
                            S r SSKJr  SSKJr  SSKJr  SSKrSSKJr   " S S\R                  5      r	 " S	 S
\R                  5      r
 " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r " S S\R                  5      r\R"                  R$                  rSr " S S\5      rg)z;API interface for interacting with cloud storage providers.    )absolute_import)division)unicode_literalsN)storage_urlc                   @    \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrg)
Capability   z:Used to track API capabilities relevant to logic in tasks.COMPOSE_OBJECTSCLIENT_SIDE_HASH_VALIDATION
ENCRYPTIONMANAGED_FOLDERSFOLDERSSTORAGE_LAYOUTRESUMABLE_UPLOADSLICED_DOWNLOADAPPENDABLE_UPLOAD"DAISY_CHAIN_SEEKABLE_UPLOAD_STREAM N)__name__
__module____qualname____firstlineno____doc__r
   r   r   r   r   r   r   r   r   r   __static_attributes__r       /lib/googlecloudsdk/api_lib/storage/cloud_api.pyr   r      s>    B%/ =*%/'#.'%/) (L$r   r   c                   $    \ rS rSrSrSrSrSrSrg)DownloadStrategy4   z,Enum class for specifying download strategy.oneshotretriable_in_flight	resumabler   N)	r   r   r   r   r   ONE_SHOTRETRIABLE_IN_FLIGHT	RESUMABLEr   r   r   r   r   r   4   s    4(- )r   r   c                   (    \ rS rSrSrSrSrSrSrSr	g)	UploadStrategy>   z*Enum class for specifying upload strategy.simpler"   	streaming
appendabler   N)
r   r   r   r   r   SIMPLEr%   	STREAMING
APPENDABLEr   r   r   r   r'   r'   >   s    2&))*r   r'   c                   (    \ rS rSrSrSrSrSrSrSr	g)	FieldsScopeF   zDValues used to determine fields and projection values for API calls.            r   N)
r   r   r   r   r   FULLNO_ACLRSYNCSHORTr   r   r   r   r0   r0   F   s    L	
$&
%
%r   r0   c                       \ rS rSrSrSrSrg)HmacKeyStateO   ACTIVEINACTIVEr   N)r   r   r   r   r=   r>   r   r   r   r   r;   r;   O   s    &(r   r;   c                   (    \ rS rSrSrSrSrSrSrSr	g)	NotificationEventTypeT   zDUsed to filter what events a notification configuration notifies on.OBJECT_ARCHIVEOBJECT_DELETEOBJECT_FINALIZEOBJECT_METADATA_UPDATEr   N)
r   r   r   r   r   rB   rC   rD   rE   r   r   r   r   r@   r@   T   s    L#.!-%/3r   r@   c                        \ rS rSrSrSrSrSrg)NotificationPayloadFormat\   z)Used to format the body of notifications.jsonnoner   N)r   r   r   r   r   JSONNONEr   r   r   r   rG   rG   \   s    1	$	$r   rG   c                   $    \ rS rSrSrSrSrSrSrg)ObjectStateb   zDFor whether to operate on live, noncurrent, or soft-deleted objects.livezlive-and-noncurrentzsoft-deletedr   N)	r   r   r   r   r   LIVELIVE_AND_NONCURRENTSOFT_DELETEDr   r   r   r   rN   rN   b   s    L	$-,r   rN   i  c                      \ rS rSrSr\" 5       rSrSr SBS jr	S r
S rS	 rS
 rS r SBS jrSCS jrS r SDS jrS rSES jrS rS rSCS jrS rS rS rS r  SES jrS r  SBS jr   SDS jrS r SS\!RD                  SSS4S  jr#SCS! jr$    SFS" jr%SSSS#SS\&RN                  S4S$ jr(   SGS% jr) SCS& jr*SSSS\+RX                  4S' jr-S( r.S) r/S* r0S+ r1SCS, jr2S- r3SHS. jr4S/ r5S0 r6SCS1 jr7S2 r8SBS3 jr9SSS\:Rv                  4S4 jr<S5 r=S6 r>S7 r?SCS8 jr@S9 rAS: rBSCS; jrCS< rDS= rE     SIS> jrFS? rGS@ rHSArIg)JCloudApin   a  Abstract base class for interacting with cloud storage providers.

Implementations of the Cloud API are not guaranteed to be thread-safe.
Behavior when calling a Cloud API instance simultaneously across
threads is undefined and doing so will likely cause errors. Therefore,
a separate instance of the Cloud API should be instantiated per-thread.

Attributes:
  capabilities (set[Capability]): If a Capability is present in this set, this
    API can be used to execute related logic in tasks.
