
    )/                     b   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S
KJr  SS
KJr  SSKJr  \
R6                  " \
R8                  R:                  5      \
R<                   " S S\
R>                  5      5       5       r \
R6                  " \
R8                  RB                  5      \
R<                   " S S\ 5      5       5       r"\
R6                  " \
R8                  RF                  5      \
R<                   " S S\"5      5       5       r$g)z&Commands for updating backend buckets.    )absolute_import)division)unicode_literals)encoding)base_classes)base)cdn_flags_utils)
exceptions)flags)scope)signed_url_flags)backend_buckets_utils)logc                   d    \ rS 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rg)Update$   zIUpdate a backend bucket.

*{command}* is used to update backend buckets.
NFc                    [         R                  " XSU R                  5        [         R                  R	                  U5        [
        R                  " USSS9  [        R                  " USSS9  [        R                  " SS9U l        U R                  R	                  U5        [         R                  " U5        [         R                  " U5        g	)
z"Set up arguments for this command.updateF )requiredunspecified_helpzbackend bucketT)update_command)resourceN)backend_buckets_flagsAddUpdatableArgssupport_regional_global_flagsGCS_BUCKET_ARGAddArgumentr   AddSignedUrlCacheMaxAge	cdn_flagsAddCdnPolicyArgssecurity_policy_flags+EdgeSecurityPolicyArgumentForTargetResourceEDGE_SECURITY_POLICY_ARGAddCacheKeyExtendedCachingArgsAddCompressionMode)clsparsers     -lib/surface/compute/backend_buckets/update.pyArgsUpdate.Args1   s     **Xs@@ ((44V<,,5 v'7M 	II%	'     ,,V488@,,V4    c                 D   UR                  S5      =(       d    UR                  S5      =(       dq    UR                  S5      =(       dY    UR                  S5      =(       dA    UR                  S5      =(       d)    UR                  S5      =(       d    UR                  S5      $ )zDReturns true if any args for updating backend bucket were specified.descriptiongcs_bucket_name
enable_cdnedge_security_policycache_key_include_http_header cache_key_query_string_whitelistcompression_mode)IsSpecifiedselfargss     r)   AnyArgsSpecifiedUpdate.AnyArgsSpecifiedF   s    ]+ 1./1\*1 341 <=	1
 ?@1 /02r,   c                    [        UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S	5      UR                  S
5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      UR                  S5      45      $ )zSReturns true if any Flexible Cache args for updating backend bucket were specified.
cache_mode
client_ttlno_client_ttldefault_ttlno_default_ttlmax_ttl
no_max_ttlcustom_response_headerno_custom_response_headersnegative_cachingnegative_caching_policyno_negative_caching_policiesserve_while_staleno_serve_while_stalebypass_cache_on_request_headers"no_bypass_cache_on_request_headers)anyr5   r6   s     r)   AnyFlexibleCacheArgsSpecified$Update.AnyFlexibleCacheArgsSpecifiedP   s    			,	')9)9,)G			/	*D,<,<],K			*	+T-=-=i-H			,	'			2	3			6	7			,	-			3	4			8	9			-	.			0	1			;	<			>	?	AB Br,   c                 d   UR                  5       S:X  aT  UR                  R                  SUR                  R	                  UR
                  UR                  UR                  5       S94$ UR                  R                  SUR                  R                  UR
                  UR                  5       S94$ )z1Returns a request to retrieve the backend bucket.compute.regionBackendBucketsGet)projectregionbackendBucket)rR   rT   )

Collectionapitools_clientregionBackendBucketsmessages%ComputeRegionBackendBucketsGetRequestrR   rS   NamebackendBucketsComputeBackendBucketsGetRequest)r7   clientbackend_bucket_refs      r)   GetGetRequestUpdate.GetGetRequesta   s    $$&*HH

 
 
5
5

//
?
?(00'...335 @   ""115OO;;*220557 < 9: :r,   c           	      h   UR                  5       S:X  aU  UR                  R                  SUR                  R	                  UR
                  UR                  UR                  5       US94$ UR                  R                  SUR                  R                  UR
                  UR                  5       US94$ )z/Returns a request to update the backend bucket.rP   Patch)rR   rS   rT   backendBucketResource)rR   rT   rc   )
rU   rV   rW   rX   'ComputeRegionBackendBucketsPatchRequestrR   rS   rZ   r[   !ComputeBackendBucketsPatchRequest)r7   r]   r^   replacements       r)   GetSetRequestUpdate.GetSetRequestr   s    $$&*HH

 
 
5
5

//
A
A(00'...335$/	 B 	 	 ""117OO==*220557&1 > 34 4r,   c           
         UR                  5       S:X  a  [        R                  " S5      eUR                  R                  SUR
                  R                  UR                  UR                  5       UR
                  R                  US9S94$ )z@Returns a request to set the edge policy for the backend bucket.rP   z?Regional backend buckets do not support edge security policies.SetEdgeSecurityPolicy)securityPolicy)rR   rT   securityPolicyReference)
rU   r
   ArgumentErrorrV   r[   rX   1ComputeBackendBucketsSetEdgeSecurityPolicyRequestrR   rZ   SecurityPolicyReference)r7   r]   r^   security_policy_refs       r)   GetSetEdgeSecurityPolicyRequest&Update.GetSetEdgeSecurityPolicyRequest   s     $$&*HH$$
