
    ~4                     J   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SS	KJr  SS
KJr  SSKJr  S r\R.                  \R0                  " \R2                  R4                  5       " S S\R6                  5      5       5       r\R0                  " \R2                  R:                  5       " S S\5      5       r\R0                  " \R2                  R>                  5       " S S\5      5       r SSSS.\l!        SSSS.\l!        SSSS.\ l!        g)z#Command to update forwarding-rules.    )absolute_import)division)unicode_literals)messages)base_classes)	constants)base)
exceptions)flags)labels_utilc                    [         R                  " 5       U l        U R                  R                  U5        [        R
                  " U5        U(       a  [         R                  " USS9  [         R                  " U5        [         R                  " U5        [         R                  " U5        [         R                  " U5        g)z*Add the flags to create a forwarding rule.T)
for_updateN)r   ForwardingRuleArgumentFORWARDING_RULE_ARGAddArgumentr   AddUpdateLabelsFlagsAddNetworkTierAddSourceIpRangesAddAllowGlobalAccessAddAllowPscGlobalAccessAddExternalMigration)clsparsersupport_network_tiers      .lib/surface/compute/forwarding_rules/update.py_Argsr       s     "88:#%%f-""6*	D1&!V$'V$    c                       \ rS rSrSrSrSr\S 5       rS r	S r
S rS	 rS
 rS rS rS rS\S\R$                  4S jrS rSrg)UpdateGA1   (Update a Compute Engine forwarding rule.NFc                 .    [        U UU R                  S9  g )N)r   )r   _support_network_tier)r   r   s     r   ArgsUpdateGA.Args:   s    	 66r   c           	          UR                  UR                  UR                  5       UR                  UR                  US9S9$ )NlabelFingerprintlabels)projectresourceglobalSetLabelsRequest),ComputeGlobalForwardingRulesSetLabelsRequestr*   NameGlobalSetLabelsRequestr(   selfr   forwarding_rule_refforwarding_rulereplacements        r   _CreateGlobalSetLabelsRequest&UpdateGA._CreateGlobalSetLabelsRequestB   sO    @@#++$))+'>>,==  ?    A ! !r   c           
          UR                  UR                  UR                  5       UR                  UR	                  UR
                  US9S9$ )Nr'   )r*   r+   regionregionSetLabelsRequest)&ComputeForwardingRulesSetLabelsRequestr*   r.   r8   RegionSetLabelsRequestr(   r0   s        r   _CreateRegionalSetLabelsRequest(UpdateGA._CreateRegionalSetLabelsRequestK   sW    ::#++$))+"))'>>,==  ?   	 ; ! !r   c                     U(       ac  UR                  5       nU[        R                  ;   a  UR                  R	                  U5      $ [
        R                  " SSR                  US95      eg )Nz--network-tierzInvalid network tier [{tier}])tier)upperr   !NETWORK_TIER_CHOICES_FOR_INSTANCEForwardingRuleNetworkTierValueValuesEnumcalliope_exceptionsInvalidArgumentExceptionformat)r1   r   network_tiers      r   ConstructNetworkTierUpdateGA.ConstructNetworkTierU   sf    !'')l	DD	D&&AA,OO!::+222EG 	G r   c                 D    U R                   =(       a    UR                  S L$ )N)r#   rG   r1   argss     r   _HasNextTierChangeUpdateGA._HasNextTierChangea   s    %%G$*;*;4*GGr   c                 $    UR                  S5      $ )Nsource_ip_rangesIsSpecifiedrK   s     r   _HasSourceIpRangeChange UpdateGA._HasSourceIpRangeChanged   s    .//r   c                 $    UR                  S5      $ )Nallow_global_accessrQ   rK   s     r   _HasGlobalAccessChangeUpdateGA._HasGlobalAccessChangeg   s    122r   c                 $    UR                  S5      $ )Nallow_psc_global_accessrQ   rK   s     r   _HasPscGlobalAccessChange"UpdateGA._HasPscGlobalAccessChangej   s    566r   c                     UR                  S5      =(       dA    UR                  S5      =(       d)    UR                  S5      =(       d    UR                  S5      $ )N<external_managed_backend_bucket_migration_testing_percentage/external_managed_backend_bucket_migration_state5clear_external_managed_backend_bucket_migration_stateload_balancing_schemerQ   rK   s     r   _HasExternalMigrationChange$UpdateGA._HasExternalMigrationChangem   s\    J	
 	5 MN	5 C
		5 34	r   r   returnc                    SnUR                  UR                  S9nU R                  U5      (       a"  U R                  XR                  5      Ul        SnU R                  U5      (       a  UR                  Ul        SnU R                  U5      (       a  UR                  Ul        SnU R                  U5      (       a$  UR                  Ul        UR                  Ul        SnUR!                  S5      (       a,  UR                   R#                  UR$                  5      Ul        SnUR!                  S5      (       a  UR(                  Ul        SnUR!                  S5      (       a,  UR                   R-                  UR.                  5      Ul        SnUR!                  S5      (       a$  UR3                  S5        UR3                  S	5        SnU(       d  g
U$ )z?Returns a modified forwarding rule message and included fields.F)nameTr_   r^   ra   r`   *externalManagedBackendBucketMigrationState6externalManagedBackendBucketMigrationTestingPercentageN)rB   rf   rM   rH   rG   networkTierrS   rP   sourceIpRangesrW   rV   allowGlobalAccessr[   rZ   allowPscGlobalAccessfingerprintrR   9ExternalManagedBackendBucketMigrationStateValueValuesEnumr_   rg   r^   rh   "LoadBalancingSchemeValueValuesEnumra   loadBalancingSchemeappend)r1   r   rL   existingcleared_fields
has_changer3   s          r   ModifyUpdateGA.Modifyy   s    J--8==-AOt$$$($=$=
%%%'o!j##D))'+'<'<o$j""4((*.*B*Bo'j%%d++-1-I-Io*$,$8$8o!jIJJCKCZCZ  DU  DU

>
>Do@ jF  
K
K L j/00

!
!
D
D(( )
 j?  HI
B jr   c           
         [         R                  " U R                  5       5      nUR                  R                  nUR                  R
                  nU R                  R                  UUR                  [        R                  " UR                  5      S9n[        R                  R                  U5      nUR                  5       n[        UU R!                  U5      U R#                  U5      U R%                  U5      U R'                  U5      U R)                  U5      /5      nU(       d  [*        R,                  " S5      eUR/                  5       S:X  aL  UR0                  SUR3                  UR5                  5       UR6                  S94n	UR8                  R:                  n
OVUR<                  SUR?                  UR5                  5       UR6                  UR@                  S94n	URB                  R:                  n
UR                  RE                  U	/5      nUS   n/ nU RG                  XAX5      nURI                  XRJ                  5      n/ nUR/                  5       S:X  a  U(       aG  URM                  UR5                  5       UUR6                  S9nURO                  UR0                  S	U45        URP                  (       a<  U RS                  UUUURJ                  5      nURO                  UR0                  S
U45        OU(       aR  URU                  UR5                  5       UUR6                  UR@                  S9nURO                  UR<                  S	U45        URP                  (       a<  U RW                  UUUURJ                  5      nURO                  UR<                  S
U45        URY                  U5         UR                  RE                  U5      sSSS5        $ ! , (       d  f       g= f)zCReturns a list of requests necessary for updating forwarding rules.)scope_listerz(At least one property must be specified.zcompute.globalForwardingRulesGet)forwardingRuler*   )rz   r*   r8   r   )rz   forwardingRuleResourcer*   Patch	SetLabels)rz   r{   r*   r8   N)-r   ComputeApiHolderReleaseTrackclientapitools_clientr   r   ResolveAsResource	resourcescompute_flagsGetDefaultScopeListerr   DiffFromUpdateArgsMayHaveUpdatesanyrM   rW   r[   rS   rb   fw_exceptionsArgumentError
CollectionglobalForwardingRules&ComputeGlobalForwardingRulesGetRequestr.   r*   r/   LabelsValueforwardingRules ComputeForwardingRulesGetRequestr8   r;   MakeRequestsru   Applyr)   (ComputeGlobalForwardingRulesPatchRequestrq   needs_updater5   "ComputeForwardingRulesPatchRequestr<   IncludeFields)r1   rL   holderr   r   r2   labels_diffhas_labels_updatesrt   get_requestlabels_valueobjectsr3   rs   forwarding_rule_replacementlabel_updaterequestsrequests                     r   RunUpdateGA.Run   s   **4+<+<+>?F]]**F}}%%H22DD"88G E I
 ""11$7K$335%##D)&&t,$$T*((. J ''
46 6 %%'+JJ115DD(;(@(@(B!4!<!< E >?k 44@@l++U>>(;(@(@(B!4!<!< 3 : : ? <=k
 44@@lmm((+7GajON"&++# $$\3I3IJL H%%'+JJ	$CC.335#>'// D 1 	55wHI		"	"44X5H5D5A5H5HJ 	55{GLM	$==.335#>'//&--	 > /
 	//'BC		"	"66x7J7F7C7J7JL 	//gFG			n	-]]''1 
.	-	-s   +O
O )__name__
__module____qualname____firstlineno____doc__r   r#   classmethodr$   r5   r<   rH   rM   rS   rW   r[   rb   message_protoMessageru   r   __static_attributes__r   r   r   r   r   1   sp     1 !!
H037
;#;;zS2r   r   c                       \ rS rSrSrSrSrg)
UpdateBetai  r!   Fr   Nr   r   r   r   r   r#   r   r   r   r   r   r     s    0r   r   c                       \ rS rSrSrSrSrg)UpdateAlphai  r!   Tr   Nr   r   r   r   r   r     s    0r   r   r!   zX        *{command}* updates global access for a Compute Engine forwarding rule.
        a          To update the forwarding rule to allow global access, run:

          $ {command} example-fr --allow-global-access --region=us-central1

        To add/update labels ``k0'' and ``k1'' and remove labels with key ``k3'',
        run:

          $ {command} example-fr --region=us-central1           --update-labels=k0=value1,k1=value2 --remove-labels=k3

        Labels can be used to identify the forwarding rule and to filter them as
        in

          $ {parent_command} list --filter='labels.k1:value2'

        To list existing labels, run:

          $ {parent_command} describe example-fr --format="default(labels)"
        )briefDESCRIPTIONEXAMPLESzk        *{command}* updates labels and global access for a Compute
        Engine forwarding rule.
        zy        *{command}* updates labels, global access and network tier for a Compute
        Engine forwarding rule.
        a          To update the forwarding rule to allow global access, run:

          $ {command} example-fr --allow-global-access --region=us-central1

        To add/update labels ``k0'' and ``k1'' and remove labels with key ``k3''
        , run:

          $ {command} example-fr --region=us-central1             --update-labels=k0=value1,k1=value2 --remove-labels=k3

        Labels can be used to identify the forwarding rule and to filter them as
        in

          $ {parent_command} list --filter='labels.k1:value2'

        To list existing labels, run:

          $ {parent_command} describe example-fr --format="default(labels)"
        N)"r   
__future__r   r   r   apitools.base.protorpcliter   r   googlecloudsdk.api_lib.computer   r   googlecloudsdk.callioper	   r
   rD   "googlecloudsdk.command_lib.computer   r   3googlecloudsdk.command_lib.compute.forwarding_rulesr   $googlecloudsdk.command_lib.util.argsr   r   UniverseCompatibleReleaseTracksr   GAUpdateCommandr   BETAr   ALPHAr   detailed_helpr   r   r   <module>r      s.   * &  ' @ 7 4 ( E E [ E <%" D%%(()V2t!! V2 * V2r D%%**+    ,  D%%++,*  - 	3		 @ 	3	
	
 B 	3	
	 r   