
    5                       S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK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   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.J0r0  SS K.J1r1  SS!K.J2r2  SS"K3J4r4  SS#K5J6r6  SSK7r7SS$K8J9r9  \Rt                  " 5         S%r;S&\;-  r<\Rz                  R|                  S'\Rz                  R~                  S(0r@S) rAS* rB " S+ S,\2R                  5      rDS- rES. rF " S/ S0\R                  5      rH " S1 S2\R                  5      rJg)3zClient for interacting with Google Cloud Storage.

Implements CloudApi for the GCS JSON API. Example functions include listing
buckets, uploading objects, and setting lifecycle conditions.
    )absolute_import)division)unicode_literalsN)
exceptions)
list_pager)transfer)	cloud_api)errors)gcs_iam_util)headers_util)download)
error_util)metadata_util)patch_apitools_messages)upload)apis)waiter)encryption_util)	gzip_util)operations_util)
posix_util)storage_url)tracker_file_util)user_request_args_factory)gcs_resource_reference)resource_reference)	copy_util)download_util)log)
properties)requests)
transports)scaled_integer)urllibi   i   JSON_API_V1NONEc           
      .   [         R                  R                  R                  R	                  5       nU(       a  UR                  SS5      nO[        R                  " S5      nSR                  U[         R                  R                  R                  R	                  5       U R                  [        R                  R                  U R                  R                  S5      SS95      nU R                   (       a  USR                  U R                   5      -   $ U$ )	zGGenerates link https://cloud.google.com/storage/docs/request-endpoints.zstorage/v1/ zhttps://storage.googleapis.com/z){}download/storage/{}/b/{}/o/{}?alt=mediazutf-8   ~)safez&generation={})r    VALUESapi_endpoint_overridesstorageGetreplace	core_apisUniversifyAddressformatjson_api_versionbucketr$   parsequotenameencode
generation)object_resourcecustom_endpointbase
url_strings       5lib/googlecloudsdk/api_lib/storage/gcs_json/client.py_get_download_linkr?   Q   s    %%<<DDHHJ/""="5D&&'HID:AA
00446 ll--44W=DI* (//0J0JKKK	    c                     U R                   (       a  U R                   R                  nO[        U 5      nSUU R                  US.n[        R
                  " U5      $ )zGenerates download serialization data for Apitools.

Args:
  object_resource (resource_reference.ObjectResource): Used to get metadata.
  progress (int): Represents how much of download is complete.

Returns:
  JSON string for use with Apitools.
F)auto_transferprogress
total_sizeurl)metadata	mediaLinkr?   sizejsondumps)r:   rC   download_linkserialization_dicts       r>   get_download_serialization_datarM   f   sT     #,,66M&7M#((	 
&	''r@   c                   D   ^  \ rS rSrSrU 4S jr    SS jrS rSrU =r	$ )_StorageStreamResponseHandler}   zBHandler for writing the streaming response to the download stream.c                 B  > [         [        U ]  SS9  SU l        0 U l        SU l        SU l        SU l        [        R                  " [        R                  R                  R                  R                  5       5      U l        [!        ["        U R                  5      U l        g)z4Initializes response handler for requests downloads.T)
use_streamN)r   )superrO   __init___stream
_digesters_processed_bytes_progress_callback_sizer#   ParseIntegerr    r+   r-   download_chunk_sizer.   _chunk_sizemax#MINIMUM_PROGRESS_CALLBACK_THRESHOLD_progress_callback_thresholdself	__class__s    r>   rT   &_StorageStreamResponseHandler.__init__   s    	
'747HDLDOD"DDJ%22!!5599;=D ),,O,0,<,<)>D%r@   c                 z    Xl         X l        Ub  UO0 U l        X@l        XPl        X`l        U R                  U l        g)a  Updates the stream handler with destination information.

The download_http_client object is stored on the gcs_api object. This allows
resusing the same http_client when the gcs_api is cached using
threading.local, which improves performance.
Since this same object gets used for multiple downloads, we need to update
the stream handler with the current active download's destination.

Args:
  stream (stream): Local stream to write downloaded data to.
  size (int): The amount of data in bytes to be downloaded.
  digesters (dict<HashAlgorithm, hashlib object> | None): For updating hash
    digests of downloaded objects on the fly.
  download_strategy (DownloadStrategy): Indicates if user wants to retry
    download on failures.
  processed_bytes (int): For keeping track of how much progress has been
    made.
  progress_callback (func<int>): Accepts processed_bytes and submits
    progress info for aggregation.
N)rU   rY   rV   _download_strategyrW   rX   _start_byte)ra   streamrH   	digestersdownload_strategyprocessed_bytesprogress_callbacks          r>   update_destination_info5_StorageStreamResponseHandler.update_destination_info   s<    6 LJ#,#8ibDO/+/,,Dr@   c                 p   U R                   c  [        R                  " S5      eSnSn UR                  U R                  5      nU(       a   U R                   R                  U5        U R                  R!                  5        H  nUR#                  U5        M     U =R$                  ['        U5      -  sl        U['        U5      -  nU R(                  (       a:  UU R*                  :  a*  U R)                  U R$                  5        UU R*                  -
  nO4U R(                  (       a"  U(       a  U R)                  U R$                  5        OGM  U R$                  U R,                  -
  nU R.                  U:w  aP  U(       dH  SR1                  U R.                  U5      n[        R2                  " U5        [4        R6                  " U5      eg g ! [         ai  nUR                  [        R                  :X  aE  U R                  [        R                  R                  L a  [        R                  " S5        Sn S nAM  e S nAff = f)NzStream was not found.Fr   Tz4Writing to download stream raised broken pipe error.z:Download not completed. Target size={}, downloaded data={})rU   command_errorsErrorreadr\   writeOSErrorerrnoEPIPEre   r	   DownloadStrategyONE_SHOTr   inforV   valuesupdaterW   lenrX   r_   rf   rY   r2   debugcloud_errorsRetryableApiError)	ra   source_streamdestination_pipe_is_broken"bytes_since_last_progress_callbackdataehash_objecttotal_downloaded_datamessages	            r>   handle$_StorageStreamResponseHandler.handle   s   ||  !899 "')*&
 0 01d		
,,

T
"  ??113K


T
" 4 	T**c$i7*##(J--).

!
!$"7"7
80//0 - ""'I

!
!$"7"7
89 < !11D4D4DDzz**3M G
M
Mjj/1  
ii**733 4N*5  	gg$%%)C)C)L)LLHHKL)-&
	s   G 
H5AH0/H00H5)	r\   rV   re   rW   rX   r_   rY   rf   rU   )NNr   N)
__name__
__module____qualname____firstlineno____doc__rT   rl   r   __static_attributes____classcell__rb   s   @r>   rO   rO   }   s)    J>& )-04./04"-H.4 .4r@   rO   c                     U (       aV  U [         R                  :w  aB  U R                  [        R                  R
                  :X  a  SU R                  U R                  S.$ 0 $ )NAES256)zx-goog-encryption-algorithmzx-goog-encryption-keyzx-goog-encryption-key-sha256)r   CLEARtyper   KeyTypeCSEKkeysha256)r   s    r>   _get_encryption_headersr      sM    	c.444	hh/))...'/!$(+

 
 
)r@   c                 >   [         R                  R                  R                  R	                  5       nU R
                  R                  R                  S5      nUc  g UR                  R                  SU5      Ul        UR                  R                  SU5      Ul
        g )NInsertv1)r    r+   r-   r3   r.   objects_upload_configsgetsimple_pathr/   resumable_path)clientapi_versioninsert_configs      r>   )_update_api_version_for_uploads_if_neededr      s    !!))::>>@+..0044X>-
