
    .                     >   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  \R.                  " \R0                  R2                  5      \R4                   " S S\R6                  5      5       5       r\R.                  " \R0                  R:                  5      \R4                   " S S\5      5       5       r\R.                  " \R0                  R>                  5      \R4                   " S S\5      5       5       r g)z&Commands for updating backend buckets.    )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.Args.   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.AnyArgsSpecifiedC   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)anyr2   r3   s     r&   AnyFlexibleCacheArgsSpecified$Update.AnyFlexibleCacheArgsSpecifiedM   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)rO   rQ   )

Collectionapitools_clientregionBackendBucketsmessages%ComputeRegionBackendBucketsGetRequestrO   rP   NamebackendBucketsComputeBackendBucketsGetRequest)r4   clientbackend_bucket_refs      r&   GetGetRequestUpdate.GetGetRequest^   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.rM   Patch)rO   rP   rQ   backendBucketResource)rO   rQ   r`   )
rR   rS   rT   rU   'ComputeRegionBackendBucketsPatchRequestrO   rP   rW   rX   !ComputeBackendBucketsPatchRequest)r4   rZ   r[   replacements       r&   GetSetRequestUpdate.GetSetRequesto   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.rM   z?Regional backend buckets do not support edge security policies.SetEdgeSecurityPolicy)securityPolicy)rO   rQ   securityPolicyReference)
rR   r   ArgumentErrorrS   rX   rU   1ComputeBackendBucketsSetEdgeSecurityPolicyRequestrO   rW   SecurityPolicyReference)r4   rZ   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ReleaseTrackrZ   r   CopyProtoMessager2   r+   r,   
bucketNamer-   	enableCdnr   ApplyCdnPolicyArgsr@   rs   rA   append	cdnPolicy	cacheModer1   rU   BackendBucketCompressionModeValueValuesEnumcompressionMode)r4   r5   existingholderrZ   rc   rr   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   r.   Nz/No change requested; skipping update for [{0}].rM   z`argument --edge-security-policy: Regional backend buckets do not support edge security policies.)!r   rt   ru   rZ   r   r   "GLOBAL_REGIONAL_BACKEND_BUCKET_ARGResolveAsResource	resourcescompute_flagsGetDefaultScopeListercompute_scope	ScopeEnumGLOBALBACKEND_BUCKET_ARGr\   MakeRequestsr   getattrr   statusPrintformatnamerS   IncludeFieldsrd   rR   r   rj   r!   SelfLinkrn   )r4   r5   r   rZ   r[   get_requestobjects
new_objectrr   backend_bucket_resultrm   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.)r6   r2   rJ   r   UpdatePropertyErrorr   r3   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'   r6   rJ   r\   rd   rn   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)
UpdateBeta   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   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   ReleaseTracksru   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)   