KM M""113JOOMM*220557(.(O(O#6 )P )8 N 9: :r,   c                    [         R                  " U R                  5       5      nUR                  n[        R
                  " U5      n/ nUR                  S5      (       a  UR                  Ul        UR                  (       a  UR                  Ul	        UR                  b  UR                  Ul        [        R                  " UUUSUS9  UR                  b  UR                  Ul        UR                   (       a  / Ul        UR                  (       d  UR#                  S5        UR$                  b1  UR$                  R&                  (       a  UR                  SLa  SUl        UR(                  b4  UR*                  R,                  R/                  UR(                  5      Ul        UR                  (       d  UR#                  S5        XV4$ )z0Modifies and returns the updated backend bucket.r.   T)	is_updatecleared_fieldscustomResponseHeadersF)r   ComputeApiHolderReleaseTrackr]   r   CopyProtoMessager5   r.   r/   
bucketNamer0   	enableCdnr   ApplyCdnPolicyArgsrC   rv   rD   append	cdnPolicy	cacheModer4   rX   BackendBucketCompressionModeValueValuesEnumcompressionMode)r7   r8   existingholderr]   rf   ru   s          r)   ModifyUpdate.Modify   sl   **4+<+<+>?F]]F++H5KN&& $ 0 0k#33k""ook,,%' "".*.*E*Ek'&&*,k',,34)''DOO5,H"k(
//
'
'
F
F##% ! ""M*&&r,   c                    [         R                  " U R                  5       5      nUR                  nU R                  (       aW  [
        R                  R                  UUR                  [        R                  " U5      [        R                  R                  S9nO%U R                  R                  XR                  5      nU R                  X45      nUR!                  U/5      nU R#                  XS   5      u  pxUS   U:X  aN  [%        USS5      c=  [&        R(                  R+                  SR-                  US   R.                  5      5        U$ / n	OFUR0                  R3                  U5         UR!                  U R5                  X4U5      /5      n	SSS5        [%        USS5      b  UR7                  5       S:X  a  [8        R:                  " S5      e[%        USS5      (       a4  U R<                  R                  XR                  5      R?                  5       n
OSn
U RA                  X4U
5      nUR!                  U/5      nW	U-   $ / nW	U-   $ ! , (       d  f       N= f)z3Makes the requests for updating the backend bucket.)scope_listerdefault_scoper   r1   Nz/No change requested; skipping update for [{0}].rP   z`argument --edge-security-policy: Regional backend buckets do not support edge security policies.)!r   rw   rx   r]   r   r   "GLOBAL_REGIONAL_BACKEND_BUCKET_ARGResolveAsResource	resourcescompute_flagsGetDefaultScopeListercompute_scope	ScopeEnumGLOBALBACKEND_BUCKET_ARGr_   MakeRequestsr   getattrr   statusPrintformatnamerV   IncludeFieldsrg   rU   r
   rm   r$   SelfLinkrq   )r7   r8   r   r]   r^   get_requestobjects
new_objectru   backend_bucket_resultrp   edge_security_policy_requestedge_security_policy_results                r)   r   Update.MakeRequests   s<   **4+<+<+>?F]]F))0SSee



$::6B%//66	 f   22DD
   $$V@K!!;-0G!%T1:!>J
 qzZ	-t	4	<

=DD
!	"  !!//? & 3 3JGH!J @
 t+T2>		&	&	(,J	J&&/
 	
 
-t	4	4";;MM""$$,HJ 	 #%)%I%I
&9&;"$*$7$7'
(%*!
 !#>>> %'! #>>>1 @?s   )#I
Ic                     U R                  U5      (       dX  UR                  S5      (       dB  UR                  S5      (       d,  U R                  U5      (       d  [        R                  " S5      eU R                  U5      $ )z;Issues the request necessary for updating a backend bucket.signed_url_cache_max_agerequest_coalescingz'At least one property must be modified.)r9   r5   rM   r
   UpdatePropertyErrorr   r6   s     r)   Run
Update.Run   so    !!$''788122..t44**
35 5T""r,    )__name__
__module____qualname____firstlineno____doc__r   r$   r   classmethodr*   r9   rM   r_   rg   rq   r   r   r   __static_attributes__r   r,   r)   r   r   $   sX    
 !"'5 5(2B":"4&:('T:?x#r,   r   c                       \ rS rSrSrSrSrg)
UpdateBetai  a  Update a backend bucket.

*{command}* is used to update backend buckets.

  To delete a global backend bucket, run either of the following:

    $ {command} my-backend-bucket
      --no-enable-cdn
      --global

    $ {command} my-backend-bucket
      --no-enable-cdn

To delete a regional backend bucket, run the following:

    $ {command} my-backend-bucket --region=us-central1
      --no-enable-cdn
Tr   Nr   r   r   r   r   r   r   r   r,   r)   r   r         & #'r,   r   c                       \ rS rSrSrSrSrg)UpdateAlphai  a  Update a backend bucket.

*{command}* is used to update backend buckets.

    To delete a global backend bucket, run either of the following:

    $ {command} my-backend-bucket
      --no-enable-cdn
      --global

    $ {command} my-backend-bucket
      --no-enable-cdn

To delete a regional backend bucket, run the following:

    $ {command} my-backend-bucket --region=us-central1
      --no-enable-cdn
Tr   Nr   r   r,   r)   r   r     r   r,   r   N)%r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.computer   googlecloudsdk.callioper   "googlecloudsdk.command_lib.computer	   r    r
   r   r   r   r   r   2googlecloudsdk.command_lib.compute.backend_bucketsr   r   4googlecloudsdk.command_lib.compute.security_policiesr"   googlecloudsdk.corer   ReleaseTracksrx   GAUniverseCompatibleUpdateCommandr   BETAr   ALPHAr   r   r,   r)   <module>r      s   - &  ' % 7 ( K 9 E E ? T ]$ # D%%(()Z#T Z#  *Z#z D%%**+' '  ,'. D%%++,'* '  -'r,   