+77??
K-!.!=!=!E!E
K"-r@   c                   D    \ rS rSrSr\R                  " SS5      rS rSr	g)CloudStorageLroPoller   zPoller for Storage LROs.r-   r   c                 T    [         R                  " UR                  5      u  p#U R                  R                  X#S9nU R                  R                  U5      $ ! [        R                   a;    [
        R                  " S5        [        R                  " SUR                   S35      ef = f)z
Overrides.zWe could not wait for the operation to complete because the required data was incorrect. The operation may still have completed in the background. Please check if the operation has completed before retrying.z3Invalid operation data initiated for this command: z=. Please check if command completed in the background before r4   operationId)r   %get_operation_bucket_and_id_from_namer7   ro   rp   r   warningr}   GcsApiError	_MESSAGES"StorageBucketsOperationsGetRequestoperation_servicer.   )ra   operation_refr4   operation_idrequests        r>   PollCloudStorageLroPoller.Poll  s    

?
?   f$ nn?? @ G !!%%g..!  	kk $$  ! "   s   "A AB' N)
r   r   r   r   r   r0   GetMessagesModuler   r   r   r   r@   r>   r   r      s     )))T:)/r@   r   c                     ^  \ rS rSrSr\R                  R                  \R                  R                  \R                  R                  \R                  R                  \R                  R                  \R                  R                  \R                  R                  \R                  R                  1rSrU 4S jr\R&                  S 5       rS rS rS rS	 r\R4                  " 5       S
 5       r\R4                  " 5       S 5       r\R4                  " 5       S 5       r\R4                  " 5       S 5       r\R4                  " 5       S 5       r\R4                  " 5       S 5       r \R4                  " 5       S 5       r!\R4                  " 5       \RD                  RF                  4S j5       r$\R4                  " 5       S 5       r%\R4                  " 5       S\RD                  RF                  S4S j5       r&\R4                  " 5       S 5       r'\RD                  RF                  SS4S jr(\R4                  " 5         SGS j5       r)\R4                  " 5       S 5       r*\R4                  " 5       \RD                  RF                  4S j5       r+\R4                  " 5       S 5       r,\R4                  " 5       S 5       r-\R4                  " 5       S 5       r.\R4                  " 5       S 5       r/SS\RD                  R`                  4S jr1\R4                  " 5       S  5       r2\R4                  " 5         SHS! j5       r3\R4                  " 5          SIS" j5       r4\R4                  " 5       S# 5       r5\R4                  " 5       SS\Rl                  Rn                  SS$S4S% j5       r8\R4                  " 5       SJS& j5       r9\R4                  " 5       SS\RD                  RF                  S4S' j5       r:SS\RD                  RF                  S(SS\Rv                  Rx                  S4S) jr=\R4                  " 5       \RD                  RF                  SS4S* j5       r>\R4                  " 5        SJS+ j5       r?\R4                  " 5       SSSS\R                  R                  4S, j5       rB\R4                  " 5       S- 5       rC\R4                  " 5       S. 5       rD\R4                  " 5       S/ 5       rE\R4                  " 5       S0 5       rFSJS1 jrG\R4                  " 5       S2 5       rH\R4                  " 5       SKS3 j5       rI\R4                  " 5       S4 5       rJ\R4                  " 5       S5 5       rKSHS6 jrL\R4                  " 5       S7 5       rM\R4                  " 5       SHS8 j5       rN\R4                  " 5       SSS\R                  R                  4S9 j5       rQ\R4                  " 5       S: 5       rR\R4                  " 5       S; 5       rS\R4                  " 5       S< 5       rT\R4                  " 5       SJS= j5       rU\R4                  " 5       S> 5       rV\R4                  " 5       S? 5       rWSJS@ jrX\R4                  " 5       SA 5       rY\R4                  " 5       SB 5       rZ\R4                  " 5            SLSC j5       r[\R4                  " 5       SD 5       r\\R4                  " 5       SE 5       r]SFr^U =r_$ )M
