
    (ph6                       S r SSKrSSKrSSKrSSK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&J'r'J(r(J)r)  SSK*J+r+  SSK,J-r-J.r.J/r/  SSK0J1r1  SSK2J3r3  SSK4J5r5  SSK4J6r6  SSK7J8r8  SSK9J:r:  \;" 5       r< " S S \5      r=S! r>S" r?g)#z9Client for interacting with the Google Cloud Storage API.    N)AnonymousCredentials)page_iterator)_LocalStack)ClientWithProject)NotFound) _add_generation_match_parameters)_bucket_bound_hostname_url)_get_api_endpoint_override)_get_environ_project)_get_storage_emulator_override)_use_client_cert)_virtual_hosted_style_base_url)_DEFAULT_UNIVERSE_DOMAIN)_DEFAULT_SCHEME)_STORAGE_HOST_TEMPLATE)_NOW)_UTC)create_trace_span)
Connection)get_expiration_seconds_v4get_v4_now_dtstampsensure_signed_credentials_sign_messageBatch)Bucket_item_to_blob_blobs_page_start)Blob)HMACKeyMetadata)	BucketACL)DefaultObjectACL)_DEFAULT_TIMEOUT)DEFAULT_RETRYc                     ^  \ rS rSrSrSr \SSSSS0 4SS.U 4S jjjr\S 5       r	\
S	 5       r\
S
 5       r\
S 5       r\R                  S 5       rS rS r\
S 5       rS\\4S jrS+S jrS,S jrSS\\S4S jrSSS\R2                  S\\4S jrSS\SS4S jrSS\SS4S jrSS\SS4S jrSS\\S4S jrS-S jr\SS\4SSS.S jjr \SS\4S jr!SSSSSSSS\\4
S jr"SSSSSSSSS\S\4S  jr#SSSSSSSSS!SS\\SSS4S" jr$SSSS!SSS\\4	SS#.S$ jjr%S!SS\\4S% jr&SS\S4S& jr'SSSSS\\4S' jr(SS\4S( jr)        S.S) jr*S*r+U =r,$ )/ClientC   as	  Client to bundle configuration needed for API requests.

:type project: str or None
:param project: the project which the client acts on behalf of. Will be
                passed when creating a topic.  If not passed,
                falls back to the default inferred from the environment.

:type credentials: :class:`~google.auth.credentials.Credentials`
:param credentials: (Optional) The OAuth2 Credentials to use for this
                    client. If not passed (and if no ``_http`` object is
                    passed), falls back to the default inferred from the
                    environment.

:type _http: :class:`~requests.Session`
:param _http: (Optional) HTTP object to make requests. Can be any object
              that defines ``request()`` with the same interface as
              :meth:`requests.Session.request`. If not passed, an
              ``_http`` object is created that is bound to the
              ``credentials`` for the current object.
              This parameter should be considered private, and could
              change in the future.

:type client_info: :class:`~google.api_core.client_info.ClientInfo`
:param client_info:
    The client info used to send a user-agent string along with API
    requests. If ``None``, then default info will be used. Generally,
    you only need to set this if you're developing your own library
    or partner tool.

:type client_options: :class:`~google.api_core.client_options.ClientOptions` or :class:`dict`
:param client_options: (Optional) Client options used to set user options on the client.
    A non-default universe domain or api endpoint should be set through client_options.

:type use_auth_w_custom_endpoint: bool
:param use_auth_w_custom_endpoint:
    (Optional) Whether authentication is required under custom endpoints.
    If false, uses AnonymousCredentials and bypasses authentication.
    Defaults to True. Note this is only used when a custom endpoint is set in conjunction.

:type extra_headers: dict
:param extra_headers:
    (Optional) Custom headers to be sent with the requests attached to the client.
    For example, you can add custom audit logging headers.