r2   i   Nc                     [        S5      e)a  Creates Anywhere Cache for given bucket.

Args:
  bucket_name (str): The name of the bucket where the Anywhere Cache should
    be created.
  zone (str): Name of the zonal locations where the Anywhere Cache should be
    created.
  admission_policy (str|None): The cache admission policy decides for each
    cache miss, that is whether to insert the missed block or not.
  ttl (str|None): Cache entry time-to-live in seconds

Returns:
  GoogleLongrunningOperation Apitools object for creating caches.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)create_anywhere_cache must be overridden.NotImplementedError)selfbucket_namezoneadmission_policyttls        r   create_anywhere_cacheCloudApi.create_anywhere_cache   s    , I
JJr   c                     [        S5      e)az  Gets Anywhere Cache Instance for a zone in bucket.

Args:
  bucket_name (str): The name of the bucket.
  anywhere_cache_id (str): Unique identifier for a cache instance in bucket.

Returns:
  AnywhereCache: the Anywhere Cache Instance

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z&get_anywhere_cache must be overridden.rX   rZ   r[   anywhere_cache_ids      r   get_anywhere_cacheCloudApi.get_anywhere_cache        F
GGr   c                     [        S5      e)aE  Pauses Anywhere Cache Instance for a zone in bucket.

Args:
  bucket_name (str): The name of the bucket.
  anywhere_cache_id (str): Unique identifier for a cache instance in bucket.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z(pause_anywhere_cache must be overridden.rX   rb   s      r   pause_anywhere_cacheCloudApi.pause_anywhere_cache   s     H
IIr   c                     [        S5      e)av  Resumes Anywhere Cache in particular zone of a bucket.

Args:
  bucket_name (str): The name of the bucket where the Anywhere Cache should
    be resumed.
  anywhere_cache_id (str): Unique identifier for a cache instance in bucket.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)resume_anywhere_cache must be overridden.rX   rb   s      r   resume_anywhere_cacheCloudApi.resume_anywhere_cache   s     I
JJr   c                     [        S5      e)ax  Disables Anywhere Cache in particular zone of a bucket.

Args:
  bucket_name (str): The name of the bucket where the Anywhere Cache should
    be disabled.
  anywhere_cache_id (str): Unique identifier for a cache instance in bucket.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z*disable_anywhere_cache must be overridden.rX   rb   s      r   disable_anywhere_cacheCloudApi.disable_anywhere_cache   s     J
KKr   c                     [        S5      e)aG  Lists all Anywhere Cache instances of the bucket.

Args:
  bucket_name (str): The name of the bucket.

Yields:
  Iterator over gcs_resource_reference.GcsAnywhereCacheResource objects.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z'list_anywhere_cache must be overridden.rX   rZ   r[   s     r   list_anywhere_cachesCloudApi.list_anywhere_caches   s     G
HHr   c                     [        S5      e)a|  Updates Anywhere Cache instance of a bucket.

Args:
  bucket_name (str): The name of the bucket where the Anywhere Cache should
    be updated.
  anywhere_cache_id (str): Unique identifier for a cache instance in bucket.
  admission_policy (str|None): The cache admission policy decides for each
    cache miss, that is whether to insert the missed block or not.
  ttl (str|None): Cache entry time-to-live in seconds

Returns:
  GoogleLongrunningOperation Apitools object for creating caches.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z(patch_anywhere_cache must be overridden.rX   )rZ   r[   rc   r]   r^   s        r   patch_anywhere_cacheCloudApi.patch_anywhere_cache   s    * H
IIr   c                     [        S5      e)a#  Creates a new bucket with the specified metadata.

Args:
  bucket_resource (resource_reference.UnknownResource): The bucket to
    create.
  request_config (RequestConfig): Contains metadata for new bucket.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.

Raises:
  CloudApiError: API returned an error.
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  resource_reference.BucketResource representing new bucket.
z!create_bucket must be overridden.rX   rZ   bucket_resourcerequest_configfields_scopes       r   create_bucketCloudApi.create_bucket      & A
BBr   c                     [        S5      e)aj  Deletes a bucket.

Args:
  bucket_name (str): Name of the bucket to delete.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z!delete_bucket must be overridden.rX   )rZ   r[   rz   s      r   delete_bucketCloudApi.delete_bucket       A
BBr   Fc                     [        S5      e)a(  Gets bucket metadata.

Args:
  bucket_name (str): Name of the bucket.
  generation (int|None): Generation of the bucket.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.
  soft_deleted (bool): If true, return the soft-deleted version of this
    bucket.

Returns:
  resource_reference.BucketResource containing the bucket metadata.

Raises:
  CloudApiError: API returned an error.
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.
zget_bucket must be overridden.rX   )rZ   r[   
generationr{   soft_deleteds        r   
get_bucketCloudApi.get_bucket(  s    , >
??r   c                     [        S5      e)a  Gets bucket IAM policy.

Args:
  bucket_name (str): Name of the bucket.

Returns:
  Provider-specific data type. Currently, only available for GCS so returns
    Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
)get_bucket_iam_policy must be overridden.rX   rq   s     r   get_bucket_iam_policyCloudApi.get_bucket_iam_policy@  s      I
JJr   c                     [        S5      e)a
  Lists bucket metadata for the given project.

Args:
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.
  soft_deleted (bool): If true, only soft-deleted bucket versions will be
    returned.
  prefix (str): If provided, only buckets with the given prefix will be
    returned.

Yields:
  Iterator over resource_reference.BucketResource objects

Raises:
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z list_buckets must be overridden.rX   )rZ   r{   r   prefixs       r   list_bucketsCloudApi.list_bucketsR  s    & @
AAr   c                     [        S5      e)a7  Relocates a bucket between different locations.

Args:
  bucket_name (str): Name of the bucket.
  destination_location (str): The new location the bucket will be relocated
    to.
  destination_custom_placement_config (list[str]): The bucket's new custom
    placement configuration if relocating to a Custom Dual Region.
  validate_only (bool): If true, validate the operation, but do not actually
    relocate the bucket.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z#relocate_bucket must be overridden.rX   )rZ   r[   destination_location#destination_custom_placement_configvalidate_onlys        r   relocate_bucketCloudApi.relocate_bucketg  s    . C
DDr   c                     [        S5      e)a  Locks a bucket's retention policy.

Args:
  bucket_resource (UnknownResource): The bucket with the policy to lock.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.

Returns:
  resource_reference.BucketResource containing the bucket metadata.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
      this interface.
z0lock_bucket_retention_policy must be overridden.rX   )rZ   ry   rz   s      r   lock_bucket_retention_policy%CloudApi.lock_bucket_retention_policy  s      :< <r   c                     [        S5      e)a  Patches bucket metadata.

Args:
  bucket_resource (BucketResource|UnknownResource): The bucket to patch.
  request_config (RequestConfig): Contains new metadata for the bucket.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.

Returns:
  resource_reference.BucketResource containing the bucket metadata.

Raises:
  CloudApiError: API returned an error.
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
      this interface.
z patch_bucket must be overridden.rX   rx   s       r   patch_bucketCloudApi.patch_bucket  s    $ @
AAr   c                     [        S5      e)ad  Sets bucket IAM policy.

Args:
  bucket_name (str): Name of the bucket.
  policy (object): Provider-specific data type. Currently, only
    available for GCS so Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Returns:
  Provider-specific data type. Currently, only available for GCS so returns
    Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
r   rX   )rZ   r[   policys      r   set_bucket_iam_policyCloudApi.set_bucket_iam_policy  s    & I
JJr   c                     [        S5      e)a  Creates an HMAC key.

Args:
  service_account_email (str): The email of the service account to use.

Returns:
  gcs_resource_reference.GcsHmacKeyResource. Provider-specific data type
  is used for now because we currently support this feature only for the
  JSON API.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z#create_hmac_key must be overridden.rX   )rZ   service_account_emails     r   create_hmac_keyCloudApi.create_hmac_key  s      C
DDr   c                     [        S5      e)zDeletes an HMAC key.

Args:
  access_id (str): The access ID corresponding to the HMAC key.

Returns:
  None

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z#delete_hmac_key must be overridden.rX   rZ   	access_ids     r   delete_hmac_keyCloudApi.delete_hmac_key       C
DDr   c                     [        S5      e)a  Gets an HMAC key.

Args:
  access_id (str): The access ID corresponding to the HMAC key.

Returns:
  gcs_resource_reference.GcsHmacKeyResource. Provider-specific data type
  is used for now because we currently support this feature only for the
  JSON API.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z get_hmac_key must be overridden.rX   r   s     r   get_hmac_keyCloudApi.get_hmac_key        @
AAr   c                     g)a  Lists HMAC keys.

Args:
  service_account_email (str): Return HMAC keys for the given service
    account email.
  show_deleted_keys (bool): If True, include keys in the DELETED state.
  fields_scope (FieldsScope): Determines which metadata keys
    the API should return for each key.

Yields:
  Iterator over gcs_resource_reference.GcsHmacKeyResource objects.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
Nr   )rZ   r   show_deleted_keysr{   s       r   list_hmac_keysCloudApi.list_hmac_keys  s    & 	r   c                     [        S5      e)a  Updates an HMAC key.

Args:
  access_id (str): The access ID corresponding to the HMAC key.
  etag (str): Only perform the patch request if the etag matches this value.
  state (HmacKeyState): The desired state of the HMAC key.

Returns:
  gcs_resource_reference.GcsHmacKeyResource. Provider-specific data type
    is used for now because we currently support this feature only for the
    JSON API.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z"patch_hmac_key must be overridden.rX   )rZ   r   etagstates       r   patch_hmac_keyCloudApi.patch_hmac_key  s    $ B
CCr   c                     [        S5      e)ay  Concatenates a list of objects into a new object.

Args:
  source_resources (list[ObjectResource|UnknownResource]): The objects to
    compose.
  destination_resource (resource_reference.UnknownResource): Metadata for
    the resulting composite object.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.
  original_source_resource (Resource|None): Useful for finding metadata to
    apply to final object. For instance, if doing a composite upload, this
    would represent the pre-split local file.
  posix_to_set (PosixAttributes|None): Set as custom metadata on target.

Returns:
  resource_reference.ObjectResource with composite object's metadata.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z"compose_object must be overridden.rX   )rZ   source_resourcesdestination_resourcerz   original_source_resourceposix_to_sets         r   compose_objectsCloudApi.compose_objects  s    < B
CCr   c                     [        S5      e)ax  Copies an object within the cloud of one provider.

Args:
  source_resource (resource_reference.ObjectResource): Resource for source
    object. Must have been confirmed to exist in the cloud.
  destination_resource (resource_reference.ObjectResource|UnknownResource):
    Resource for destination object. Existence doesn't have to be confirmed.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.
  posix_to_set (PosixAttributes|None): Set as custom metadata on target.
  progress_callback (function): Optional callback function for progress
    notifications. Receives calls with arguments (bytes_transferred,
    total_size).
  should_deep_copy_metadata (bool): Rather than copying select fields of the
    source metadata, if True, copy everything. The request_config data
    (containing user args) overrides the deep-copied data.

Returns:
  resource_reference.ObjectResource with new object's metadata.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
zcopy_object must be overriddenrX   )rZ   source_resourcer   rz   r   progress_callbackshould_deep_copy_metadatas          r   copy_objectCloudApi.copy_object9  s    D >
??r   c                     [        S5      e)ax  Deletes an object.