JsonClienti  z$Client for Google Cloud Storage API.    c                 h  > [         [        U ]  5         [        R                  " SS5      U l        [        U R
                  5        SU R
                  l        [        R                  " 5       U R
                  l
        [        R                  " SS5      U l        [        5       U l        S U l        S U l        g )Nr-   r   T)rS   r   rT   r0   GetClientInstancer   r   (overwrite_transfer_urls_with_client_baser   get_additional_header_dictadditional_http_headersr   messagesrO   _stream_response_handler_download_http_client_upload_http_clientr`   s    r>   rT   JsonClient.__init__/  s    	*d$&--i>DK-dkk:;?DKK8//1 	KK' //	4@DM$A$CD!!%D#Dr@   c              #      #    U(       aI  U R                   R                  R                  5       nU R                   R                  R                  U5        S v   U(       a  WU R                   l        g g 7fN)r   r   copyrz   )ra   headersold_headerss      r>   !_apitools_request_headers_context,JsonClient._apitools_request_headers_context>  sO     KK77<<>k
kk))009	,7dkk) s   A/A1c                 6    U R                  [        U5      5      $ r   )r   r   )ra   r   s     r>   _encryption_headers_context&JsonClient._encryption_headers_contextG  s    112I#2NOOr@   c                 h   0 n[        UR                  SS 5      nUR                  [        U5      5        [        UR                  SS 5      nU(       aQ  UR                  [
        R                  R                  :X  a)  UR                  SUR                  UR                  S.5        U R                  U5      $ )Nencryption_keydecryption_keyr   )z'x-goog-copy-source-encryption-algorithmz!x-goog-copy-source-encryption-keyz(x-goog-copy-source-encryption-key-sha256)getattrresource_argsrz   r   r   r   r   r   r   r   r   )ra   request_configadditional_headersr   r   s        r>   ,_encryption_headers_for_rewrite_call_context7JsonClient._encryption_headers_for_rewrite_call_contextJ  s    ^99;K!#N5nEF^99;K!#N.--1H1H1M1MM5=/=/A/A6D6K6K! 	
 112DEEr@   c                 &    U[         R                  ;  a  [        R                  " S5      e UR
                  nU[         R                  R                  :X  a  UR                  $ UR                  $ ! [         a    [        R                  " S5      ef = f)aq  Generate query projection from fields_scope.

Args:
  fields_scope (FieldsScope): Used to determine projection to return.
  message_class (object): Apitools message object that contains a projection
    enum.

Returns:
  projection (ProjectionValueValuesEnum): Determines if ACL properties
      should be returned.

Raises:
  Error: The fields_scope isn't recognized.
zInvalid fields_scope.)	r	   FieldsScopero   rp   	TypeErrorProjectionValueValuesEnumFULLfullnoAcl)ra   fields_scopemessage_classprojection_enums       r>   _get_projectionJsonClient._get_projectionZ  s    :	Y22	2""#:;; 
3 $==Oy,,111!!!     :  !899:s   *A/ /!Bc                 >    U(       a  UR                   R                  $ g)zGet source path from source_resource.

Args:
  source_resource (FileObjectResource|None): Contains the
    source StorageUrl. Can be None if source is pure stream.

Returns:
  (str|None) Source path.
N)r   versionless_url_string)ra   source_resources     r>   _get_source_pathJsonClient._get_source_patht  s     ((???r@   c                    U R                   R                  UUUUS9nU R                  S[        R                  " 5       R
                  05         U R                  R                  R                  U5      nSSS5        U$ ! , (       d  f       W$ = f)See super class.)r4   zoneadmissionPolicyttlx-goog-gcs-idempotency-tokenN)	r   AnywhereCacher   uuiduuid4hexr   anywhereCachesr   )ra   bucket_namer   admission_policyr   r   	operations          r>   create_anywhere_cache JsonClient.create_anywhere_cache  s     mm))(	 * G 
	/	/	')9)9:
 ++,,33G<i
 	
 
    &A==
Bc                     U R                   R                  UUS9nU R                  R                  R	                  U5        gr   r4   anywhereCacheIdN)r   #StorageAnywhereCachesDisableRequestr   r   Disablera   r   anywhere_cache_idr   s       r>   disable_anywhere_cache!JsonClient.disable_anywhere_cache  s>     mm??) @ G 	KK&&w/r@   c                     U R                   R                  UUS9n[        R                  " U R                  R
                  R                  U5      5      $ )r   r   )r   StorageAnywhereCachesGetRequestr   )get_anywhere_cache_resource_from_metadatar   r   r.   r  s       r>   get_anywhere_cacheJsonClient.get_anywhere_cache  sP     mm;;) < G BB""&&w/ r@   c              #     #    U R                   R                  U[        R                  SS9n[        R
                  " U R                  R                  U[        R                  SS9n U H  n[        R                  " U5      v   M     g! [        R                   aC  n[        R                  " [        R                  " U[         R"                  5      5         SnAgSnAff = f7f)r   N)r4   pageSize	pageTokenr  )
batch_sizebatch_size_attribute)r    StorageAnywhereCachesListRequestr	   NUM_ITEMS_PER_LIST_PAGEr   YieldFromListr   r   r   r  apitools_exceptions	HttpErrorcore_exceptionsreraiser}   translate_errorr   ERROR_TRANSLATION)ra   r   r   anywhere_cache_iteratoranywhere_cacher   s         r>   list_anywhere_cachesJsonClient.list_anywhere_caches  s      mm<<22 = G )66""44'	3.EE
 	
 4 (( 

&
&q**F*F
G s0   A#C"&!B C"C9CC"CC"c                    U R                   R                  UUUUS9nU R                  S[        R                  " 5       R
                  05         U R                  R                  R                  U5      nSSS5        U$ ! , (       d  f       W$ = f)r   )r4   r   r   r   r   N)	r   r   r   r   r   r   r   r   Update)ra   r   r  r   r   r   r   s          r>   patch_anywhere_cacheJsonClient.patch_anywhere_cache  s     mm)))(	 * G 
	/	/	')9)9:
 ++,,33G<i
 	
 
 r   c                     U R                   R                  UUS9nU R                  R                  R	                  U5        gr   )r   !StorageAnywhereCachesPauseRequestr   r   Pauser  s       r>   pause_anywhere_cacheJsonClient.pause_anywhere_cache  s=     mm==) > G 	KK$$W-r@   c                     U R                   R                  UUS9nU R                  R                  R	                  U5        gr   )r   "StorageAnywhereCachesResumeRequestr   r   Resumer  s       r>   resume_anywhere_cache JsonClient.resume_anywhere_cache  s=     mm>>) ? G 	KK%%g.r@   c                    U R                  UU R                  R                  5      nU R                  R                  UR                  R
                  S9n[        R                  " XR5        [        USS5      nU R                  R                  U[        USS5      [        R                  R                  R                  R                  5       US9nU R                  R                  R!                  U5      n[        R"                  " U5      $ )r   r7   r   Nenable_per_object_retention)r4   enableObjectRetentionproject
projection)r   r   StorageBucketsInsertRequestBucketr   r   r   *update_bucket_metadata_from_request_configr   r    r+   corer.  	GetOrFailr   bucketsr   !get_bucket_resource_from_metadata)	ra   bucket_resourcer   r   r/  bucket_metadatar   r   created_bucket_metadatas	            r>   create_bucketJsonClient.create_bucket  s     %%l&*mm&O&OQJ mm**((44 + 6O<<) NOTBMmm77%8$
 !!&&..88: 8 G #kk1188A::! !r@   c                     U R                   R                  UUR                  S9nU R                  R                  R                  U5        g)r   r4   ifMetagenerationMatchN)r   StorageBucketsDeleteRequest!precondition_metageneration_matchr   r5  Delete)ra   r   r   r   s       r>   delete_bucketJsonClient.delete_bucket  sD     mm77,NN 8 PG
 	KKw'r@   NFc                    U R                  X0R                  R                  5      nU R                  R                  UUUU(       a  SOSS9nU R                  R                  R                  U5      n[        R                  " U5      $ )r   TN)r4   r9   r/  softDeleted)r   r   StorageBucketsGetRequestr   r5  r.   r   r6  )ra   r   r9   r   soft_deletedr/  r   rF   s           r>   
get_bucketJsonClient.get_bucket  sy     %%mm<<J mm44(Dd 5 G {{""&&w/H::8DDr@   c                     U R                   R                  SS9nU R                  R                  R	                  U R                   R                  U[        R                  S9US9$ )r   bindings,etagfields)r4   optionsRequestedPolicyVersionglobal_params)r   StandardQueryParametersr   r5  GetIamPolicy!StorageBucketsGetIamPolicyRequestr   IAM_POLICY_VERSION)ra   r   rP  s      r>   get_bucket_iam_policy JsonClient.get_bucket_iam_policy-  sl     MM99 : M ;;++77*6*I*I 	8 	
 $ ,  r@   c              #     #    U R                  XR                  R                  5      nU R                  R                  [        R                  R
                  R                  R                  5       UU(       a  SOSUS9nSnU[        R                  R                  :X  a  U R                  R                  SS9n[        R                  " U R                  R                  U[        R                   US9n U H  n["        R$                  " U5      v   M     g! [&        R(                   aC  n	[*        R,                  " [.        R0                  " U	[2        R4                  5      5         Sn	A	gSn	A	ff = f7f)r   TN)r.  r/  rE  prefixzitems/name,nextPageTokenrL  )r  rP  )r   r   StorageBucketsListRequestr    r+   r3  r.  r4  r	   r   SHORTrQ  r   r  r   r5  r  r   r6  r  r  r  r  r}   r  r   r  )
ra   r   rG  rX  r/  r   rP  bucket_iterr4   r   s
             r>   list_bucketsJsonClient.list_buckets;  s-     %%mm==J mm55!!&&..88:(Dd 6 G My,,222mm;;+ < m **44#	K&==fEE  (( 

&
&q**F*F
G s0   C-E,0!D E,E)&9E$E,$E))E,c                     Ub#  U R                   R                  R                  US9nU R                   R                  UUUS9nU R                   R                  XS9nU R                  R
                  R                  U5      $ )See CloudApi class.)dataLocations)destinationLocation destinationCustomPlacementConfigvalidateOnly)r4   relocateBucketRequest)r   RelocateBucketRequest%DestinationCustomPlacementConfigValueStorageBucketsRelocateRequestr   r5  Relocate)ra   r   destination_location#destination_custom_placement_configvalidate_onlyr   relocate_requests          r>   relocate_bucketJsonClient.relocate_bucketa  s     +6,0MM,O,O,u,u; -v -) mm110)L" 2 G
 }}BB C  ;;''(899r@   c                    UR                   =(       d    UR                  nU R                  R                  UR                  R
                  US9n[        R                  " U R                  R                  R                  U5      5      $ )Nr=  )r@  metagenerationr   (StorageBucketsLockRetentionPolicyRequestr   r   r   r6  r   r5  LockRetentionPolicy)ra   r7  r   metageneration_preconditionr   s        r>   lock_bucket_retention_policy'JsonClient.lock_bucket_retention_policyx  s{     	88 	*))   mmDD**669 E G :://8 r@   c           	         U R                  X0R                  R                  5      n[        USS5      =(       d     [        R
                  " UR                  5      n[        R                  " XR5        [        R                  " U5      nUR                  (       a9  UR                  S   [        R                  :X  a  UR                  S5        / Ul	        UR                  (       a/  UR                  [        R                  " UR                  5      5        UR                  (       aF  UR                  S5        [        U R                  R                  R                   UR                  5      nOSnUR"                  (       aF  UR                  S5        [        U R                  R                  R$                  UR"                  5      nOSnU R                  R                  UR                  R&                  UUUR(                  UUS9n	U R*                  R-                  U5         [        R.                  " U R*                  R0                  R3                  U	5      5      sSSS5        $ ! , (       d  f       g= f)r   rF   Nr   defaultObjectAclacl)r4   bucketResourcer/  r>  predefinedAclpredefinedDefaultObjectAcl)r   r   StorageBucketsPatchRequestr   r   get_apitools_metadata_from_urlr   r2  get_cleared_bucket_fieldsrw  PRIVATE_DEFAULT_OBJECT_ACLappendipFilterextendget_cleared_ip_filter_fieldspredefined_acl_stringPredefinedAclValueValuesEnum$predefined_default_object_acl_string)PredefinedDefaultObjectAclValueValuesEnumr   r@  r   IncludeFieldsr6  r5  Patch)
ra   r7  r   r   r/  rF   cleared_fieldspredefined_aclpredefined_default_object_aclapitools_requests
             r>   patch_bucketJsonClient.patch_bucket  s    %%mm>>J 
D9 44''	
 
 << #<<^LN!!%%a(334 ./"$h 

4
4X5F5F
G
 ++E"
--
2
2
O
O

.
.0n n::./&-
--
2
244

=
='?#
 '+#}}??**66,NN$#@ @ B 
	"	">	2<<
++


#
#$4
57 
3	2	2s   9I
I*c                 z    U R                   R                  R                  U R                  R	                  XS95      $ )r   )r4   policy)r   r5  SetIamPolicyr   !StorageBucketsSetIamPolicyRequest)ra   r   r  s      r>   set_bucket_iam_policy JsonClient.set_bucket_iam_policy  s;     ;;++77 	8 	/0 0r@   c                    U R                   R                  [        R                  R                  R
                  R                  5       US9n[        R                  " U R                  R                  R                  U5      5      $ )r   )	projectIdserviceAccountEmail)r   $StorageProjectsHmacKeysCreateRequestr    r+   r3  r.  r4  r   GcsHmacKeyResourcer   projects_hmacKeysCreate)ra   service_account_emailr   s      r>   create_hmac_keyJsonClient.create_hmac_key  sl     mm@@##((00::<1 A 3G "44%%,,W57 7r@   c                     U R                   R                  [        R                  R                  R
                  R                  5       US9nU R                  R                  R                  U5        g)r   r  accessIdN)
r   $StorageProjectsHmacKeysDeleteRequestr    r+   r3  r.  r4  r   r  rA  )ra   	access_idr   s      r>   delete_hmac_keyJsonClient.delete_hmac_key  sY     mm@@##((00::< A G 	KK!!((1r@   c                    U R                   R                  [        R                  R                  R
                  R                  5       US9nU R                  R                  R                  U5      n[        R                  " U5      $ )r   r  )r   !StorageProjectsHmacKeysGetRequestr    r+   r3  r.  r4  r   r  r.   r   r  )ra   r  r   responses       r>   get_hmac_keyJsonClient.get_hmac_key  sk     mm==##((00::< > G {{,,009H!44X>>r@   c              #     #    U[         R                  R                  :X  a  [        R                  " S5      eU[         R                  R
                  :X  a  SnOU R                  R                  SS9nU R                  R                  UU[        R                  R                  R                  R                  5       S9n[        R                  " UU R                   R"                  U[         R$                  S9n U H  n[&        R(                  " U5      v   M     g! [*        R,                   aC  n[.        R0                  " [2        R4                  " U[6        R8                  5      5         SnAgSnAff = f7f)r   zHMAC keys do not have ACLs.Nz7items(accessId,state,serviceAccountEmail),nextPageTokenrL  )r  showDeletedKeysr  )rP  servicer   r  )r	   r   NO_ACLro   rp   r   r   rQ  "StorageProjectsHmacKeysListRequestr    r+   r3  r.  r4  r   r  r   r  r  r   r  r  r  r  r  r}   r  r   r  )	ra   r  show_deleted_keysr   rP  r   	hmac_iterhmac_keyr   s	            r>   list_hmac_keysJsonClient.list_hmac_keys  s7     y,,333  
') )y,,111mmm;;J < Lm mm>>1)##((00::< ? G ((#--44	II($77AA  (( I

&
&q**F*F
GI IIs0   C3E26!D E2E/,9E*%E2*E//E2c                 j   U R                   R                  UR                  S9nU(       a  X$l        U R                   R	                  [
        R                  R                  R                  R                  5       UUS9n[        R                  " U R                  R                  R                  U5      5      $ )r   )state)r  hmacKeyMetadatar  )r   HmacKeyMetadatavalueetag$StorageProjectsHmacKeysUpdateRequestr    r+   r3  r.  r4  r   r  r   r  r  )ra   r  r  r  updated_metadatar   s         r>   patch_hmac_keyJsonClient.patch_hmac_key  s     }}445;;4G"mm@@##((00::<( A G "44%%,,W57 7r@   c                    U(       d  [         R                  " S5      e[        U5      U R                  :  a9  [         R                  " SR	                  [        U5      U R                  5      5      e/ nU H  nU R
                  R                  R                  UR                  R                  S9nUR                  R                  b%  [        UR                  R                  5      n	Xl
        UR                  U5        M     [        R                  " UR                  5      n
[        US   SS5      (       a=  [        R                   " US   R"                  U
U[        R$                  R&                  S9nOU
n[        R(                  " UUUU[        R$                  R&                  S9  U R
                  R                  XkS	9nU R
                  R+                  UUR                  R,                  UR                  R                  UR.                  UR0                  S
9nUR2                  (       aj  UR2                  R4                  nU(       aM  U[6        R8                  :w  a9  UR:                  [<        R>                  R@                  :X  a  URB                  Ul"        URF                  b9  [        U R
                  R*                  RH                  URF                  5      Ul%        [        UR2                  SS5      nU RM                  U5         [        RN                  " U RP                  RR                  RU                  U5      5      sSSS5        $ ! , (       d  f       g= f),See CloudApi class for function doc strings.z/Compose requires at least one component object.z4Compose was called with {} objects. The limit is {}.r+  Nr   rF   )method_type)attributes_resourceposix_to_setr  )sourceObjectsdestination)composeRequestdestinationBucketdestinationObjectifGenerationMatchr>  r   )+r}   r   r{   MAX_OBJECTS_PER_COMPOSE_CALLr2   r   ComposeRequestSourceObjectsValueListEntryr   resource_namer9   intr  r   r}  r   copy_object_metadatarF   
MethodTypeOBJECT_COMPOSE*update_object_metadata_from_request_configStorageObjectsComposeRequestr   precondition_generation_matchr@  r   r   r   r   r   r   r   CMEKr   
kmsKeyNamer  'DestinationPredefinedAclValueValuesEnumdestinationPredefinedAclr   !get_object_resource_from_metadatar   r   Compose)ra   source_resourcesdestination_resourcer   original_source_resourcer  source_messagessourcesource_messager9   base_destination_metadatafinal_destination_metadatacompose_request_payloadcompose_requestr   s                  r>   compose_objectsJsonClient.compose_objects  s    $$
;= = t@@@$$
@
G
G"#T%F%FHI I O"}}33OO!!// P 1n				&	&	2++667
$.!^, # !. L L((!*"J55#0#E#E
1

&
&(A
m&>&>&M&M$O  $= <<"4!!,,;; #mm::% ; O mm@@..::FF.::HH(FF,NN A PO ##%33BBn

5;;
;


!8!8!=!=
=%3%7%7"++718
--
4
422

.
.20o.
 ^99;K!#N		)	).	9<<
++


%
%o
68 
:	9	9s   >9M
Mc                 N   [        USS5      nU(       d   [        R                  " UR                  5      nUR                  (       a!  [        R
                  " UR                  UUUS9n[        R                  " UUU[        R                  R                  S9  UR                  (       a5  [        U R                  R                  R                  UR                  5      nOSnUR                  c  Sn	O[        UR                  5      n	[        R                   " UR                  [        R"                  R$                  UR                  S9n
[        R&                  " UUUUS9n[        R(                  " X5      nU(       a  [*        R,                  " S5        O[*        R,                  " S5        [.        R0                  " [2        R4                  R6                  R8                  R;                  5       5      nU R=                  U5          U R                  R                  UR                  R>                  UR                  R@                  UR                  R>                  UR                  R@                  UU	[B        RD                  " U5      URF                  UUUS	9n[        URH                  S
S5      nU(       aM  U[J        RL                  :w  a9  URN                  [P        RR                  RT                  :X  a  URV                  Ul,        U RZ                  R\                  R_                  U5      nUR`                  nU(       a  U" U5        URb                  (       a  OU(       d  URd                  nURf                  [.        R0                  " [2        R4                  R6                  Rh                  R;                  5       5      :  a!  [        Rj                  " XURd                  5        GM  SSS5        [        Rl                  " U
5        [        Rn                  " WRp                  5      $ ! , (       d  f       ND= f)r   rF   N)should_deep_copyr  r  )
source_url)r   z#Found rewrite token. Resuming copy.z3No rewrite token found. Starting copy from scratch.)sourceBucketsourceObjectr  r  objectsourceGenerationr  r>  r  rewriteTokenmaxBytesRewrittenPerCallr   )9r   r   r}  r   rF   r  r  r  OBJECT_REWRITEr  r   StorageObjectsRewriteRequestr  r9   r  r   get_tracker_file_pathTrackerFileTypeREWRITE,hash_gcs_rewrite_parameters_for_tracker_file#get_rewrite_token_from_tracker_filer   r|   r#   rZ   r    r+   r-   copy_chunk_sizer.   r   r   r  r   get_generation_match_valuer@  r   r   r   r   r   r   r  r   destinationKmsKeyNamer   r   RewritetotalBytesRewrittendoner  rH   resumable_thresholdwrite_rewrite_tracker_filedelete_tracker_filer  resource)ra   r   r  r   r  rk   should_deep_copy_metadatadestination_metadatar  source_generationtracker_file_pathrewrite_parameters_hashresume_rewrite_tokenmax_bytes_per_callr   r   rewrite_responserj   s                     r>   copy_objectJsonClient.copy_objectb  se    ##7TJ*II

*
*,*??

"
"

4	6
 <<!!,,;;	 ++
--
4
422

.
.0n
 n!!)o889)??(())11"..0
 	FF  )		
  	==	8  	ii56	iiEF'44!!115579		:	:>	J--<<(44@@(44BB2>>JJ2>>LL'.'BB "0..%3-%7 = 9 !((*:DB7===?#:#:#?#??
 +9*<*<'
';;..66w?*>>
O
,  
#!1!>!>
!!^%@%@'';;??A&C C88! --/O  
KX ))*;<::!!# #[ 
K	Js   =GP
P$c                 "   UR                   b  [        UR                   5      nOSnU R                  R                  UR                  UR
                  UUR                  UR                  S9nU R                  R                  R                  U5        g)r   N)r4   r  r9   r  r>  )r9   r  r   StorageObjectsDeleteRequestr   r  r  r@  r   r   rA  )ra   
object_urlr   r9   r   s        r>   delete_objectJsonClient.delete_object  s     (z,,-jjmm77%%''(FF,NN 8 PG 	KKw'r@   r   c
           	      @   [         R                  " X5      (       a  g[        X5      n
[        R                  R                  UU
[        R                  R                  R                  R                  5       U R                  S9nU	c  UR                  S-
  nOU	nU R                  R                  UX-
  S-   UUUUS9  U R                  c$  [         R"                  " SU R                  S9U l        U R                  Ul        U R                  R&                  nU(       a  SUS'   [)        UR*                  SS5      nUR-                  [/        U5      5        U[0        R2                  R4                  :X  a  [6        R8                  " UUU	US	9nU$ [6        R:                  " UUUU	US	9nU$ )
r   N)num_retriesr      )rg   rH   rh   ri   rj   rk   )response_encodingresponse_handlergzipzaccept-encodingr   )
start_byteend_byter   )r   (return_and_report_if_nothing_to_downloadrM   apitools_transferDownloadFromDatar    r+   r-   max_retriesGetIntr   rH   r   rl   r   r"   GetApitoolsTransport
bytes_httpr   r   r   rz   r   r	   rv   rw   r   launchlaunch_retriable)ra   cloud_resourcedownload_streamr   rh   do_not_decompressri   rk   r  r  serialization_dataapitools_downloadcalculated_end_byter   r   server_reported_encodings                   r>   download_objectJsonClient.download_object  s    ==  8$)22;;%%--99@@B{{	 <  *//!3$!!99 -1+"+ :  !!)#-#B#B 88$:d  $(#=#= <<.4*+^99;K!#N5nEFI66???!)
/	"1 $# "*!:!:

/"1 $#r@   c                     U(       a  [        U5      nU R                  R                  SS9nU R                  R                  R                  U R                  R                  XUS9US9$ )r   rK  rL  )r4   r  r9   rO  )r  r   rQ  r   r   rR  !StorageObjectsGetIamPolicyRequest)ra   r   object_namer9   rP  s        r>   get_object_iam_policy JsonClient.get_object_iam_policy+  sn     z?jMM99 :  M;;++77z 	8 	K# , % %r@   c                 &   U(       a  [        U5      nU R                  UU R                  R                  5      nSnU[        R
                  R                  :X  a  U R                  R                  SS9n[        [        USS5      SS5      n	U R                  U	5         U R                  R                  R                  U R                  R                  UUUUU(       a  SOSS9US9n
SSS5        [        R                  " W
5      $ ! , (       d  f       N$= f)	r   Nzbucket,name,size,generationrL  r   r   T)r4   r  r9   r/  rE  rO  )r  r   r   StorageObjectsGetRequestr	   r   rZ  rQ  r   r   r   r   r.   r   r  )ra   r   r/  r   r9   r   rG  r/  rP  r   object_metadatas              r>   get_object_metadataJsonClient.get_object_metadata8  s     z?j%%l&*mm&L&LNJMy,,222mm;;. < m 68H$PN		)	).	9++//
--
0
0  ##".$D 1  & 0 
o 
: ::?KK 
:	9s   A	D
DTc
              #     #    U R                  UU R                  R                  5      n
SnU[        R                  R
                  :X  a  U R                  R                  SS9nOU[        R                  R                  :X  ar  U R                  R                  SR                  [        R                  [        R                  [        R                  [        R                  [        R                  5      S9nSnU[        R                  R                   L a  SOSnU[        R                  R"                  L a  SOSn U R                  R                  UUUUU
U[        R$                  UUU	S9
n U R&                  R(                  R+                  XS9nUR<                  nUR>                  (       dE  UR@                  (       d4  U(       a-  U(       a&  [B        RD                  " SR                  U5      5        gUR>                   H"  nUUl#        [H        RJ                  " U5      v   M$     UR@                   HF  n[L        RN                  " [P        RR                  " [P        RT                  RV                  UUS	9US
9v   MH     U(       d  gGMI  ! [,        R.                   aD  n[0        R2                  " [4        R6                  " U[8        R:                  5      5         SnAGNHSnAff = f7f)r   Nz=prefixes,items/name,items/size,items/generation,nextPageTokenrL  zprefixes,items/name,items/etag,items/size,items/generation,items/storageClass,items/timeCreated,items/metadata/{},items/metadata/{},items/metadata/{},items/metadata/{},items/metadata/{},items/crc32c,items/md5Hash,nextPageToken,items/kmsKeyNameT)
r4   rX  	delimiterversionsr/  r  
maxResultsincludeFoldersAsPrefixesrE  filterrO  a  Received empty list response. However, a next page token is available. Rerun with `--exhaustive --next-page-token={}` to pick up where you left off and exhaustively search all objects. Making numerous LIST API calls can be expensive, and additional objects are not guaranteed exist.)schemer   r  )rX  ),r   r   StorageObjectsListRequestr	   r   rZ  rQ  RSYNCr2   r   ATIME_METADATA_KEYGID_METADATA_KEYMODE_METADATA_KEYMTIME_METADATA_KEYUID_METADATA_KEYObjectStateLIVE_AND_NONCURRENTSOFT_DELETEDr  r   r   Listr  r  r  r  r}   r  r   r  nextPageTokenitemsprefixesr   r   r4   r   r  r   PrefixResourcer   CloudUrlProviderPrefixGCS)ra   r   rX  r8  r   halt_on_empty_responseinclude_folders_as_prefixesnext_page_tokenobject_statelist_filterr/  rP  list_resultlive_and_noncurrentrG  r  r   r4  prefix_strings                      r>   list_objectsJsonClient.list_objects_  s     %%l&*mm&M&MOJMy,,222mm;;P < m 
..44	4mm;;!
 F++))**++)) < m  K 900DDD 	  	 5 5 B BB  @@&#66#>" A Kkk)).. / 
 $11o  K$8$8$@
 f_%	
 	 )../!,== 	 / '//- //  "1155'+- !" 	" 0 s & !** K((J,H,HI	K 	KKs1   E&K)#J C5KK9KKKKc                 H   U(       a  [        U5      nSnUR                  (       a4  [        U R                  R                  R
                  UR                  5      nU R                  XPR                  R                  5      n	UR                  =(       d     [        R                  " UR                  5      n
[        R                  " U
UU[        R                  R                  S9  U R                  R	                  UUU
UUR                  UR                  UR                   UU	S9	nU R"                  R%                  [        R&                  " U5      5         U R"                  R(                  R+                  U5      nSSS5        [        R,                  " W5      $ ! , (       d  f       N$= f)r   Nr  )	r4   r  objectResourcer9   r  r>  overrideUnlockedRetentionrz  r/  )r  r  r   r   StorageObjectsPatchRequestr  r   rF   r   r}  r   r  r  OBJECT_PATCHr  r@  override_unlocked_retentionr   r  get_cleared_object_fieldsr   r  r  )ra   r   r/  r:   r   r   r9   r  r  r/  r4  r   r  s                r>   patch_object_metadata JsonClient.patch_object_metadata  sb    z?jN++
--
2
2
O
O

.
.n
 %%mm>>J &.. 44''	
  <<!!,,99	 mm66&(FF,NN"0"L"L$ 7 
G 
	"	"//?
 ,,227;
 ::;KLL	
 
s   &F
F!c           	          U(       a  [        U5      nU R                  R                  R                  U R                  R                  UUUUS95      $ )r   )r4   r  r9   r  )r  r   r   r  r   !StorageObjectsSetIamPolicyRequest)ra   r   r/  r  r9   s        r>   set_object_iam_policy JsonClient.set_object_iam_policy  sP     z?j;;++77!	 	8 	 r@   c	                    U R                   c  [        R                  " SS9U l         U R                  U5      n	[        R
                  " UR                  U	5      n
U
(       a%  [        R                  " SR                  U	5      5        U[        R                  R                  :X  a&  [        R                  " U U R                   UUU
UUUS9nOU[        R                  R                  :X  a(  [        R                   " U U R                   UUU
UUUUUS9
nOsU[        R                  R"                  :X  a&  [        R$                  " U U R                   UUU
UUUS9nO/[&        R(                  " SR                  UR*                  5      5      e[-        UR.                  SS5      n U R1                  U5         UR3                  5       nSSS5        [J        RL                  " W5      $ ! , (       d  f       N$= f! [4        R6                  [4        R8                  4 ad  n[:        R<                  " S	R                  [?        U5      [@        RB                  RD                  RF                  RI                  5       5      5      eSnAff = f)
r  NzObject data is not displayed to keep the log output clean. Set log_http_show_request_body property to True to print the body of this request.)redact_request_body_reasonz+Using compressed transport encoding for {}.)r  r   )r  r'  r   tracker_callbackzInvalid upload strategy: {}.r   z{}
 This likely occurred because the file being uploaded changed size between resumable upload attempts. If this error persists, try deleting the tracker files present in {})'r   r"   r   r   r   should_gzip_in_flightgzip_settingsr   rx   r2   r	   UploadStrategySIMPLEr   SimpleUpload	RESUMABLEResumableUpload	STREAMINGStreamingUploadro   rp   r  r   r   r   runr  StreamExhaustedTransferErrorr}   ResumableUploadAbortErrorstrr    r+   r-   tracker_files_directoryr.   r   r  )ra   r   r  r   r  r   r'  ri  upload_strategysource_pathrj  uploaderr   rF   errors                  r>   upload_objectJsonClient.upload_object  s?    '!+!@!@'")d ''8K%;;$$k3 	hh
7
>
>{
KM)22999$$


"
"



#)	h 
I44>>	>''


"
"



#/)+h 
I44>>	>''


"
"



#)	h   !?!F!F


"! " " ^99;K!#NH++N;<<> < ::8DD <; 	++)) 	H 2255;V%j''??CCE6GH H		Hs7   G+ +G<G+ 
G($G+ (G+ +$I3AI..I3c                     U R                   R                  XS9nU R                  R                  R	                  U5      n[
        R                  " U5      $ )r  r4   r7   )r   ManagedFolderr   managedFoldersr   r   )get_managed_folder_resource_from_metadata)ra   r   managed_folder_namefolder_messager  s        r>   create_managed_folder JsonClient.create_managed_folderf  sM     ]]00 1 N {{))00@HBB8LLr@   c                     U R                   R                  XS9nU R                  R                  R	                  U5        g)r  r4   managedFolderN)r   "StorageManagedFoldersDeleteRequestr   r  rA  )ra   r   r  delete_requests       r>   delete_managed_folder JsonClient.delete_managed_foldero  s;     ]]EE F N 	KK%%n5r@   c                     U R                   R                  R                  U R                  R	                  XS95      n[
        R                  " U5      $ )r  r  )r   r  r.   r   StorageManagedFoldersGetRequestr   r  )ra   r   r  r  s       r>   get_managed_folderJsonClient.get_managed_folderw  sK     {{))--55 	6 	
H
 BB8LLr@   c                     U R                   R                  SS9nU R                  R                  R	                  U R                   R                  XS9US9$ )r  rK  rL  r  rO  )r   rQ  r   r  rR  (StorageManagedFoldersGetIamPolicyRequest)ra   r   r  rP  s       r>   get_managed_folder_iam_policy(JsonClient.get_managed_folder_iam_policy  sc     MM99 : M ;;%%22>> 	? 	
 $	 3  r@   c           	   #     #     [         R                  " U R                  R                  U R                  R                  UUS9SSSS9 H  n[        R                  " U5      v   M     g! [        R                   aP  n[        R                  " [        R                  " U[        R                  [        R                   S95         SnAgSnAff = f7f)r  )r4   rX    r  rJ  r  r  fieldstatus_code_getterN)r   r  r   r  r    StorageManagedFoldersListRequestr   r  r  r  r  r  r}   r  r   r  get_status_code)ra   r   rX  folderr   s        r>   list_managed_foldersJsonClient.list_managed_folders  s     ,,
++
$
$
--
8
8  9  )	& EEfMM	 (( 

&
&**!+!;!; s0   CA#A( 'C(C<ACCCCc                 |    U R                   R                  R                  U R                  R	                  XUS95      $ )r  )r4   r  r  )r   r  r  r   (StorageManagedFoldersSetIamPolicyRequest)ra   r   r  r  s       r>   set_managed_folder_iam_policy(JsonClient.set_managed_folder_iam_policy  s=    
 ;;%%22>>& 	? 	
 r@   c                     U R                   R                  XS9nU R                   R                  XUS9nU R                  R                  R                  U5      n[        R                  " U5      $ )r  r  )r4   r  	recursive)r   FolderStorageFoldersInsertRequestr   foldersr   r   !get_folder_resource_from_metadata)ra   r   folder_nameis_recursiver  insert_folder_request_messager  s          r>   create_folderJsonClient.create_folder  si     ]]!!!GF$(MM$M$M\ %N %! {{""))*GHH::8DDr@   c                     U R                   R                  XS9nU R                  R                  R	                  U5        g)r  r4   r  N)r   StorageFoldersDeleteRequestr   r  rA  )ra   r   r  delete_folder_requests       r>   delete_folderJsonClient.delete_folder  s=     !MMEE F  	KK45r@   c                     U R                   R                  R                  U R                  R	                  XS95      n[
        R                  " U5      $ )r  r  )r   r  r.   r   StorageFoldersGetRequestr   r  )ra   r   r  r  s       r>   
get_folderJsonClient.get_folder  sK     {{""&&.. 	/ 	
H
 ::8DDr@   c           	   #     #     [         R                  " U R                  R                  U R                  R                  UUUS9SSSS9 H  n[        R                  " U5      v   M     g! [        R                   aP  n[        R                  " [        R                  " U[        R                  [        R                   S95         SnAgSnAff = f7f)r  )r4   r8  rX  r  r  rJ  r  r  N)r   r  r   r  r   StorageFoldersListRequestr   r  r  r  r  r  r}   r  r   r  r  )ra   r   r8  rX  r  r   s         r>   list_foldersJsonClient.list_folders  s     ,,
++


--
1
1 ! 2 
 )
& ==fEE
 (( 

&
&**!+!;!; s0   CA$A) (C)C=ACCCCc                     U R                   R                  UUUS9nU R                  R                  R	                  U5      $ )r  )r4   sourceFolderdestinationFolder)r   StorageFoldersRenameRequestr   r  Rename)ra   r   source_folder_namedestination_folder_namerename_folder_requests        r>   rename_folderJsonClient.rename_folder  sF    
 !MMEE'1 F 
 ;;%%&;<<r@   c                 B   U(       a  UnOPU(       a  [         R                  " U5      nO2[        R                  R                  R
                  R                  5       nU R                  R                  R                  U R                  R                  US95      R                  $ )#See CloudApi class for doc strings.)r  )six	text_typer    r+   r3  r.  r4  r   projects_serviceAccountr.   r   'StorageProjectsServiceAccountGetRequestemail_address)ra   
project_idproject_numberproject_identifiers       r>   get_service_agentJsonClient.get_service_agent  s|     %	==8%,,1199CCE;;..22==( 	> 	*++8=9r@   c                 
   UR                  5       (       d  [        R                  " S5      eU R                  R	                  U[
        U   S9nU(       a  / nUR                  5        HA  u  pUR                  U R                  R                  R                  R                  XS95        MC     U R                  R                  R                  US9Ul
        U(       a!  U Vs/ s H  oR                  PM     snUl        U(       a  XWl        U R                  R                  R!                  U R                  R#                  UR$                  U[&        R(                  R*                  R,                  R/                  5       S95      $ s  snf )r  zDCreate notification configuration endpoint accepts only bucket URLs.)topicpayload_format)r   r  )additionalPropertiesr4   notificationuserProject)	is_bucketro   InvalidUrlErrorr   Notification0_NOTIFICATION_PAYLOAD_FORMAT_KEY_TO_API_CONSTANTrJ  r  CustomAttributesValueAdditionalPropertycustom_attributesr  event_typesobject_name_prefixr   notificationsr   !StorageNotificationsInsertRequestr   r    r+   r3  r.  r4  )ra   rE   pubsub_topicr  r  r  r  notification_configurationadditional_propertiesr   r  
event_types               r>   !create_notification_configuration,JsonClient.create_notification_configuration  sc    ==??**
P  "&!;!;G "< "  )//1*#$$MM&&<<OO P &	( 2
 --
$
$
:
:#8 ; : !2 -80-8z

[0 , 6H3;;$$++77??3"))..66@@B 	8 	DE E0s   F c                 J   UR                  5       (       d  [        R                  " S5      eU R                  R                  R                  U R                  R                  UR                  U[        R                  R                  R                  R                  5       S95        g)r  zDDelete notification configuration endpoint accepts only bucket URLs.r  N)r  ro   r  r   r  rA  r   !StorageNotificationsDeleteRequestr   r    r+   r3  r.  r4  ra   rE   notification_ids      r>   !delete_notification_configuration,JsonClient.delete_notification_configuration%  s     ==??**
P  	KK$$77??("))..66@@B 	8 	DEr@   c                 H   UR                  5       (       d  [        R                  " S5      eU R                  R                  R                  U R                  R                  UR                  U[        R                  R                  R                  R                  5       S95      $ )r  zAGet notification configuration endpoint accepts only bucket URLs.r  )r  ro   r  r   r  r.   r   StorageNotificationsGetRequestr   r    r+   r3  r.  r4  r  s      r>   get_notification_configuration)JsonClient.get_notification_configuration2  s     ==??**
M  ;;$$((44??("))..66@@B 	5 	DE Er@   c              #   ~  #    UR                  5       (       d  [        R                  " S5      eU R                  R                  R                  U R                  R                  UR                  [        R                  R                  R                  R                  5       S95      nUR                   H  nUv   M	     g7f)r  zCList notification configurations endpoint accepts only bucket URLs.)r4   r  N)r  ro   r  r   r  rH  r   StorageNotificationsListRequestr   r    r+   r3  r.  r4  rJ  )ra   rE   r  r  s       r>    list_notification_configurations+JsonClient.list_notification_configurations?  s      ==??**
O  {{((--55??"))..66@@B 	6 	DEH '/nn"&& '5s   B;B=c                     U R                   R                  Ub  [        U5      S-   OSS9nU R                   R                  UUUS9nU R                  R
                  R                  U5      $ )r_  Ns)r   )%advanceRelocateBucketOperationRequestr4   r   )r   %AdvanceRelocateBucketOperationRequestrw  4StorageBucketsOperationsAdvanceRelocateBucketRequestr   
operationsAdvanceRelocateBucket)ra   r   r   r   )advance_relocate_bucket_operation_requestr   s         r>   advance_relocate_bucket"JsonClient.advance_relocate_bucketN  ss     	;;"%/C3t 	< 	
 .
 mmPP.W  Q G
 ;;!!77@@r@   c                 ~    U R                   R                  R                  U R                  R	                  UUS95        g)r_  r   N)r   r   Cancelr   %StorageBucketsOperationsCancelRequestra   r   r   s      r>   cancel_operationJsonClient.cancel_operation]  s9     	KK!!;;$ 	< 	
r@   c                 |    U R                   R                  R                  U R                  R	                  UUS95      $ )r_  r   )r   r   r.   r   r   r  s      r>   get_operationJsonClient.get_operationg  s>     ;;!!%%88$ 	9 	
 r@   c              #   f  #    U R                   R                  UUS9n[        R                  " U R                  R
                  USSS9n U H  nUv   M	     g! [        R                   aC  n[        R                  " [        R                  " U[        R                  5      5         SnAgSnAff = f7f)r_  )r4   r<  r  r   )r  r  N)r   #StorageBucketsOperationsListRequestr   r  r   r   r  r  r  r  r}   r  r   r  )ra   r   server_side_filterr   operation_iteratorr   r   s          r>   list_operationsJsonClient.list_operationsq  s     mm??! @ G $11'	)) *(( 

&
&q**F*F
G s0   AB1	A B1B.+9B)$B1)B..B1c                 z   UR                   (       a  UR                   R                  nOSnU R                  R                  R	                  U R
                  R                  UR                  U[        UR                  5      UR                  UR                  UR                  S95      n[        R                  " U5      $ )r_  N)r4   copySourceAclr9   r  r>  r  )r   preserve_aclr   r   Restorer   StorageObjectsRestoreRequestr   r  r9   r  r@  r  r   r  )ra   rE   r   r  r4  s        r>   restore_objectJsonClient.restore_object  s     ###11>>llkk))1122??&3>>*,JJ@@$$ 	3 		
O ::?KKr@   c                 Z   UR                  5       (       d  [        R                  " S5      eUR                  (       d  [        R                  " S5      eU R                  R
                  R                  U R                  R                  UR                  [        UR                  5      S95      $ )r_  z1Restore bucket endpoint accepts only bucket URLs.z.Restore bucket endpoint requires a generation.)r4   r9   )r  ro   r  r9   r   r5  r  r   StorageBucketsRestoreRequestr   r  )ra   rE   s     r>   restore_bucketJsonClient.restore_bucket  s     ==??**
=  >>**
:  ;;&&22??3>>* 	3 	
 r@   c	                    UR                   (       a  UR                   R                  n	OSn	U R                  S[        R                  " 5       R
                  05         U R                  R                  R                  U R                  R                  UR                  U R                  R                  UU	UUUUUS9S95      n
SSS5        U
$ ! , (       d  f       W
$ = f)r_  Nr   )allowOverwriter  createdAfterTimecreatedBeforeTime
matchGlobssoftDeletedAfterTimesoftDeletedBeforeTime)r4   bulkRestoreObjectsRequest)r   r  r   r   r   r   r   r   BulkRestorer    StorageObjectsBulkRestoreRequestr   BulkRestoreObjectsRequest)ra   
bucket_urlobject_globsr   allow_overwritecreated_after_timecreated_before_timedeleted_after_timedeleted_before_timer  r   s              r>   bulk_restore_objectsJsonClient.bulk_restore_objects  s     ###11>>ll		/	/	')9)9:
 ++%%11
--
8
8++(,(O(O!0 ,#5$7)'9(; )P ) 9 i
" #
 
" s   A%C


Cc                 ~    U R                   R                  US9nU R                  R                  R	                  U5      $ )r  )r4   )r   %StorageBucketsGetStorageLayoutRequestr   r5  GetStorageLayout)ra   r   storage_layout_requests      r>   get_storage_layoutJsonClient.get_storage_layout  s<     	;;;;O  ;;//0FGGr@   c                 p    [        U R                  R                  S 5      n[        R                  " X!5      $ )r  c                     U R                   $ r   r+  )refs    r>   <lambda>/JsonClient.wait_for_operation.<locals>.<lambda>  s    SXXr@   )r   r   r   r   WaitFor)ra   r   pollers      r>   wait_for_operationJsonClient.wait_for_operation  s/     #!5F >>&00r@   )r   r   r   r   r   )NF)NN)NNFr   )F)FNNNN)`r   r   r   r   r   r	   
CapabilityCOMPOSE_OBJECTS"DAISY_CHAIN_SEEKABLE_UPLOAD_STREAM
ENCRYPTIONMANAGED_FOLDERSFOLDERSSTORAGE_LAYOUTRESUMABLE_UPLOADSLICED_DOWNLOADcapabilitiesr  rT   
contextlibcontextmanagerr   r   r   r   r   r   $catch_http_error_raise_gcs_api_errorr   r  r  r  r  r#  r(  r   r  r:  rB  rH  rU  r\  rm  rt  r  r  r  r  r  rZ  r  r  r  r  r  rv   ro  r+  r0  r5  rE  LIVErX  ra  re  rl  rm  r}  r  r  r  r  r  r  r  r  r  r  r  r  NotificationPayloadFormatJSONr  r  r  r  r  r	  r  r  r  r  r1  r7  r@  r   r   r   s   @r>   r   r     s   , **==%%**""))++**	, "$$ 8 8PF !4 224 5 224
0 5
0 224 5 224 56 224 5( 224. 5. 224/ 5/ 224 "+!6!6!=!=! 5!4 224( 5( 224 ((//E 5E, 224 5 ((//	$L 224
 +/: 5:, 224 5 224
 ((//	?7 5?7B 2240 50 2247 57 2242 52 224? 5? 26"+"7"7"="=IB 224
7 5
7 224  $G8 5G8R 224  %m# 5m#^ 224( 5($ 224
 !%(-(1(B(B(L(L(,!"#C$ 5C$J 224
% 5
% 224
 ((//$L 5$LR ((//!"&((--gR 224 ((//6M 56Mp 224
 (,	 5 224 ..55RE 5REh 224M 5M 2246 56 224M 5M 224
 5
. 224 5 224E 5E 2246 56 224E 5E0 224	= 5	= 224
9 5
9 224
 88==%E 5%EN 224
E 5
E 224
E 5
E 224' 5' 224A 5A 224 5 224 5( 224L 5L* 224 5& 224 " 5"H 224H 5H 2241 51r@   r   )Kr   
__future__r   r   r   rL  rt   rI   r   apitools.base.pyr   r  r   r   r  googlecloudsdk.api_lib.storager	   r
   r}   r   r   'googlecloudsdk.api_lib.storage.gcs_jsonr   r   r   r   r   googlecloudsdk.api_lib.utilr   r0   r   "googlecloudsdk.command_lib.storager   ro   r   r   r   r   r   r   ,googlecloudsdk.command_lib.storage.resourcesr   r   +googlecloudsdk.command_lib.storage.tasks.cpr   r   googlecloudsdk.corer  r   r    r!   googlecloudsdk.core.credentialsr"   googlecloudsdk.core.utilr#   r  	six.movesr$   patchKBr^   rP  rQ  r&   r  r?   rM   ResponseHandlerrO   r   r   CloudOperationPollerNoResourcesr   CloudApir   r   r@   r>   <module>rc     s"   '  '     > ' : 4 A 7 7 < > A K : 9 . > G 8 > 9 : @ H O K A E = # * ( 6 3 
     
 
&)Bh # '',,m'',,f4 0*(.e4H$<$< e4P	/FBB /BG1## G1r@   