:type api_key: string
:param api_key:
    (Optional) An API key. Mutually exclusive with any other credentials.
    This parameter is an alias for setting `client_options.api_key` and
    will supercede any api key set in the `client_options` parameter.
)z7https://www.googleapis.com/auth/devstorage.full_controlz4https://www.googleapis.com/auth/devstorage.read_onlyz5https://www.googleapis.com/auth/devstorage.read_writeNT)api_keyc                  > S U l         Uc  Sn	SnOSn	U[        L a  S nX@l        XPl        Xpl        SU0n
U(       a0  U(       a  [        U[        5      (       d  Xl        OU(       d  0 nXS'   U(       a>  [        U[        5      (       a)  [        R                  R                  R                  U5      nU(       a#  UR                  (       a  UR                  U l        OS U l        [        5       n[        5       nU(       a  UR                   (       a  UR                   nOgU(       a  UnO]U(       a  UnOSU R                  (       a@  [#        5       (       a  [%        S5      e[&        [(        R*                  " U R                  S9-   nOS nXS'   U(       a  SOSU l        U
S   b9  U R,                  (       d  U(       d!  Uc
  [/        5       nUc
  [1        5       nUc  Sn	Sn[2        [4        U ]o  UUUUS	9  U R8                  R                  U R                  :w  a7  [%        S
R+                  U R                  U R8                  R                  S95      eU	(       a  S U l        [=        U 40 U
D6nX~l        Xl         [C        5       U l"        g )NT<none>Fclient_infor(   zThe "GOOGLE_API_USE_CLIENT_CERTIFICATE" env variable is set to "true" and a non-default universe domain is configured. mTLS is not supported in any universe other thangoogleapis.com.)universe_domainapi_endpoint)projectcredentialsclient_options_httpzThe configured universe domain ({client_ud}) does not match the universe domain found in the credentials ({cred_ud}). If you haven't configured the universe domain explicitly, `googleapis.com` is the default.)	client_udcred_ud)#_base_connection_marker_initial_client_info_initial_client_options_extra_headers
isinstancedictr(   googleapi_corer0   	from_dictr,   _universe_domainr   r
   r-   r   
ValueErrorr   r   format_is_emulator_setr   r   superr&   __init___credentialsr.   r   extra_headers_connectionr   _batch_stack)selfr.   r/   r1   r+   r0   use_auth_w_custom_endpointrE   r(   
no_projectconnection_kw_argsstorage_emulator_overrideapi_endpoint_overrider-   
connection	__class__s                  N/var/www/html/venv/lib/python3.13/site-packages/google/cloud/storage/client.pyrC   Client.__init__~   sY    !%?JGJgG %0!'5$++[9
 j&F&F)0&%%'N,3y).$//!'!?!?!I!I"" n<<$2$B$BD!$(D!$B$D! : < n99)66L '4L #0L ""  !! &  +-C-J-J $ 5 5. L  L-9>*(Au n-9$$,F&"6"8K?24G?!%J&Gfd$#)	 	% 	
 ,,0D0DD3 4:6"22 --== 4: 4	  DL  ;(:;
#0 %'M    c                 2    U " S[        5       S9nSUl        U$ )a%  Factory: return client with anonymous credentials.

.. note::

   Such a client has only limited access to "public" buckets:
   listing their contents and downloading their blobs.

:rtype: :class:`google.cloud.storage.client.Client`
:returns: Instance w/ anonymous credentials and no project.
r*   )r.   r/   N)r   r.   )clsclients     rP   create_anonymous_clientClient.create_anonymous_client  s      X3G3IJrR   c                 4    U R                   =(       d    [        $ N)r>   r   rH   s    rP   r,   Client.universe_domain$  s    $$@(@@rR   c                 .    U R                   R                  $ rY   )rF   API_BASE_URLrZ   s    rP   r-   Client.api_endpoint(  s    ,,,rR   c                 L    U R                   b  U R                   $ U R                  $ )zGet connection or batch on the client.

:rtype: :class:`google.cloud.storage._http.Connection`
:returns: The connection set on the client, or the batch
          if one is set.
)current_batchr4   rZ   s    rP   rF   Client._connection,  s(     )%%%(((rR   c                 @    U R                   b  [        S5      eXl         g)ad  Set connection on the client.

Intended to be used by constructor (since the base class calls)
    self._connection = connection
Will raise if the connection is set more than once.

:type value: :class:`google.cloud.storage._http.Connection`
:param value: The connection set on the client.

:raises: :class:`ValueError` if connection has already been set.
Nz Connection already set on client)r4   r?   )rH   values     rP   rF   ra   9  s"       ,?@@ %rR   c                 :    U R                   R                  U5        g)zPush a batch onto our stack.

"Protected", intended for use by batch context mgrs.

:type batch: :class:`google.cloud.storage.batch.Batch`
:param batch: newly-active batch
N)rG   push)rH   batchs     rP   _push_batchClient._push_batchJ  s     	u%rR   c                 6    U R                   R                  5       $ )zPop a batch from our stack.

"Protected", intended for use by batch context mgrs.

:raises: IndexError if the stack is empty.
:rtype: :class:`google.cloud.storage.batch.Batch`
:returns: the top-most batch/transaction, after removing it.
)rG   poprZ   s    rP   
_pop_batchClient._pop_batchT  s       $$&&rR   c                 .    U R                   R                  $ )zCurrently-active batch.

:rtype: :class:`google.cloud.storage.batch.Batch` or ``NoneType`` (if
        no batch is active).
:returns: The batch at the top of the batch stack.
)rG   toprZ   s    rP   r`   Client.current_batch_  s       $$$rR   c                     [        SS9   Uc  U R                  nSU S3nU R                  XBUS9nUS   sSSS5        $ ! , (       d  f       g= f)ad  Get the email address of the project's GCS service account

:type project: str
:param project:
    (Optional) Project ID to use for retreiving GCS service account
    email address.  Defaults to the client's project.
:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC. See: :ref:`configuring_retries`

:rtype: str
:returns: service account email address
z%Storage.Client.getServiceAccountEmailnameN
/projects/z/serviceAccounttimeoutretryemail_address)r   r.   _get_resource)rH   r.   ru   rv   pathapi_responses         rP   get_service_account_email Client.get_service_account_emaili  sS    * $KL,,y8D--d5-QL0 MLLs	   *>
Ac                     [        U UUUS9$ )aX  Factory constructor for bucket object.

.. note::
  This will not make an HTTP request; it simply instantiates
  a bucket object owned by this client.

:type bucket_name: str
:param bucket_name: The name of the bucket to be instantiated.

:type user_project: str
:param user_project: (Optional) The project ID to be billed for API
                     requests made via the bucket.

:type generation: int
:param generation: (Optional) If present, selects a specific revision of
                   this bucket.

:rtype: :class:`google.cloud.storage.bucket.Bucket`
:returns: The bucket object created.
)rU   rr   user_project
generation)r   )rH   bucket_namer~   r   s       rP   bucketClient.bucket  s    * %!	
 	
rR   c                     [        XS9$ )a<  Factory constructor for batch object.

.. note::
  This will not make an HTTP request; it simply instantiates
  a batch object owned by this client.

:type raise_exception: bool
:param raise_exception:
    (Optional) Defaults to True. If True, instead of adding exceptions
    to the list of return responses, the final exception will be raised.
    Note that exceptions are unwrapped after all operations are complete
    in success or failure, and only the last exception is raised.

:rtype: :class:`google.cloud.storage.batch.Batch`
:returns: The batch object created.
)rU   raise_exceptionr   )rH   r   s     rP   rf   Client.batch  s    " DBBrR   c           
      @    U R                   R                  SUUUUUUS9$ )aV  Helper for bucket / blob methods making API 'GET' calls.

Args:
    path str:
        The path of the resource to fetch.

    query_params Optional[dict]:
        HTTP query parameters to be passed

    headers Optional[dict]:
        HTTP headers to be passed

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    _target_object (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                 :class:`~google.cloud.storage.bucket.blob`,             ]):
        Object to which future data is to be applied -- only relevant
        in the context of a batch.

Returns:
    dict
        The JSON resource fetched

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
GETmethodry   query_paramsheadersru   rv   _target_objectrF   api_requestrH   ry   r   r   ru   rv   r   s          rP   rx   Client._get_resource  s8    p ++%) , 
 	
rR   c
                     SUUS.n
[        SU U
U	S9   [        R                  " U R                  R                  XS9nS S S 5        [
        R                  " U WUUUUUUUS9	$ ! , (       d  f       N*= f)Nr   )r   ry   ru   z.Storage.Client._list_resource_returns_iterator)rr   rU   r   rv   rt   )	rU   r   ry   item_to_value
page_tokenmax_resultsextra_params
page_start	page_size)r   	functoolspartialrF   r   r   HTTPIterator)rH   ry   r   r   r   r   r   r   ru   rv   kwargsr   s               rP   _list_resourceClient._list_resource  s     

 A	
 $++  ,,gK
 ))#'!#%!

 
	

 
s   *A!!
A/c                 B    U R                   R                  SUUUUUUUS9$ )a  Helper for bucket / blob methods making API 'PATCH' calls.

Args:
    path str:
        The path of the resource to fetch.

    data dict:
        The data to be patched.

    query_params Optional[dict]:
        HTTP query parameters to be passed

    headers Optional[dict]:
        HTTP headers to be passed

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    _target_object (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                 :class:`~google.cloud.storage.bucket.blob`,             ]):
        Object to which future data is to be applied -- only relevant
        in the context of a batch.

Returns:
    dict
        The JSON resource fetched

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
PATCHr   ry   datar   r   ru   rv   r   r   rH   ry   r   r   r   ru   rv   r   s           rP   _patch_resourceClient._patch_resource  s;    x ++%) , 	
 		
rR   c                 B    U R                   R                  SUUUUUUUS9$ )a  Helper for bucket / blob methods making API 'PUT' calls.

Args:
    path str:
        The path of the resource to fetch.

    data dict:
        The data to be patched.

    query_params Optional[dict]:
        HTTP query parameters to be passed

    headers Optional[dict]:
        HTTP headers to be passed

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    _target_object (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                 :class:`~google.cloud.storage.bucket.blob`,             ]):
        Object to which future data is to be applied -- only relevant
        in the context of a batch.

Returns:
    dict
        The JSON resource fetched

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
PUTr   r   r   s           rP   _put_resourceClient._put_resourced  s;    x ++%) , 	
 		
rR   c                 B    U R                   R                  SUUUUUUUS9$ )a  Helper for bucket / blob methods making API 'POST' calls.

Args:
    path str:
        The path of the resource to which to post.

    data dict:
        The data to be posted.

    query_params Optional[dict]:
        HTTP query parameters to be passed

    headers Optional[dict]:
        HTTP headers to be passed

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    _target_object (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                 :class:`~google.cloud.storage.bucket.blob`,             ]):
        Object to which future data is to be applied -- only relevant
        in the context of a batch.

Returns:
    dict
        The JSON resource returned from the post.

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
POSTr   r   r   s           rP   _post_resourceClient._post_resource  s;    z ++%) , 	
 		
rR   c           
      @    U R                   R                  SUUUUUUS9$ )aZ  Helper for bucket / blob methods making API 'DELETE' calls.

Args:
    path str:
        The path of the resource to delete.

    query_params Optional[dict]:
        HTTP query parameters to be passed

    headers Optional[dict]:
        HTTP headers to be passed

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    _target_object (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                 :class:`~google.cloud.storage.bucket.blob`,             ]):
        Object to which future data is to be applied -- only relevant
        in the context of a batch.

Returns:
    dict
        The JSON resource fetched

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
DELETEr   r   r   s          rP   _delete_resourceClient._delete_resource  s8    p ++%) , 
 	
rR   c                     [        U[        5      (       a)  U(       a  [        S5      eUnUR                  c  Xl        U$ [        XUS9nU$ )a  Helper to return given bucket or create new by name.

Args:
    bucket_or_name (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                  str,             ]):
        The bucket resource to pass or name to create.
    generation (Optional[int]):
        The bucket generation. If generation is specified,
        bucket_or_name must be a name (str).

Returns:
    google.cloud.storage.bucket.Bucket
        The newly created bucket or the given one.
zThe generation can only be specified if a name is used to specify a bucket, not a Bucket object. Create a new Bucket object with the correct generation instead.)rr   r   )r9   r   r?   rU   _client)rH   bucket_or_namer   r   s       rP   _bucket_arg_to_bucketClient._bucket_arg_to_bucket5  sV    " nf--   $F}}$!%  D*MFrR   )r   soft_deletedc          
          [        SS9   U R                  XS9nUR                  U UUUUUS9  UsSSS5        $ ! , (       d  f       g= f)a
  Retrieve a bucket via a GET request.

See [API reference docs](https://cloud.google.com/storage/docs/json_api/v1/buckets/get) and a [code sample](https://cloud.google.com/storage/docs/samples/storage-get-bucket-metadata#storage_get_bucket_metadata-python).

Args:
    bucket_or_name (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                  str,             ]):
        The bucket resource to pass or name to create.

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    if_metageneration_match (Optional[int]):
        Make the operation conditional on whether the
        bucket's current metageneration matches the given value.

    if_metageneration_not_match (Optional[int]):
        Make the operation conditional on whether the bucket's
        current metageneration does not match the given value.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    generation (Optional[int]):
        The generation of the bucket. The generation can be used to
        specify a specific soft-deleted version of the bucket, in
        conjunction with the ``soft_deleted`` argument below. If
        ``soft_deleted`` is not True, the generation is unused.

    soft_deleted (Optional[bool]):
        If True, looks for a soft-deleted bucket. Will only return
        the bucket metadata if the bucket exists and is in a
        soft-deleted state. The bucket ``generation`` is required if
        ``soft_deleted`` is set to True.
        See: https://cloud.google.com/storage/docs/soft-delete

Returns:
    google.cloud.storage.bucket.Bucket
        The bucket matching the name provided.

Raises:
    google.cloud.exceptions.NotFound
        If the bucket is not found.
zStorage.Client.getBucketrq   )r   )rU   ru   if_metageneration_matchif_metageneration_not_matchrv   r   N)r   r   reload)	rH   r   ru   r   r   rv   r   r   r   s	            rP   
get_bucketClient.get_bucketU  sV    N $>?///VFMM(?,G)    @??s	   %9
Ac           	          [        SS9    U R                  UUUUUS9sSSS5        $ ! [         a     SSS5        gf = f! , (       d  f       g= f)a~  Get a bucket by name, returning None if not found.

You can use this if you would rather check for a None value
than catching a NotFound exception.

:type bucket_name: str
:param bucket_name: The name of the bucket to get.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type if_metageneration_match: long
:param if_metageneration_match: (Optional) Make the operation conditional on whether the
                                blob's current metageneration matches the given value.

:type if_metageneration_not_match: long
:param if_metageneration_not_match: (Optional) Make the operation conditional on whether the
                                    blob's current metageneration does not match the given value.

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC. See: :ref:`configuring_retries`

:rtype: :class:`google.cloud.storage.bucket.Bucket` or ``NoneType``
:returns: The bucket matching the name provided or None if not found.
zStorage.Client.lookupBucketrq   )ru   r   r   rv   N)r   r   r   )rH   r   ru   r   r   rv   s         rP   lookup_bucketClient.lookup_bucket  sc    H $AB	#,C0K '  CB   CB CBs!   A (
=A =A  
AFc           
         [        SS9   U R                  U5      n0 nUc  U R                  nU R                  (       a  Uc
  [	        5       nUc  SnUb  SU0nUb   [
        R                  " S[        SS9  X,l        Ub  [        R                  " U5      nX}S	'   Ub  [        R                  " U5      nUUS
'   Ub  XMS'   U	(       a  XS'   UR                   Vs0 s H  oUR                  U   _M     nnUR                  US'   Ub  X_S'   Ub  SU0US'   U R                  SUUU
UUS9nUR!                  U5        UsSSS5        $ s  snf ! , (       d  f       g= f)a  Create a new bucket via a POST request.

See [API reference docs](https://cloud.google.com/storage/docs/json_api/v1/buckets/insert) and a [code sample](https://cloud.google.com/storage/docs/samples/storage-create-bucket#storage_create_bucket-python).

Args:
    bucket_or_name (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                  str,             ]):
        The bucket resource to pass or name to create.
    requester_pays (bool):
        DEPRECATED. Use Bucket().requester_pays instead.
        (Optional) Whether requester pays for API requests for
        this bucket and its blobs.
    project (str):
        (Optional) The project under which the bucket is to be created.
        If not passed, uses the project set on the client.
    user_project (str):
        (Optional) The project ID to be billed for API requests
        made via created bucket.
    location (str):
        (Optional) The location of the bucket. If not passed,
        the default location, US, will be used. If specifying a dual-region,
        `data_locations` should be set in conjunction. See:
        https://cloud.google.com/storage/docs/locations
    data_locations (list of str):
        (Optional) The list of regional locations of a custom dual-region bucket.
        Dual-regions require exactly 2 regional locations. See:
        https://cloud.google.com/storage/docs/locations
    predefined_acl (str):
        (Optional) Name of predefined ACL to apply to bucket. See:
        https://cloud.google.com/storage/docs/access-control/lists#predefined-acl
    predefined_default_object_acl (str):
        (Optional) Name of predefined ACL to apply to bucket's objects. See:
        https://cloud.google.com/storage/docs/access-control/lists#predefined-acl
    enable_object_retention (bool):
        (Optional) Whether object retention should be enabled on this bucket. See:
        https://cloud.google.com/storage/docs/object-lock
    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

Returns:
    google.cloud.storage.bucket.Bucket
        The newly created bucket.

Raises:
    google.cloud.exceptions.Conflict
        If the bucket already exists.
zStorage.Client.createBucketrq   Nr*   r.   zFrequester_pays arg is deprecated. Use Bucket().requester_pays instead.   )
stacklevelpredefinedAclpredefinedDefaultObjectAcluserProjectenableObjectRetentionrr   locationdataLocationscustomPlacementConfig/b)r   ru   rv   r   )r   r   r.   rA   r   warningswarnPendingDeprecationWarningrequester_paysr!   validate_predefinedr"   _changes_propertiesrr   r   _set_properties)rH   r   r   r.   r~   r   data_locationspredefined_aclpredefined_default_object_aclenable_object_retentionru   rv   r   r   key
propertiesrz   s                    rP   create_bucketClient.create_bucket  s   ` $AB//?FL,, $$?24G?&G " )73)\- 
 )7%)!*!>!>~!N0>_-,80@0T0T11-
 2 0 '.:]+&8O45BH//R/3v11#66/JR!'Jv#)1:&)7F6W
23..)% / L ""<0A CBZ S[ CBs   CEE .AE E
Eautoc                     [        SS9   [        U[        5      (       d  [        R                  " U5      nUR	                  UU UUUUUUU	U
UUUUS9  SSS5        g! , (       d  f       g= f)a  Download the contents of a blob object or blob URI into a file-like object.

See https://cloud.google.com/storage/docs/downloading-objects

Args:
    blob_or_uri (Union[             :class:`~google.cloud.storage.blob.Blob`,              str,             ]):
        The blob resource to pass or URI to download.

    file_obj (file):
        A file handle to which to write the blob's data.

    start (int):
        (Optional) The first byte in a range to be downloaded.

    end (int):
        (Optional) The last byte in a range to be downloaded.

    raw_download (bool):
        (Optional) If true, download the object without any expansion.

    if_etag_match (Union[str, Set[str]]):
        (Optional) See :ref:`using-if-etag-match`

    if_etag_not_match (Union[str, Set[str]]):
        (Optional) See :ref:`using-if-etag-not-match`

    if_generation_match (long):
        (Optional) See :ref:`using-if-generation-match`

    if_generation_not_match (long):
        (Optional) See :ref:`using-if-generation-not-match`

    if_metageneration_match (long):
        (Optional) See :ref:`using-if-metageneration-match`

    if_metageneration_not_match (long):
        (Optional) See :ref:`using-if-metageneration-not-match`

    timeout ([Union[float, Tuple[float, float]]]):
        (Optional) The amount of time, in seconds, to wait
        for the server response.  See: :ref:`configuring_timeouts`

    checksum (str):
        (Optional) The type of checksum to compute to verify the integrity
        of the object. The response headers must contain a checksum of the
        requested type. If the headers lack an appropriate checksum (for
        instance in the case of transcoded or ranged downloads where the
        remote service does not know the correct checksum, including
        downloads where chunk_size is set) an INFO-level log will be
        emitted. Supported values are "md5", "crc32c", "auto" and None.
        The default is "auto", which will try to detect if the C
        extension for crc32c is installed and fall back to md5 otherwise.

    retry (google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy)
        (Optional) How to retry the RPC. A None value will disable
        retries. A google.api_core.retry.Retry value will enable retries,
        and the object will define retriable response codes and errors and
        configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a
        Retry object and activates it only if certain conditions are met.
        This class exists to provide safe defaults for RPC calls that are
        not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a
        condition such as if_metageneration_match is set.

        See the retry.py source code and docstrings in this package
        (google.cloud.storage.retry) for information on retry types and how
        to configure them.
z!Storage.Client.downloadBlobToFilerq   )rU   startendraw_downloadif_etag_matchif_etag_not_matchif_generation_matchif_generation_not_matchr   r   ru   checksumrv   N)r   r9   r   from_uri_prep_and_do_download)rH   blob_or_urifile_objr   r   r   r   r   r   r   r   r   ru   r   rv   s                  rP   download_blob_to_fileClient.download_blob_to_filej  ss    t $GHk400"mmK8--)+"3$7(?(?,G! . 	 IHHs   AA
A)noAclc                    [        SS9   U R                  U5      nSU
0nUb  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS'   Ub  UUS	'   Ub  UUS
'   U	b  U	US'   Ub  UUS'   Ub  UUS'   Ub  UUS'   UR                  b  UR                  US'   UR                  S-   nU R	                  U[
        UUU[        UUUS9	nUUl        [        5       Ul	        UsSSS5        $ ! , (       d  f       g= f)a  Return an iterator used to find blobs in the bucket.

If :attr:`user_project` is set, bills the API request to that project.

.. note::
  List prefixes (directories) in a bucket using a prefix and delimiter.
  See a [code sample](https://cloud.google.com/storage/docs/samples/storage-list-files-with-prefix#storage_list_files_with_prefix-python)
  listing objects using a prefix filter.

Args:
    bucket_or_name (Union[                 :class:`~google.cloud.storage.bucket.Bucket`,                  str,             ]):
        The bucket resource to pass or name to create.

    max_results (int):
        (Optional) The maximum number of blobs to return.

    page_token (str):
        (Optional) If present, return the next batch of blobs, using the
        value, which must correspond to the ``nextPageToken`` value
        returned in the previous response.  Deprecated: use the ``pages``
        property of the returned iterator instead of manually passing the
        token.

    prefix (str):
        (Optional) Prefix used to filter blobs.

    delimiter (str):
        (Optional) Delimiter, used with ``prefix`` to
        emulate hierarchy.

    start_offset (str):
        (Optional) Filter results to objects whose names are
        lexicographically equal to or after ``startOffset``. If
        ``endOffset`` is also set, the objects listed will have names
        between ``startOffset`` (inclusive) and ``endOffset``
        (exclusive).

    end_offset (str):
        (Optional) Filter results to objects whose names are
        lexicographically before ``endOffset``. If ``startOffset`` is
        also set, the objects listed will have names between
        ``startOffset`` (inclusive) and ``endOffset`` (exclusive).

    include_trailing_delimiter (boolean):
        (Optional) If true, objects that end in exactly one instance of
        ``delimiter`` will have their metadata included in ``items`` in
        addition to ``prefixes``.

    versions (bool):
        (Optional) Whether object versions should be returned
        as separate blobs.

    projection (str):
        (Optional) If used, must be 'full' or 'noAcl'.
        Defaults to ``'noAcl'``. Specifies the set of
        properties to return.

    fields (str):
        (Optional) Selector specifying which fields to include
        in a partial response. Must be a list of fields. For
        example to get a partial response with just the next
        page token and the name and language of each blob returned:
        ``'items(name,contentLanguage),nextPageToken'``.
        See: https://cloud.google.com/storage/docs/json_api/v1/parameters#fields

    page_size (int):
        (Optional) Maximum number of blobs to return in each page.
        Defaults to a value set by the API.

    timeout (Optional[Union[float, Tuple[float, float]]]):
        The amount of time, in seconds, to wait for the server response.

        Can also be passed as a tuple (connect_timeout, read_timeout).
        See :meth:`requests.Session.request` documentation for details.

    retry (Optional[Union[google.api_core.retry.Retry, google.cloud.storage.retry.ConditionalRetryPolicy]]):
        How to retry the RPC. A None value will disable retries.
        A google.api_core.retry.Retry value will enable retries, and the object will
        define retriable response codes and errors and configure backoff and timeout options.

        A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
        activates it only if certain conditions are met. This class exists to provide safe defaults
        for RPC calls that are not technically safe to retry normally (due to potential data
        duplication or other side-effects) but become safe to retry if a condition such as
        if_metageneration_match is set.

        See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
        information on retry types and how to configure them.

    match_glob (str):
        (Optional) A glob pattern used to filter results (for example, foo*bar).
        The string value must be UTF-8 encoded. See:
        https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-object-glob

    include_folders_as_prefixes (bool):
        (Optional) If true, includes Folders and Managed Folders in the set of
        ``prefixes`` returned by the query. Only applicable if ``delimiter`` is set to /.
        See: https://cloud.google.com/storage/docs/managed-folders

    soft_deleted (bool):
        (Optional) If true, only soft-deleted objects will be listed as distinct results in order of increasing
        generation number. This parameter can only be used successfully if the bucket has a soft delete policy.
        Note ``soft_deleted`` and ``versions`` cannot be set to True simultaneously. See:
        https://cloud.google.com/storage/docs/soft-delete

Returns:
    Iterator of all :class:`~google.cloud.storage.blob.Blob`
    in this bucket matching the arguments. The RPC call
    returns a response when the iterator is consumed.

    As part of the response, you'll also get back an iterator.prefixes entity that lists object names
    up to and including the requested delimiter. Duplicate entries are omitted from this list.
zStorage.Client.listBlobsrq   
projectionNprefix	delimiter	matchGlobstartOffset	endOffsetincludeTrailingDelimiterversionsfieldsincludeFoldersAsPrefixessoftDeletedr   z/o)r   r   r   r   r   ru   rv   )
r   r   r~   ry   r   r   r   r   setprefixes)rH   r   r   r   r   r   start_offset
end_offsetinclude_trailing_delimiterr   r   r   r   ru   rv   
match_globinclude_folders_as_prefixesr   r   r   ry   iterators                         rP   
list_blobsClient.list_blobs  sH   P $>?//?F(*5L!)/X&$,5[)%,6[)'.:]+%,6[))5;U78#+3Z(!)/X&*6;V78'.:]+""..4.A.A]+;;%D**%'),# + 
H %HO #Hi @??s   CC
C))r   c
                &   [        SS9   0 nUc  U R                  nU R                  (       a  Uc
  [        5       nUc  SnUb  SU0nUb  X;S'   XKS'   Ub  X[S'   U
b  XS	'   U R	                  S
[
        UUUUUU	S9sSSS5        $ ! , (       d  f       g= f)a
  Get all buckets in the project associated to the client.

This will not populate the list of blobs available in each
bucket.

See [API reference docs](https://cloud.google.com/storage/docs/json_api/v1/buckets/list) and a [code sample](https://cloud.google.com/storage/docs/samples/storage-list-buckets#storage_list_buckets-python).

:type max_results: int
:param max_results: (Optional) The maximum number of buckets to return.

:type page_token: str
:param page_token:
    (Optional) If present, return the next batch of buckets, using the
    value, which must correspond to the ``nextPageToken`` value
    returned in the previous response.  Deprecated: use the ``pages``
    property of the returned iterator instead of manually passing the
    token.

:type prefix: str
:param prefix: (Optional) Filter results to buckets whose names begin
               with this prefix.

:type projection: str
:param projection:
    (Optional) Specifies the set of properties to return. If used, must
    be 'full' or 'noAcl'. Defaults to 'noAcl'.

:type fields: str
:param fields:
    (Optional) Selector specifying which fields to include in a partial
    response. Must be a list of fields. For example to get a partial
    response with just the next page token and the language of each
    bucket returned: 'items/id,nextPageToken'

:type project: str
:param project: (Optional) The project whose buckets are to be listed.
                If not passed, uses the project set on the client.

:type page_size: int
:param page_size: (Optional) Maximum number of buckets to return in each page.
    Defaults to a value set by the API.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC. See: :ref:`configuring_retries`

:type soft_deleted: bool
:param soft_deleted:
    (Optional) If true, only soft-deleted buckets will be listed as distinct results in order of increasing
    generation number. This parameter can only be used successfully if the bucket has a soft delete policy.
    See: https://cloud.google.com/storage/docs/soft-delete

:rtype: :class:`~google.api_core.page_iterator.Iterator`
:raises ValueError: if both ``project`` is ``None`` and the client's
                    project is also ``None``.
:returns: Iterator of all :class:`~google.cloud.storage.bucket.Bucket`
          belonging to this project.
zStorage.Client.listBucketsrq   Nr*   r.   r   r   r   r   r   )r   r   r   r   ru   rv   )r   r.   rA   r   r   _item_to_bucket)rH   r   r   r   r   r   r.   r   ru   rv   r   r   s               rP   list_bucketsClient.list_buckets  s    Z $@AL,, $$?24G?&G " )73!)/X&)3&!)/X&'.:]+&&%')# ' 	; BAAs   A.B
Bc                     X#S.n[        UUUS9  U R                  U5      n	U R                  U	R                   S3SUUUS9n
U	R	                  U
5        U	$ )a  Restores a soft-deleted bucket.

:type bucket_name: str
:param bucket_name: The name of the bucket to be restored.

:type generation: int
:param generation: Selects the specific revision of the bucket.

:type projection: str
:param projection:
    (Optional) Specifies the set of properties to return. If used, must
    be 'full' or 'noAcl'. Defaults to 'noAcl'.

if_metageneration_match (Optional[int]):
    Make the operation conditional on whether the
    blob's current metageneration matches the given value.

if_metageneration_not_match (Optional[int]):
    Make the operation conditional on whether the blob's
    current metageneration does not match the given value.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC.

    Users can configure non-default retry behavior. A ``None`` value will
    disable retries. See [Configuring Retries](https://cloud.google.com/python/docs/reference/storage/latest/retry_timeout).

:rtype: :class:`google.cloud.storage.bucket.Bucket`
:returns: The restored Bucket.
)r   r   )r   r   z/restoreNr   ru   rv   )r   r   r   ry   r   )rH   r   r   r   r   r   ru   rv   r   r   rz   s              rP   restore_bucketClient.restore_bucket  sr    \ '1K($;(C	
 [)**{{m8$% + 
 	|,rR   c           	          [        SS9   Uc  U R                  nSU S3nSU0nUb  X7S'   U R                  USUUUS9n[        U 5      n	US	   U	l        US
   n
X4sSSS5        $ ! , (       d  f       g= f)a`  Create an HMAC key for a service account.

:type service_account_email: str
:param service_account_email: e-mail address of the service account

:type project_id: str
:param project_id: (Optional) Explicit project ID for the key.
    Defaults to the client's project.

:type user_project: str
:param user_project: (Optional) This parameter is currently ignored.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry: (Optional) How to retry the RPC. A None value will disable retries.
    A google.api_core.retry.Retry value will enable retries, and the object will
    define retriable response codes and errors and configure backoff and timeout options.

    A google.cloud.storage.retry.ConditionalRetryPolicy value wraps a Retry object and
    activates it only if certain conditions are met. This class exists to provide safe defaults
    for RPC calls that are not technically safe to retry normally (due to potential data
    duplication or other side-effects) but become safe to retry if a condition such as
    if_metageneration_match is set.

    See the retry.py source code and docstrings in this package (google.cloud.storage.retry) for
    information on retry types and how to configure them.

:rtype:
    Tuple[:class:`~google.cloud.storage.hmac_key.HMACKeyMetadata`, str]
:returns: metadata for the created key, plus the bytes of the key's secret, which is an 40-character base64-encoded string.
zStorage.Client.createHmacKeyrq   Nrs   	/hmacKeysserviceAccountEmailr   r  metadatasecret)r   r.   r   r    r   )rH   service_account_email
project_idr~   ru   rv   ry   	qs_paramsrz   r  r  s              rP   create_hmac_keyClient.create_hmac_keyM  s    V $BC!!\\

|95D.0EFI'+7-(..& / L 't,H#/
#;H !(+F#) DCCs   AA$$
A2c           
          [        SS9   Uc  U R                  nSU S3n0 n	Ub  X)S'   Ub  X9S'   Ub  XYS'   U R                  U[        UU	UUS	9sSSS5        $ ! , (       d  f       g= f)
a  List HMAC keys for a project.

:type max_results: int
:param max_results:
    (Optional) Max number of keys to return in a given page.

:type service_account_email: str
:param service_account_email:
    (Optional) Limit keys to those created by the given service account.

:type show_deleted_keys: bool
:param show_deleted_keys:
    (Optional) Included deleted keys in the list. Default is to
    exclude them.

:type project_id: str
:param project_id: (Optional) Explicit project ID for the key.
    Defaults to the client's project.

:type user_project: str
:param user_project: (Optional) This parameter is currently ignored.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC. See: :ref:`configuring_retries`

:rtype:
    Tuple[:class:`~google.cloud.storage.hmac_key.HMACKeyMetadata`, str]
:returns: metadata for the created key, plus the bytes of the key's secret, which is an 40-character base64-encoded string.
zStorage.Client.listHmacKeysrq   Nrs   r  r  showDeletedKeysr   )r   r   ru   rv   )r   r.   r   _item_to_hmac_key_metadata)
rH   r   r  show_deleted_keysr  r~   ru   rv   ry   r   s
             rP   list_hmac_keysClient.list_hmac_keys  s    Z $AB!!\\

|95DL$06K23 ,2C./'.:]+&&*') ' ! CBBs   AA
A&c                     [        SS9   [        XX#5      nUR                  US9  UsSSS5        $ ! , (       d  f       g= f)a  Return a metadata instance for the given HMAC key.

:type access_id: str
:param access_id: Unique ID of an existing key.

:type project_id: str
:param project_id: (Optional) Project ID of an existing key.
    Defaults to client's project.

:type timeout: float or tuple
:param timeout:
    (Optional) The amount of time, in seconds, to wait
    for the server response.  See: :ref:`configuring_timeouts`

:type user_project: str
:param user_project: (Optional) This parameter is currently ignored.
z!Storage.Client.getHmacKeyMetadatarq   )ru   N)r   r    r   )rH   	access_idr  r~   ru   r  s         rP   get_hmac_key_metadataClient.get_hmac_key_metadata  s7    ( $GH&t
QHOOGO, IHHs   1
?c           
      &   U(       a  U(       a  [        S5      eUc  U R                  OUnU
nU(       a  U
(       d  [        U5        UR                  n[	        5       u  pSR                  XS9nSU0SU0SU0SU0S	S
0/nU=(       d    / n0 n[        U=(       d    0 R                  5       5       H6  u  nnUR                  S5      (       a  M  UUU'   UR                  UU05        M8     UU-  n[        [        5      R                  SS9nUc  U[        R                  " SS9-   nU[        R                  " [        U5      S9-   n[         R"                  " [$        R&                  " [        UUR)                  5       S-   S.R                  5       5      5      SS9n[*        R,                  " UR/                  S5      5      nU(       a*  U
(       a#  [1        UX5      n[*        R2                  " U5      nOUR5                  U5      n[6        R8                  " U5      R;                  S5      nUR=                  US
UUUUR;                  S5      S.5        U(       a  [?        U R@                  USS9nO(U(       a  [C        X5       S3nOU R@                   SU S3nUUS.$ )a\	  Generate a V4 signed policy object. Generated policy object allows user to upload objects with a POST request.

.. note::

    Assumes ``credentials`` implements the
    :class:`google.auth.credentials.Signing` interface. Also assumes
    ``credentials`` has a ``service_account_email`` property which
    identifies the credentials.

See a [code sample](https://github.com/googleapis/python-storage/blob/main/samples/snippets/storage_generate_signed_post_policy_v4.py).

:type bucket_name: str
:param bucket_name: Bucket name.

:type blob_name: str
:param blob_name: Object name.

:type expiration: Union[Integer, datetime.datetime, datetime.timedelta]
:param expiration: Policy expiration time. If a ``datetime`` instance is
                   passed without an explicit ``tzinfo`` set,  it will be
                   assumed to be ``UTC``.

:type conditions: list
:param conditions: (Optional) List of POST policy conditions, which are
                   used to restrict what is allowed in the request.

:type fields: dict
:param fields: (Optional) Additional elements to include into request.

:type credentials: :class:`google.auth.credentials.Signing`
:param credentials: (Optional) Credentials object with an associated private
                    key to sign text.

:type virtual_hosted_style: bool
:param virtual_hosted_style:
    (Optional) If True, construct the URL relative to the bucket
    virtual hostname, e.g., '<bucket-name>.storage.googleapis.com'.
    Incompatible with bucket_bound_hostname.

:type bucket_bound_hostname: str
:param bucket_bound_hostname:
    (Optional) If passed, construct the URL relative to the bucket-bound hostname.
    Value can be bare or with a scheme, e.g., 'example.com' or 'http://example.com'.
    Incompatible with virtual_hosted_style.
    See: https://cloud.google.com/storage/docs/request-endpoints#cname

:type scheme: str
:param scheme:
    (Optional) If ``bucket_bound_hostname`` is passed as a bare hostname, use
    this value as a scheme. ``https`` will work only when using a CDN.
    Defaults to ``"http"``.

:type service_account_email: str
:param service_account_email: (Optional) E-mail address of the service account.

:type access_token: str
:param access_token: (Optional) Access token for a service account.

:raises: :exc:`ValueError` when mutually exclusive arguments are used.

:rtype: dict
:returns: Signed POST policy.
zLOnly one of virtual_hosted_style and bucket_bound_hostname can be specified.Nz.{email}/{datestamp}/auto/storage/goog4_request)email	datestampr   r   x-goog-datex-goog-credentialx-goog-algorithmzGOOG4-RSA-SHA256z	x-ignore-)tzinfor   )hours)secondsZ)
conditions
expiration),:)
separatorszutf-8)r   r#  r"  r!  zx-goog-signaturepolicyT)trailing_slash/)urlr   )"r?   rD   r   signer_emailr   r@   sorteditems
startswithappendr   r   replacedatetime	timedeltar   jsondumpscollectionsOrderedDict	isoformatbase64	b64encodeencoder   	b64decode
sign_bytesbinasciihexlifydecodeupdater   r-   r	   )rH   r   	blob_namer)  r(  r   r/   virtual_hosted_stylebucket_bound_hostnameschemer  access_tokenclient_email	timestampr   x_goog_credentialrequired_conditionspolicy_fieldsr   rc   nowpolicy_expiresr-  str_to_sign	signaturesignature_bytesr0  s                              rP   generate_signed_post_policy_v4%Client.generate_signed_post_policy_v4  s   Z  $9$ 
 ,7+>d''K,#8%k2&33L  34	LSS T 
 {#II& "34!34
  %2
 &,B!5!5!78JC>>+..%*c"!!3,/ 9
 	))
 4j   -x11::Jx11-j9 
 

 ##&0&4&>&>&@3&F eg	 "

 &&v}}W'=> 1%k<WI$..y9O)44[AO $$_5<<WE	 $6%6($-%,,W5		
  0!!;tC #/0ENOqQC&&'qQ7Cm44rR   )	r4   rG   rF   r8   r6   r7   rA   r>   r.   )NN)TrY   )NNNFNhttpNN)-__name__
__module____qualname____firstlineno____doc__SCOPEr5   rC   classmethodrV   propertyr,   r-   rF   setterrg   rk   r`   r#   r$   r{   r   rf   rx   r   _do_nothing_page_startr   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  rV  __static_attributes____classcell__)rO   s   @rP   r&   r&   C   s   1fE
 N #'T* T* T*l   A A - - 
) 
) & & &	' % % $4M1:
8C,  @
L  77 $
T  E
V  E
V  F
V  @
DF ! $$(Q Ql ! $$(.f &* % Pl   $ $$( md #' $(%|@  s sr  $$( ?H  ?$F " DN %)tEU< """e5 e5rR   r&   c                 v    UR                  S5      n[        U R                  U5      nUR                  U5        U$ )a.  Convert a JSON bucket to the native object.

:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that has retrieved the item.

:type item: dict
:param item: An item to be converted to a bucket.

:rtype: :class:`.Bucket`
:returns: The next bucket in the page.
rr   )getr   rU   r   )r   itemrr   r   s       rP   r  r    s5     88FDHOOT*F
4 MrR   c                 <    [        U R                  5      nXl        U$ )a  Convert a JSON key metadata resource to the native object.

:type iterator: :class:`~google.api_core.page_iterator.Iterator`
:param iterator: The iterator that has retrieved the item.

:type item: dict
:param item: An item to be converted to a key metadata instance.

:rtype: :class:`~google.cloud.storage.hmac_key.HMACKeyMetadata`
:returns: The next key metadata instance in the page.
)r    rU   r   )r   rg  r  s      rP   r  r    s     x/HOrR   )@r]  r>  rC  r;  r7  r   r9  r   google.api_core.client_optionsr;   google.auth.credentialsr   google.api_corer   google.cloud._helpersr   google.cloud.clientr   google.cloud.exceptionsr   google.cloud.storage._helpersr   r	   r
   r   r   r   r   r   r   r   r   r   +google.cloud.storage._opentelemetry_tracingr   google.cloud.storage._httpr   google.cloud.storage._signingr   r   r   r   google.cloud.storage.batchr   google.cloud.storage.bucketr   r   r   google.cloud.storage.blobr   google.cloud.storage.hmac_keyr    google.cloud.storage.aclr!   r"   google.cloud.storage.constantsr#   google.cloud.storage.retryr$   objectr5   r&   r  r   rR   rP   <module>r|     s    @        % 8 ) - 1 , J D D > H : H B 9 @ . . I 1  - P P * 9 . 5 ; 4 (O5 O5d:$rR   