Args:
  object_url (storage_url.CloudUrl): Url of object to delete.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
      this interface.
z!delete_object must be overridden.rX   )rZ   
object_urlrz   s      r   delete_objectCloudApi.delete_object]  r   r   r   c
                     [        S5      e)a  Gets object data.

Args:
  cloud_resource (resource_reference.ObjectResource): Contains metadata and
    information about object being downloaded.
  download_stream (stream): Stream to send the object data to.
  request_config (RequestConfig): Contains arguments for API calls.
  digesters (dict): Dict of {string : digester}, where string is the name of
    a hash algorithm, and digester is a validation digester object that
    update(bytes) and digest() using that algorithm. Implementation can set
    the digester value to None to indicate supports bytes were not
    successfully digested on-the-fly.
  do_not_decompress (bool): If true, gzipped objects will not be
    decompressed on-the-fly if supported by the API.
  download_strategy (DownloadStrategy): Cloud API download strategy to use
    for download.
  progress_callback (function): Optional callback function for progress
    notifications. Receives calls with arguments (bytes_transferred,
    total_size).
  start_byte (int): Starting point for download (for resumable downloads and
    range requests). Can be set to negative to request a range of bytes
    (python equivalent of [:-3]).
  end_byte (int): Ending byte number, inclusive, for download (for range
    requests). If None, download the rest of the object.

Returns:
  server_encoding (str): Useful for determining what the server actually
    sent versus what object metadata claims.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z#download_object must be overridden.rX   )
rZ   cloud_resourcedownload_streamrz   	digestersdo_not_decompressdownload_strategyr   
start_byteend_bytes
             r   download_objectCloudApi.download_objectl  s    X C
DDr   c                     [        S5      e)a  Gets object IAM policy.

Args:
  bucket_name (str): Name of the bucket.
  object_name (str): Name of the object.
  generation (str|None): Generation of object.

Returns:
  Provider-specific data type. Currently, only available for GCS so returns
    Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)get_object_iam_policy must be overridden.rX   )rZ   r[   object_namer   s       r   get_object_iam_policyCloudApi.get_object_iam_policy  s    $ I
JJr   c                     [        S5      e)a  Gets object metadata.

If decryption is supported by the implementing class, this function will
read decryption keys from configuration and appropriately retry requests to
encrypted objects with the correct key.

Args:
  bucket_name (str): Bucket containing the object.
  object_name (str): Object name.
  request_config (RequestConfig): Contains API call arguments.
  generation (string): Generation of the object to retrieve.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.
  soft_deleted (bool): Returns the soft-deleted version of an object (not
    the live version or a past version in a bucket with versioning enabled).

Returns:
  resource_reference.ObjectResource with object metadata.

Raises:
  CloudApiError: API returned an error.
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.
  NotFoundError: Raised if object does not exist.
z'get_object_metadata must be overridden.rX   )rZ   r[   r   rz   r   r{   r   s          r   get_object_metadataCloudApi.get_object_metadata  s    F G
HHr   Tc
                     [        S5      e)a  Lists objects (with metadata) and prefixes in a bucket.

Args:
  bucket_name (str): Bucket containing the objects.
  prefix (str|None): Prefix for directory-like behavior.
  delimiter (str|None): Delimiter for directory-like behavior.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.
  halt_on_empty_response (bool): For features like soft delete, the API may
    return an empty list and a next page token. If true, print a warning
    instead of using the next page token. See the warning text details.
  include_folders_as_prefixes (bool): If True, includes managed folders as
    prefixes in list responses. This means that managed folders that don't
    contain objects will be listed.
  next_page_token (str|None): Used to resume LIST calls. For example, if
    halt_on_empty_response was true and a halt warning is printed, it will
    contain a next_page_token the user can use to resume querying.
  object_state (ObjectState): What versions of an object to query.
  list_filter (str|None): If provided, objects with matching
    filters will be returned, The prefixes would still be returned
    regardless of whether they match the specified filter, See
    go/gcs-object-context-filtering for more details.

Yields:
  Iterator over resource_reference.ObjectResource objects.

Raises:
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z list_objects must be overridden.rX   )
rZ   r[   r   	delimiterr{   halt_on_empty_responseinclude_folders_as_prefixesnext_page_tokenobject_statelist_filters
             r   list_objectsCloudApi.list_objects  s    V @
AAr   c                     [        S5      e)a  Updates object metadata with patch semantics.

Args:
  bucket_name (str): Bucket containing the object.
  object_name (str): Object name.
  object_resource (resource_reference.ObjectResource): Contains metadata
    that will be used to update cloud object. May have different name than
    object_name argument.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.
  fields_scope (FieldsScope): Determines the fields and projection
    parameters of API call.
  generation (string): Generation (or version) of the object to update.
  posix_to_set (PosixAttributes|None): Set as custom metadata on target.

Returns:
  resource_reference.ObjectResource with patched object metadata.

Raises:
  CloudApiError: API returned an error.
  Error: Invalid fields_scope.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)patch_object_metadata must be overridden.rX   )rZ   r[   r   object_resourcerz   r{   r   r   s           r   patch_object_metadataCloudApi.patch_object_metadata   s    D I
JJr   c                     [        S5      e)a  Sets object IAM policy.

Args:
  bucket_name (str): Name of the bucket.
  object_name (str): Name of the object.
  policy (object): Provider-specific data type. Currently, only available
    for GCS so Apitools messages.Policy object. If supported for more
    providers in the future, use a generic container.
  generation (str|None): Generation of object.

Returns:
  Provider-specific data type. Currently, only available for GCS so returns
    Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)set_bucket_iam_policy must be overridden.rX   )rZ   r[   r   r   r   s        r   set_object_iam_policyCloudApi.set_object_iam_policy$  s    2 I
JJr   c	                     [        S5      e)ao  Uploads object data and metadata.

Args:
  source_stream (stream): Seekable stream of object data.
  destination_resource (resource_reference.ObjectResource|UnknownResource):
    Contains the correct metadata to upload.
  request_config (RequestConfig): Object containing general API function
    arguments. Subclasses for specific cloud providers are available.
  posix_to_set (PosixAttributes|None): Set as custom metadata on target.
  serialization_data (dict): API-specific data needed to resume an upload.
    Only used with UploadStrategy.RESUMABLE.
  source_resource (resource_reference.FileObjectResource|None): Contains the
    source StorageUrl. Can be None if source is pure stream.
  tracker_callback (Callable[[dict]|None]): Function that writes a tracker
    file with serialization data. Only used with UploadStrategy.RESUMABLE.
  upload_strategy (UploadStrategy): Strategy to use for this upload.

Returns:
  resource_reference.ObjectResource with uploaded object's metadata.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z!upload_object must be overridden.rX   )	rZ   source_streamr   rz   r   serialization_datar   tracker_callbackupload_strategys	            r   upload_objectCloudApi.upload_object?  s    H A
BBr   c                     [        S5      e)a  Creates a managed folder.

Args:
  bucket_name (str): The bucket to create the managed folder in.
  managed_folder_name (str): The name of the managed folder to create.

Returns:
  A resource_reference.ManagedFolderResource for the new managed folder.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)create_managed_folder must be overridden.rX   rZ   r[   managed_folder_names      r   create_managed_folderCloudApi.create_managed_foldere  s     I
JJr   c                     [        S5      e)a@  Deletes a managed folder.

Args:
  bucket_name (str): The bucket containing the managed folder to delete.
  managed_folder_name (str): The name of the managed folder to delete.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z)delete_managed_folder must be overridden.rX   r   s      r   delete_managed_folderCloudApi.delete_managed_folderv  s     I
JJr   c                     [        S5      e)a|  Gets metadata for a managed folder.

Args:
  bucket_name (str): The bucket containing the managed folder to get.
  managed_folder_name (str): The name of the managed folder to get.

Returns:
  A resource_reference.ManagedFolderResource.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z&get_managed_folder must be overridden.rX   r   s      r   get_managed_folderCloudApi.get_managed_folder  rf   r   c                     [        S5      e)a  Gets the IAM policy for a managed folder.

Args:
  bucket_name (str): The bucket containing the managed folder to get the IAM
    policy for.
  managed_folder_name (str): The name of the managed folder to get the IAM
    policy for.

Returns:
  An Apitools message.Policy object.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z1get_managed_folder_iam_policy must be overridden.rX   r   s      r   get_managed_folder_iam_policy&CloudApi.get_managed_folder_iam_policy  s    " ; r   c                     [        S5      e)a  Lists managed folders in a bucket.

Args:
  bucket_name (str): The bucket to list managed folders in.
  prefix (str|None): Only managed folders beginning with `prefix` are listed
    if specified.

Yields:
  resource_reference.ManagedFolderResources

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z(list_managed_folders must be overridden.rX   rZ   r[   r   s      r   list_managed_foldersCloudApi.list_managed_folders  s      H
IIr   c                     [        S5      e)a  Sets the IAM policy for a managed folder.

Args:
  bucket_name (str): The bucket containing the managed folder to get the IAM
    policy for.
  managed_folder_name (str): The name of the managed folder to get the IAM
    policy for.
  policy (object): Provider-specific data type. Currently, only available
    for GCS so Apitools messages.Policy object. If supported for more
    providers in the future, use a generic container.

Returns:
  Provider-specific data type. Currently, only available for GCS so returns
    Apitools messages.Policy object. If supported for
    more providers in the future, use a generic container.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z1set_managed_folder_iam_policy must be overridden.rX   )rZ   r[   r   r   s       r   set_managed_folder_iam_policy&CloudApi.set_managed_folder_iam_policy  s    0 ; r   c                     [        S5      e)a  Creates a folder.

Args:
  bucket_name (str): The bucket to create the folder in.
  folder_name (str): The name of the folder to create.
  is_recursive (bool): Whether to create all folders in a given path if they
    do not exist.

Returns:
  A resource_reference.FolderResource for the new folder.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z!create_folder must be overridden.rX   )rZ   r[   folder_nameis_recursives       r   create_folderCloudApi.create_folder  s    " A
BBr   c                     [        S5      e)a   Deletes a folder.

Args:
  bucket_name (str): The bucket containing the folder to delete.
  folder_name (str): The name of the folder to delete.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z!delete_folder must be overridden.rX   rZ   r[   r  s      r   delete_folderCloudApi.delete_folder  s     A
BBr   c                     [        S5      e)aU  Gets metadata for a folder.

Args:
  bucket_name (str): The bucket containing the folder to get.
  folder_name (str): The name of the folder to get.

Returns:
  A resource_reference.FolderResource.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
zget_folder must be overridden.rX   r  s      r   
get_folderCloudApi.get_folder  s     >
??r   c                     [        S5      e)aj  Lists folders in a bucket.

Args:
  bucket_name (str): The bucket to list folders in.
  prefix (str|None): Only folders beginning with `prefix` are listed if
    specified.

Yields:
  resource_reference.FolderResources

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z list_folders must be overridden.rX   r   s      r   list_foldersCloudApi.list_folders
  r   r   c                     [        S5      e)a  Renames a folder to a specified destination folder name in a bucket.

Args:
  bucket_name (str): The bucket to list folders in.
  source_folder_name (str): Name of the folder which needs to be renamed.
  destination_folder_name (str): Name of the folder to which the source
    folder needs to be renamed.

Returns:
  GoogleLongrunningOperation Apitools object for renaming folders.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z!rename_folder must be overridden.rX   )rZ   r[   source_folder_namedestination_folder_names       r   rename_folderCloudApi.rename_folder  r~   r   c                     [        S5      e)aH  Returns the email address (str) used to identify the service agent.

For some providers, the service agent is responsible for encrypting and
decrypting objects using CMEKs. project_number is useful because it may be
in bucket metadata when project ID is not.

If neither project_id or project_number are available, uses the
  default project configured in gcloud.


Args:
  project_id (str|None): Project to get service account for. Takes
    precedence over project_number.
  project_number (int|None): Project to get service account for.

Returns:
  Email of service account (str).
z%get_service_agent must be overridden.rX   )rZ   
project_idproject_numbers      r   get_service_agentCloudApi.get_service_agent1  s    & E
FFr   c                     [        S5      e)aU  Creates a new notification on a bucket with the specified parameters.

Args:
  url (storage_url.CloudUrl): Bucket URL.
  pubsub_topic (str): Cloud Pub/Sub topic to publish to.
  custom_attributes (dict[str, str]|None): Dictionary of custom attributes
    to apply to all notifications sent by the new configuration.
  event_types (list[NotificationEventType]|None): Event type filters, e.g.
    'OBJECT_FINALIZE'.
  object_name_prefix (str|None): Filter on object name.
  payload_format (NotificationPayloadFormat): Format of body of
    notifications sent by the new configuration.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received a non-bucket URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  Apitools Notification object for the new notification configuration.
z5create_notification_configuration must be overridden.rX   )rZ   urlpubsub_topiccustom_attributesevent_typesobject_name_prefixpayload_formats          r   !create_notification_configuration*CloudApi.create_notification_configurationF  s    < ?A Ar   c                     [        S5      e)aa  Deletes a notification configuration on a bucket.

Args:
  url (storage_url.CloudUrl): Bucket URL.
  notification_id (str): Name of the notification configuration.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received a non-bucket URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z5delete_notification_configuration must be overridden.rX   rZ   r  notification_ids      r   !delete_notification_configuration*CloudApi.delete_notification_configurationg  s     ?A Ar   c                     [        S5      e)a^  Gets a notification configuration on a bucket.

Args:
  url (storage_url.CloudUrl): Bucket URL.
  notification_id (str): Name of the notification configuration.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received a non-bucket URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z2get_notification_configuration must be overridden.rX   r(  s      r   get_notification_configuration'CloudApi.get_notification_configurationw  s     <> >r   c                     [        S5      e)aP  Lists notification configurations on a bucket.

Args:
  url (storage_url.CloudUrl): Bucket URL.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received a non-bucket URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Yields:
  List of  apitools Notification objects.
z4list_notification_configurations must be overridden.rX   rZ   r  s     r    list_notification_configurations)CloudApi.list_notification_configurations  s     >@ @r   c                     [        S5      e)a3  Advances a bucket relocation operation, by applying write lock.

Args:
  bucket_name (str): Name of the bucket to advance the relocate for.
  operation_id (str): ID of the operation resource.
  ttl (int | None): Specifies the duration in int seconds, after which the
    relocation will revert to the sync stage if the relocation hasn't
    succeeded. Optional, if not supplied, a default value of 12h will be
    used.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.
z+advance_relocate_bucket must be overridden.rX   )rZ   r[   operation_idr^   s       r   advance_relocate_bucket CloudApi.advance_relocate_bucket  s      K
LLr   c                     [        S5      e)a  Cancels a long-running operation if it's still running.

Args:
  bucket_name (str): Bucket associated with operation.
  operation_id (str): Operation to cancel.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: Function not implemented by child class.
z$cancel_operation must be overridden.rX   rZ   r[   r4  s      r   cancel_operationCloudApi.cancel_operation  s     D
EEr   c                     [        S5      e)aF  Returns metadata of a long-running operation.

Args:
  bucket_name (str): Bucket associated with operation.
  operation_id (str): Operation to fetch.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: Function not implemented by child class.

Returns:
  Apitools Operation object (currently Google-only).
z!get_operation must be overridden.rX   r8  s      r   get_operationCloudApi.get_operation  s     A
BBr   c                     [        S5      e)aU  Lists long-running operations.

Args:
  bucket_name (str): Bucket associated with target operations.
  server_side_filter: (str|None): Filter operations on backend.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: Function not implemented by child class.

Yields:
  Apitools Operation objects (currently Google-only).
z#list_operations must be overridden.rX   )rZ   r[   server_side_filters      r   list_operationsCloudApi.list_operations  r   r   c                     [        S5      e)a  Restores soft-deleted object.

Args:
  url (storage_url.CloudUrl): Object URL.
  request_config (RequestConfig): Contains preconditions for API requests.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received invalid object URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  ObjectResource of restored resource.
z"restore_object must be overridden.rX   )rZ   r  rz   s      r   restore_objectCloudApi.restore_object  s      B
CCr   c                     [        S5      e)aQ  Restores a soft-deleted bucket.

Args:
  url (storage_url.CloudUrl): Bucket URL with generation.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received invalid Bucket URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  BucketResource of restored resource.
z"restore_bucket must be overridden.rX   r0  s     r   restore_bucketCloudApi.restore_bucket  s     B
CCr   c	                     [        S5      e)a   Initiates long-running operation to restore soft-deleted objects.

Args:
  bucket_url (StorageUrl): Launch a bulk restore operation for this bucket.
  object_globs (list[str]): Objects in the target bucket matching these glob
    patterns will be restored.
  request_config (RequestConfig): Contains preconditions for API requests.
  allow_overwrite (bool): Allow overwriting live objects with soft-deleted
    versions.
  created_after_time (datetime|None): Restore only objects created after
    this time.
  created_before_time (datetime|None): Restore only objects created before
    this time.
  deleted_after_time (datetime|None): Restore only objects soft-deleted
    after this time.
  deleted_before_time (datetime|None): Restore only objects soft-deleted
    before this time.

Raises:
  CloudApiError: API returned an error.
  InvalidUrlError: Received invalid object URL.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  GoogleLongrunningOperation Apitools object for restoring objects.
z'bulk_restore_object must be overridden.rX   )	rZ   
bucket_urlobject_globsrz   allow_overwritecreated_after_timecreated_before_timedeleted_after_timedeleted_before_times	            r   bulk_restore_objectsCloudApi.bulk_restore_objects  s    L G
HHr   c                     [        S5      e)a  Returns the storage layout configuration for the specified bucket.

Note that this operation requires storage.objects.list permission.

Args:
  bucket_name (str): Name of the Bucket for which we need layout
    configuration details.

Raises:
  CloudApiError: API returned an error.
  NotImplementedError: This function was not implemented by a class using
    this interface.

Returns:
  apitools BucketStorageLayout object.
z&get_storage_layout must be overridden.rX   rq   s     r   get_storage_layoutCloudApi.get_storage_layout#  s    " F
GGr   c                     [        S5      e)zWaits for the given google.longrunning.Operation to complete.

Args:
  operation_ref: The operation to poll.

Returns:
  The Operation once it completes.

Raises:
  apitools.base.py.HttpError: if the request returns an HTTP error.
z&wait_for_operation must be overridden.rX   )rZ   operation_refs     r   wait_for_operationCloudApi.wait_for_operation6  s     F
GGr   r   )NN)N)NNF)NFN)NNNF)NNN)F)FNNNN)Jr   r   r   r   r   setcapabilitiesMAX_OBJECTS_PER_COMPOSE_CALLMAX_OBJECT_NAME_LENGTHr_   rd   rh   rk   rn   rr   ru   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   r   r   r   rN   rQ   r   r   r   r'   r,   r   r   r   r   r   r   r  r  r  r  r  r  r  rG   rK   r%  r*  r-  r1  r5  r9  r<  r@  rC  rF  rP  rS  rW  r   r   r   r   rU   rU   n   s9   
 ,
 "#
   ;?K0H"J KLI" HLJ.C*C  KP@0K$B*E2<&B(K*E$E B$ JO"&	*D2  $DJ  %"@HC& !%(-(8(A(A(,!"#,E\K0 #IP !"&##+Bf "KP (,	K@ $++$CLK"KH"*J$8C&C@"B$C*G2 .33ABA > @$M$FC E D$D, &IPH&Hr   rU   )r   
__future__r   r   r   enum"googlecloudsdk.command_lib.storager   Enumr   r   r'   r0   r;   r@   rG   rN   ProviderPrefixGCSDEFAULT_PROVIDERNUM_ITEMS_PER_LIST_PAGEobjectrU   r   r   r   <module>rf     s    B '  '  :L L0tyy TYY $)) 499 
4DII 4		  $))   --11  THv THr   