
    (ph~
                       S 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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rSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSKJ#r#  SSK$J%r%  SSK&J'r'  SSK&J(r(  SSK&J)r)  SSK&J*r*  SSK&J+r+  SSK&J,r,  SSK&J-r-  SSK&J.r.  SS K/J0r0  SS!K/J1r1  SS"K&J2r2  SS#K&J3r3  SS$K4J5r5  SS%K6J7r7  SS&K6J8r8  SS'K9J:r:  SS(K9J;r;  SS)K9J<r<  SS*K9J=r=  SS+K9J>r>  SS,K9J?r?  SS-K9J@r@  SS.KAJBrB  SS/KAJCrC  SS0KDJErE  SS1KDJFrF  SS2KDJGrG  SS3KDJHrH  SS4KIJJrJ  SS5KIJKrK  S6rLS7rMS8rN\NS9-   rO\NS:-   rPS;rQS<S=S>S?\QS@SASBSCSDSESF4rRSGrSSHrTSIrUSJrVSKrWSLrXSMrYSNrZ\
R                  " SO5      r\SPr]SQr^\R                  " \`5      ra " SR SS\)5      rbST rcS\SU jrdS]SV jreS\SW jrfSX rgSY rh " SZ S[\i5      rjg)^z3Create / interact with Google Cloud Storage blobs.
    N)BytesIO)TextIOWrapper)HeaderParser)	parse_qsl)quote)	urlencode)urlsplit)
urlunsplit)ChunkedDownload)Download)RawDownload)RawChunkedDownload)MultipartUpload)ResumableUpload)Policy)
exceptions)_bytes_to_unicode)_datetime_to_rfc3339)_rfc3339_nanos_to_datetime)	_to_bytes)NotFound)_add_etag_match_headers) _add_generation_match_parameters)_PropertyMixin)_scalar_property)_bucket_bound_hostname_url)_raise_if_more_than_one_set)_get_default_headers)_get_default_storage_base_url)generate_signed_url_v2)generate_signed_url_v4)_API_VERSION)_virtual_hosted_style_base_url)create_trace_span)ACL)	ObjectACL)_DEFAULT_TIMEOUT)ARCHIVE_STORAGE_CLASS)COLDLINE_STORAGE_CLASS)#MULTI_REGIONAL_LEGACY_STORAGE_CLASS)NEARLINE_STORAGE_CLASS)REGIONAL_LEGACY_STORAGE_CLASS)STANDARD_STORAGE_CLASS)DataCorruption)InvalidResponse)ConditionalRetryPolicy)DEFAULT_RETRY)DEFAULT_RETRY_IF_ETAG_IN_JSON)%DEFAULT_RETRY_IF_GENERATION_SPECIFIED)
BlobReader)
BlobWriterzapplication/octet-streamz9{hostname}/download/storage/{api_version}{path}?alt=mediazB{hostname}/upload/storage/{api_version}{bucket_path}/o?uploadType=	multipart	resumablecontentTypecacheControlcontentDispositioncontentEncodingcontentLanguagecrc32c
customTimemd5Hashmetadataname	retentionstorageClasszOSize {:d} was specified but the file-like object only had {:d} bytes remaining.znA checksum of type `{}` was requested, but checksumming is not available for downloads when chunk_size is set.z'if_generation_match: type list' is deprecated and supported for backwards-compatability reasons only.  Use 'if_source_generation_match' instead' to match source objects' generations.zUse 'if_generation_match' to match the generation of the destination object by passing in a generation number, instead of a list. Use 'if_source_generation_match' to match source objects generations.z'if_metageneration_match: type list' is deprecated and supported for backwards-compatability reasons only. Note that the metageneration to be matched is that of the destination blob. Please pass in a single value (type long).zH'if_source_generation_match' length must be the same as 'sources' lengthzlBlob.download_as_string() is deprecated and will be removed in future. Use Blob.download_as_bytes() instead.z\Blob.from_string() is deprecated and will be removed in future. Use Blob.from_uri() instead.zB(?P<scheme>gs)://(?P<bucket_name>[a-z0-9_.-]+)/(?P<object_name>.+)i  @i   c                   $  ^  \ rS rSrSrSrSr \\\	\
\\4r     S]U 4S jjr\S 5       r\S 5       r\R$                  S 5       r\S	 5       r\R$                  S
 5       r\S 5       r\S 5       rS r\S 5       r\S 5       r\S 5       rS r\S 5       r\S 5       r\S^S j5       r\S^S j5       r                   S_S jr!SSSSSSS\"\#S4
S jr$SSSSS\"\#4S jr%S r&    S]S jr'S r(SSS\"S\#4S jr)SSSSSSSSSS\"S\#4S jr*S  r+S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\#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\"\#4S$ jr/S^S% jr0S& r1S`S' jr2\"SSS4S( jr3SSSSSSS\"SSS4S) jr4\"SSS4S* jr5\"SSS4S+ jr6SSSSSSSSS\"S\#S4S, jr7SSSSSSSSS\"S\#4S- jr8S^S. jr9SSSSSSS\"S\#4
S/ jr:S0SSSSSS\"S\#4
S1 jr;SSSS\"SSSSSS\#4S2 jr<SS\"\#4S3 jr=S\"\>4S4 jr?S\"\#4S5 jr@S\"SSSS\#4S6 jrAS\"SSSS\#4S7 jrBS\"SSS\C4S8 jrDSSSSSSSSSS\"\C4S9 jrESSSSSSSSS\"\C4S: jrF      SaS; jrG\H" S<5      rI \H" S=5      rJ \H" S>5      rK \H" S?5      rL \H" \M5      rN \H" S@5      rO SSSSSSSSSS\"S\#S4SA jrP\SB 5       rQ\SC 5       rR\H" SD5      rS \SE 5       rT\SF 5       rU\H" SG5      rV \SH 5       rW\SI 5       rX\XR$                  SJ 5       rX\SK 5       rY\SL 5       rZ\SM 5       r[\SN 5       r\\SO 5       r]\SP 5       r^\^R$                  SQ 5       r^\H" SR5      r_ \H" SS5      r` \ST 5       ra\SU 5       rb\SV 5       rc\SW 5       rd\dR$                  SX 5       rd\SY 5       re\SZ 5       rf\S[ 5       rgS\rhU =ri$ )bBlob   a  A wrapper around Cloud Storage's concept of an ``Object``.

:type name: str
:param name: The name of the blob.  This corresponds to the unique path of
             the object in the bucket. If bytes, will be converted to a
             unicode object. Blob / object names can contain any sequence
             of valid unicode characters, of length 1-1024 bytes when
             UTF-8 encoded.

:type bucket: :class:`google.cloud.storage.bucket.Bucket`
:param bucket: The bucket to which this blob belongs.

:type chunk_size: int
:param chunk_size:
    (Optional) The size of a chunk of data whenever iterating (in bytes).
    This must be a multiple of 256 KB per the API specification. If not
    specified, the chunk_size of the blob itself is used. If that is not
    specified, a default value of 40 MB is used.

:type encryption_key: bytes
:param encryption_key:
    (Optional) 32 byte encryption key for customer-supplied encryption.
    See https://cloud.google.com/storage/docs/encryption#customer-supplied.

:type kms_key_name: str
:param kms_key_name:
    (Optional) Resource name of Cloud KMS key used to encrypt the blob's
    contents.

:type generation: long
:param generation:
    (Optional) If present, selects a specific revision of this object.
Ni   c                    > [        U5      n[        [        U ]  US9  X0l        X l        [        U 5      U l        [        XES9  X@l	        Ub  XPR                  S'   Ub  X`R                  S'   gg)z0
property :attr:`name`
    Get the blob's name.
rA   )encryption_keykms_key_nameN
kmsKeyName
generation)r   superrE   __init__
chunk_size_bucketr&   _aclr   _encryption_key_properties)selfrA   bucketrO   rI   rJ   rL   	__class__s          L/var/www/html/venv/lib/python3.13/site-packages/google/cloud/storage/blob.pyrN   Blob.__init__   sv     !&dD""-$dO	#)	
  .#-9\*!-7\* "    c                     U R                   $ )zwBucket which contains the object.

:rtype: :class:`~google.cloud.storage.bucket.Bucket`
:returns: The object's bucket.
)rP   rT   s    rW   rU   Blob.bucket   s     ||rY   c                     U R                   $ )zwGet the blob's default chunk size.

:rtype: int or ``NoneType``
:returns: The current blob's chunk size, if it is set.
)_chunk_sizer[   s    rW   rO   Blob.chunk_size   s     rY   c                 x    Ub1  US:  a+  XR                   -  S:w  a  [        SU R                   4-  5      eXl        g)zSet the blob's default chunk size.

:type value: int
:param value: (Optional) The current blob's chunk size, if it is set.

:raises: :class:`ValueError` if ``value`` is not ``None`` and is not a
         multiple of 256 KB.
Nr   z$Chunk size must be a multiple of %d.)_CHUNK_SIZE_MULTIPLE
ValueErrorr^   rT   values     rW   rO   r_     sG     u7P7P/PTU/U6$:S:S9UU  !rY   c                     U R                   $ )zRetrieve the customer-supplied encryption key for the object.

:rtype: bytes or ``NoneType``
:returns:
    The encryption key or ``None`` if no customer-supplied encryption key was used,
    or the blob's resource has not been loaded from the server.
rR   r[   s    rW   rI   Blob.encryption_key  s     ###rY   c                     Xl         g)aj  Set the blob's encryption key.

See https://cloud.google.com/storage/docs/encryption#customer-supplied

To perform a key rotation for an encrypted blob, use :meth:`rewrite`.
See https://cloud.google.com/storage/docs/encryption/using-customer-supplied-keys?hl=ca#rotating

:type value: bytes
:param value: 32 byte encryption key for customer-supplied encryption.
Nrf   rc   s     rW   rI   rg     s
      %rY   c                 $    U S-   [        U5      -   $ )zRelative URL path for a blob.

:type bucket_path: str
:param bucket_path: The URL path for a bucket.

:type blob_name: str
:param blob_name: The name of the blob.

:rtype: str
:returns: The relative URL path for ``blob_name``.
z/o/)_quote)bucket_path	blob_names     rW   path_helperBlob.path_helper+  s     U"VI%666rY   c                     U R                   $ )zCreate our ACL on demand.)rQ   r[   s    rW   aclBlob.acl:  s     yyrY   c                     U R                   (       a  U R                   R                  nOS nSU SU R                   SU R                   S3$ )Nz<Blob: z, >)rU   rA   rL   )rT   bucket_names     rW   __repr__Blob.__repr__?  sA    ;;++**KKR		{"T__4EQGGrY   c                     U R                   (       d  [        S5      eU R                  U R                  R                  U R                   5      $ )zaGetter property for the URL path to this Blob.

:rtype: str
:returns: The URL path to this Blob.
z*Cannot determine path without a blob name.)rA   rb   rm   rU   pathr[   s    rW   rx   	Blob.pathG  s8     yyIJJ 0 0$))<<rY   c                 .    U R                   R                  $ )zThe client bound to this blob.)rU   clientr[   s    rW   r{   Blob.clientS  s     {{!!!rY   c                 .    U R                   R                  $ )zbProject ID billed for API requests made via this blob.

Derived from bucket's value.

:rtype: str
)rU   user_projectr[   s    rW   r~   Blob.user_projectX  s     {{'''rY   c                 ,    [        U R                  5      $ )zReturn any encryption headers needed to fetch the object.

:rtype: List(Tuple(str, str))
:returns: a list of tuples to be passed as headers.
)_get_encryption_headersrR   r[   s    rW   _encryption_headersBlob._encryption_headersb  s     't';';<<rY   c                 z    0 nU R                   b  U R                   US'   U R                  b  U R                  US'   U$ )zDefault query parameters.rL   userProject)rL   r~   )rT   paramss     rW   _query_paramsBlob._query_paramsj  sB     ??&#'??F< ($($5$5F=!rY   c           	          U R                   (       a  U R                   R                  nO
[        5       nSR                  UU R                  R
                  [        U R
                  SS9S9$ )zThe public URL for this blob.

Use :meth:`make_public` to enable anonymous access via the returned
URL.

:rtype: `string`
:returns: The public URL for this blob.
z.{storage_base_url}/{bucket_name}/{quoted_name}   /~safe)storage_base_urlrt   quoted_name)r{   api_endpointr   formatrU   rA   rj   )rT   endpoints     rW   
public_urlBlob.public_urlt  sY     ;;{{//H46H?FF%((tyyu5 G 
 	
rY   c                     SSK Jn  [        R                  U5      nU(       d  [	        S5      eU" X$R                  S5      S9nU " UR                  S5      U5      $ )a  Get a constructor for blob object by URI.

.. code-block:: python

    from google.cloud import storage
    from google.cloud.storage.blob import Blob
    client = storage.Client()
    blob = Blob.from_uri("gs://bucket/object", client=client)

:type uri: str
:param uri: The blob uri following a gs://bucket/object pattern.
  Both a bucket and object name is required to construct a blob object.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  Application code should
    *always* pass ``client``.

:rtype: :class:`google.cloud.storage.blob.Blob`
:returns: The blob object created.
r   )Bucketz&URI pattern must be gs://bucket/objectrt   rH   object_name)google.cloud.storage.bucketr   _GS_URL_REGEX_PATTERNmatchrb   group)clsurir{   r   r   rU   s         rW   from_uriBlob.from_uri  sO    . 	7%++C0EFF[[%?@5;;}-v66rY   c                 d    [         R                  " [        [        SS9  [        R                  XS9$ )a  (Deprecated) Get a constructor for blob object by URI.

.. note::
   Deprecated alias for :meth:`from_uri`.

.. code-block:: python

    from google.cloud import storage
    from google.cloud.storage.blob import Blob
    client = storage.Client()
    blob = Blob.from_string("gs://bucket/object", client=client)

:type uri: str
:param uri: The blob uri following a gs://bucket/object pattern.
  Both a bucket and object name is required to construct a blob object.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  Application code should
    *always* pass ``client``.

:rtype: :class:`google.cloud.storage.blob.Blob`
:returns: The blob object created.
   
stacklevel)r   r{   )warningswarn_FROM_STRING_DEPRECATEDPendingDeprecationWarningrE   r   )r   r   r{   s      rW   from_stringBlob.from_string  s(    4 	-/HUVW}}}44rY   Fc                    Uc  SnOUS;  a  [        S5      eUc  U(       a  U(       a  [        S5      eUc  U R                  U5      nUR                  n[        U R                  SS9nU(       a%  [        X R                  R                  5      nSU 3nO5U(       a  [        UU5      nSU 3nOSU R                  R                   SU 3nUc  U R                  U5      nUR                  nU R                  U5      nUR                  nUS:X  a  [        nO[        nU R                  b<  [        U R                  5      nU	c  0 n	US:X  a  SnUU   U	U'   OU	R                  U5        U" UUUUUR                  5       UUUUUU	U
UUUS	9$ )
a  Generates a signed URL for this blob.

.. note::

    If you are on Google Compute Engine, you can't generate a signed
    URL using GCE service account.
    If you'd like to be able to generate a signed URL from GCE,
    you can use a standard service account from a JSON file rather
    than a GCE service account.

If you have a blob that you want to allow access to for a set
amount of time, you can use this method to generate a URL that
is only valid within a certain time period.

See a [code sample](https://cloud.google.com/storage/docs/samples/storage-generate-signed-url-v4#storage_generate_signed_url_v4-python).

This is particularly useful if you don't want publicly
accessible blobs, but don't want to require users to explicitly
log in.

If ``bucket_bound_hostname`` is set as an argument of :attr:`api_access_endpoint`,
``https`` works only if using a ``CDN``.

:type expiration: Union[Integer, datetime.datetime, datetime.timedelta]
:param expiration:
    Point in time when the signed URL should expire. If a ``datetime``
    instance is passed without an explicit ``tzinfo`` set,  it will be
    assumed to be ``UTC``.

:type api_access_endpoint: str
:param api_access_endpoint: (Optional) URI base, for instance
    "https://storage.googleapis.com". If not specified, the client's
    api_endpoint will be used. Incompatible with bucket_bound_hostname.

:type method: str
:param method: The HTTP verb that will be used when requesting the URL.

:type content_md5: str
:param content_md5:
    (Optional) The MD5 hash of the object referenced by ``resource``.

:type content_type: str
:param content_type:
    (Optional) The content type of the object referenced by
    ``resource``.

:type response_disposition: str
:param response_disposition:
    (Optional) Content disposition of responses to requests for the
    signed URL.  For example, to enable the signed URL to initiate a
    file of ``blog.png``, use the value ``'attachment;
    filename=blob.png'``.

:type response_type: str
:param response_type:
    (Optional) Content type of responses to requests for the signed
    URL. Ignored if content_type is set on object/blob metadata.

:type generation: str
:param generation:
    (Optional) A value that indicates which generation of the resource
    to fetch.

:type headers: dict
:param headers:
    (Optional) Additional HTTP headers to be included as part of the
    signed URLs. See:
    https://cloud.google.com/storage/docs/xml-api/reference-headers
    Requests using the signed URL *must* pass the specified header
    (name and value) with each request for the URL.

:type query_parameters: dict
:param query_parameters:
    (Optional) Additional query parameters to be included as part of the
    signed URLs. See:
    https://cloud.google.com/storage/docs/xml-api/reference-headers#query

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type credentials: :class:`google.auth.credentials.Credentials`
:param credentials:
    (Optional) The authorization credentials to attach to requests.
    These credentials identify this application to the service.  If
    none are specified, the client will attempt to ascertain the
    credentials from the environment.

:type version: str
:param version:
    (Optional) The version of signed credential to create.  Must be one
    of 'v2' | 'v4'.

: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.

:type virtual_hosted_style: bool
:param virtual_hosted_style:
    (Optional) If true, then construct the URL relative the bucket's
    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, then construct the URL relative to the bucket-bound hostname.
    Value can be a bare or with scheme, e.g., 'example.com' or 'http://example.com'.
    Incompatible with api_access_endpoint and 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 the scheme.  ``https`` will work only
    when using a CDN.  Defaults to ``"http"``.

:raises: :exc:`ValueError` when version is invalid or mutually exclusive arguments are used.
:raises: :exc:`TypeError` when expiration is not a valid type.
:raises: :exc:`AttributeError` if credentials is not an instance
        of :class:`google.auth.credentials.Signing`.

:rtype: str
:returns: A signed URL you can use to access the resource
          until expiration.
v2)r   v4z%'version' must be either 'v2' or 'v4'zmThe bucket_bound_hostname argument is not compatible with either api_access_endpoint or virtual_hosted_style.r   r   /zX-Goog-Encryption-Algorithm)resource
expirationapi_access_endpointmethodcontent_md5content_typeresponse_typeresponse_dispositionrL   headersquery_parametersservice_account_emailaccess_tokenuniverse_domain)rb   _require_clientr   rj   rA   r#   rU   r   _credentialsr   r    r!   rR   r   updateupper)rT   r   r   r   r   r   r   r   rL   r   r   r{   credentialsversionr   r   virtual_hosted_stylebucket_bound_hostnameschemer   r   r   helperencryption_headersv2_copy_onlys                            rW   generate_signed_urlBlob.generate_signed_url  s   l ?GL(DEE  +/C#F 
 &))&1F"("5"5TYYU3
  "@#[[%5%5# ;-(H""<%v# ;-(H4;;++,Ak];H))&1F --K%%f- 00d?+F+F+!89M9M!N$<(:<(H%12! 3<<>#%'!5!-"7%+
 	
rY   c           
      @   [        SS9   U R                  U5      nU R                  nSUS'   U
b  XS'   [        UUUUUS9  0 n[	        UUUS9   UR                  U R                  UUUU	SS	9   SSS5        g! [         a     SSS5        g
f = f! , (       d  f       g= f)a  Determines whether or not this blob exists.

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

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

: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, looks for a soft-deleted object. Will only return True
    if the object exists and is in a soft-deleted state.
    :attr:`generation` is required to be set on the blob if ``soft_deleted`` is set to True.
    See: https://cloud.google.com/storage/docs/soft-delete

:rtype: bool
:returns: True if the blob exists in Cloud Storage.
zStorage.Blob.existsrH   rA   fieldsNsoftDeletedif_generation_matchif_generation_not_matchif_metageneration_matchif_metageneration_not_matchif_etag_matchif_etag_not_matchquery_paramsr   timeoutretry_target_objectFT)r$   r   r   r   r   _get_resourcerx   r   )rT   r{   r   r   r   r   r   r   r   r   soft_deletedr   r   s                rW   existsBlob.exists  s    D $9:))&1F  --L%+L"'.:]+,$7(?(?,G G#+"3 $$II!-###' %  Q ;:F   O ;:FG ;:s0   ABA7-B7
BBBB
Bc                     [        SS9   U R                  R                  U R                  UU R                  UUUUUUS9	  SSS5        g! , (       d  f       g= f)a  Deletes a blob from Cloud Storage.

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

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

: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_generation_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.

:raises: :class:`google.cloud.exceptions.NotFound`
         (propagated from
         :meth:`google.cloud.storage.bucket.Bucket.delete_blob`).
zStorage.Blob.deleterH   )r{   rL   r   r   r   r   r   r   N)r$   rU   delete_blobrA   rL   )rT   r{   r   r   r   r   r   r   s           rW   deleteBlob.delete  sT    | $9:KK##		??$7(?(?,G $ 
 ;::s   6A		
Ac                 <    U R                  U5      nUR                  $ )a  Return the client's transport.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:rtype transport:
    :class:`~google.auth.transport.requests.AuthorizedSession`
:returns: The transport (with credentials) that will
          make authenticated requests.
)r   _http)rT   r{   s     rW   _get_transportBlob._get_transport]  s     %%f-||rY   c                    / nU R                   cd  [        UR                  5      n[        R	                  XpR
                  [        S9nU R                  b  UR                  SU R                  S 45        OU R                   nU R                  b  UR                  SU R                  45        [        UUUUUS9  [        X5      $ )ah  Get the download URL for the current blob.

If the ``media_link`` has been loaded, it will be used, otherwise
the URL will be constructed from the current blob's path (and possibly
generation) to avoid a round trip.

:type client: :class:`~google.cloud.storage.client.Client`
:param client: The client to use.

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

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

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

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

:rtype: str
:returns: The download URL for the current blob.
)hostnamerx   api_versionrL   dr   r   )
media_link_get_host_name_connection_DOWNLOAD_URL_TEMPLATEr   rx   r"   rL   appendr~   r   _add_query_parameters)	rT   r{   r   r   r   r   name_value_pairsr   base_urls	            rW   _get_download_urlBlob._get_download_urlm  s    H ??"%f&8&89H-44!		| 5 H * ''$//!9L(NOH(##]D4E4E$FG( 3$;$;(C	
 %X@@rY   c                     UR                   R                  SS5      U R                  S'   UR                   R                  SS5      U R                  [        '   UR                   R                  SS5      U R                  S'   UR                   R                  SS5      U R                  S'   UR                   R                  S	S5      U R                  S
'   UR                   R                  SS5      U R                  S'   UR                   R                  SS5      U R                  S'   UR                   R                  SS5      U R                  S'   UR                   R                  SS5      nU(       a  0 nUR	                  S5       H9  n[
        R                  " SU5      nU(       d  M#  UR                  5       u  pgXsU'   M;     UR                  SS5      U R                  S'   UR                  SS5      U R                  S'   gg)a  Extract headers from a non-chunked request's http object.

This avoids the need to make a second request for commonly used
headers.

:type response:
    :class requests.models.Response
:param response: The server response from downloading a non-chunked file
zContent-EncodingNr;   zContent-TypezCache-Controlr9   zX-Goog-Storage-ClassrC   zContent-Languager<   ETagetagzX-goog-generationrL   zX-goog-metagenerationmetagenerationzX-Goog-Hash ,z (crc32c|md5)=([\w\d/\+/]+={0,3})r=   md5r?   )r   getrS   _CONTENT_TYPE_FIELDsplitrer   groups)rT   responsex_goog_hashdigestsencoded_digestr   r   digests           rW   _extract_headers_from_download#Blob._extract_headers_from_download  s    /7.>.>.B.B/
*+ 190@0@0D0DD1
,- ,4+;+;+?+?QU+V(+3+;+;+?+?"D,
( /7.>.>.B.B/
*+ $,#3#3#7#7#E )1)9)9)=)=>QSW)X&-5-=-=-A-A#T.
)* &&**="=G"-"3"3C"8!DnU5%*\\^NF&,FO	 #9 *1Xt)DDX&*1++eT*BDY' rY   autoc           
         UU R                    UU	 S.nSU0nU R                   c]  U(       a	  [        nSnO[        nSnU" UUUUUU	U
S9n[        SU S3UUS	9   UR	                  XS
9nU R                  U5        SSS5        gU	(       a*  [        R                  U	5      n[        R                  U5        U(       a	  [        nSnO[        nSnU" UU R                   UUU(       a  UOSUU
S9n[        SU S3UUS	9   UR                  (       d"  UR                  XS
9  UR                  (       d  M"  SSS5        g! , (       d  f       g= f! , (       d  f       g= f)a  Perform a download without any error handling.

This is intended to be called by :meth:`_prep_and_do_download` so it can
be wrapped with error handling / remapping.

:type transport:
    :class:`~google.auth.transport.requests.AuthorizedSession`
:param transport:
    The transport (with credentials) that will make authenticated
    requests.

:type file_obj: file
:param file_obj: A file handle to which to write the blob's data.

:type download_url: str
:param download_url: The URL where the media can be accessed.

:type headers: dict
:param headers: Headers to be sent with the request(s).

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

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

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

: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 checksum: str
:param checksum:
    (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.

:type retry: google.api_core.retry.Retry
: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 configure backoff and timeout options.

    This private method does not accept ConditionalRetryPolicy values
    because the information necessary to evaluate the policy is instead
    evaluated in blob._prep_and_do_download().

    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.
)url.fullzdownload.chunk_sizezdownload.raw_downloadupload.checksumr   Nr   r   )streamr   startendchecksumr   zStorage.z/consume)rA   
attributesapi_requestr   r   r   r   )r   r
  r  r   z/consumeNextChunk)rO   r   r   r$   consumer  "_CHUNKED_DOWNLOAD_CHECKSUM_MESSAGEr   _loggerinfor   r   finishedconsume_next_chunk)rT   	transportfile_objdownload_urlr   r
  r  raw_downloadr   r  r   extra_attributesargsklassdownload_classdownloadr   msgs                     rW   _do_downloadBlob._do_download  s   V %&*oo%6%1"*	
 7#??"#!. !+!H #/x8+ 
 $++I+G33H=  8??IS!*!5'!2$e!H #//@A+ 
 #++//	/K #+++ ; : s   !D692E6
E
Ec                     [        SS9   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 this blob into a file-like object.

.. note::

   If the server-set property, :attr:`media_link`, is not yet
   initialized, makes an additional API request to load it.

If the :attr:`chunk_size` of a current blob is `None`, will download data
in single download request otherwise it will download the :attr:`chunk_size`
of data in each request.

For more fine-grained control over the download process, check out
[`google-resumable-media`](https://googleapis.dev/python/google-resumable-media/latest/index.html).
For example, this library allows downloading **parts** of a blob rather than the whole thing.

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

:type file_obj: file
:param file_obj: A file handle to which to write the blob's data.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

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

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

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

: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 checksum: str
:param checksum:
    (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.

: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.

:raises: :class:`google.cloud.exceptions.NotFound`
zStorage.Blob.downloadToFilerH   r{   r
  r  r  r   r   r   r   r   r   r   r  r   N)r$   _prep_and_do_download)rT   r  r{   r
  r  r  r   r   r   r   r   r   r   r  r   s                  rW   download_to_fileBlob.download_to_fileZ  sX    b $AB&&)+"3$7(?(?,G! '  CBB   0
>c                 X    [        US5       nU R                  " U/UQ70 UD6  SSS5        U R                  nUb3  UR                  5       n[        R                  " WR                  Xf45        gg! , (       d  f       NQ= f! [        [        4 a    [        R
                  " U5        e f = f)zDownload the contents of this blob into a named file.

:type filename: str
:param filename: A filename to be passed to ``open``.

For *args and **kwargs, refer to the documentation for download_to_filename() for more information.
wbN)
openr$  r.   r   osremoveupdated	timestamputimerA   )rT   filenamer  kwargsr  r-  mtimes          rW   _handle_filename_and_download"Blob._handle_filename_and_download  s    	h%**  & ,,%%'EHHX]]UN3  &% ) 	IIh	s'   B A0B 0
A>:B >B (B)c                     [        SS9   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 this blob into a named file.

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

See a [code sample](https://cloud.google.com/storage/docs/samples/storage-download-encrypted-file#storage_download_encrypted_file-python)
to download a file with a [`customer-supplied encryption key`](https://cloud.google.com/storage/docs/encryption#customer-supplied).

:type filename: str
:param filename: A filename to be passed to ``open``.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

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

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

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

: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 checksum: str
:param checksum:
    (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.

: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.

:raises: :class:`google.cloud.exceptions.NotFound`
zStorage.Blob.downloadToFilenamerH   r#  N)r$   r3  )rT   r0  r{   r
  r  r  r   r   r   r   r   r   r   r  r   s                  rW   download_to_filenameBlob.download_to_filename  sX    N $EF..)+"3$7(?(?,G! /  GFFr'  c                     [        SS9   [        5       nU R                  UUUUUUUUUU	U
UUUS9  UR                  5       sSSS5        $ ! , (       d  f       g= f)af  Download the contents of this blob as a bytes object.

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

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

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

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

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

: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 checksum: str
:param checksum:
    (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.

: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: bytes
:returns: The data stored in this blob.

:raises: :class:`google.cloud.exceptions.NotFound`
zStorage.Blob.downloadAsBytesrH   r#  N)r$   r   r$  getvalue)rT   r{   r
  r  r  r   r   r   r   r   r   r   r  r   string_buffers                  rW   download_as_bytesBlob.download_as_bytesq  sm    F $BC#IM&&)+"3$7(?(?,G! '   !))+' DCCs   6A


Ac                     [         R                  " [        [        SS9  [	        SS9   U R                  UUUUUUUUU	U
UUS9sSSS5        $ ! , (       d  f       g= f)a*
  (Deprecated) Download the contents of this blob as a bytes object.

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

.. note::
   Deprecated alias for :meth:`download_as_bytes`.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

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

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

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

: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: bytes
:returns: The data stored in this blob.

:raises: :class:`google.cloud.exceptions.NotFound`
r   r   zStorage.Blob.downloadAsStringrH   r{   r
  r  r  r   r   r   r   r   r   r   r   N)r   r   _DOWNLOAD_AS_STRING_DEPRECATEDr   r$   r;  )rT   r{   r
  r  r  r   r   r   r   r   r   r   r   s                rW   download_as_stringBlob.download_as_string  si    r 	*,ERS	
 $CD)))+"3$7(?(?,G *  EDDs   A
Ac                    [        SS9   U R                  UUUUUUUU	U
UUUS9nUb  UR                  U5      sSSS5        $ U R                  be  [	        5       R                  SU R                  -   5      n[        UR                  5       SS 5      nSU;   a  UR                  US   5      sSSS5        $ UR                  S5      sSSS5        $ ! , (       d  f       g= f)	a{
  Download the contents of this blob as text (*not* bytes).

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

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

:type encoding: str
:param encoding: (Optional) encoding to be used to decode the
    downloaded bytes.  Defaults to the ``charset`` param of
    attr:`content_type`, or else to "utf-8".

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

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

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

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

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

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

: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: text
:returns: The data stored in this blob, decoded to text.
zStorage.Blob.downloadAsTextrH   r>  NzContent-Type:    charsetutf-8)r$   r;  decoder   r   parsestrdict
get_params)rT   r{   r
  r  r  encodingr   r   r   r   r   r   r   r   datar  r   s                    rW   download_as_textBlob.download_as_textU  s    t $AB)))+"3$7(?(?,G * D #{{8,# CB&   ,"n--.>ARAR.RScnn.qr23&;;vi'89/ CB2 ;;w'3 CBBs   .CA(C4C
Cc                 r    Uc  U R                   nUc  Ub  [        R                  " U5      u  pUc  [        nU$ )a  Determine the content type from the current object.

The return value will be determined in order of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type content_type: str
:param content_type: (Optional) Type of content.

:type filename: str
:param filename:
    (Optional) The name of the file where the content is stored.

:rtype: str
:returns: Type of content gathered from the object.
)r   	mimetypes
guess_type_DEFAULT_CONTENT_TYPE)rT   r   r0  _s       rW   _get_content_typeBlob._get_content_type  sC    & ,,LH$8'228<OL0LrY   c                     SU R                   0nU R                   H   nU[        ;   d  M  U R                  U   X'   M"     U$ )a\  Get the object / blob metadata which is writable.

This is intended to be used when creating a new object / blob.

See the [`API reference docs`](https://cloud.google.com/storage/docs/json_api/v1/objects)
for more information, the fields marked as writable are:

* ``acl``
* ``cacheControl``
* ``contentDisposition``
* ``contentEncoding``
* ``contentLanguage``
* ``contentType``
* ``crc32c``
* ``customTime``
* ``md5Hash``
* ``metadata``
* ``name``
* ``retention``
* ``storageClass``

For now, we don't support ``acl``, access control lists should be
managed directly through :class:`ObjectACL` methods.
rA   )rA   _changes_WRITABLE_FIELDSrS   )rT   object_metadatakeys      rW   _get_writable_metadataBlob._get_writable_metadata  sD    4 "499-==C&&'+'7'7'<$ ! rY   c                     U R                  X#S9n0 [        UR                  R                  X$S9E[	        U R
                  5      EUR                  EnU R                  5       nXVU4$ )a  Get required arguments for performing an upload.

The content type returned will be determined in order of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type content_type: str
:param content_type: Type of content being uploaded (or :data:`None`).

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:rtype: tuple
:returns: A triple of

          * A header dictionary
          * An object metadata dictionary
          * The ``content_type`` as a string (according to precedence)
r0  command)rS  r   r   
user_agentr   rR   _extra_headersrZ  )rT   r{   r   r0  r_  r   rX  s          rW   _get_upload_argumentsBlob._get_upload_arguments	  s|    2 --l-N
"""--|
 &d&:&:;	

 ##
 55755rY   c           	         Uc  UR                  5       nOJUR                  U5      n[        U5      U:  a*  [        R                  U[        U5      5      n[	        U5      eU R                  U5      nU R                  U5      nSU R                  ;   a+  SU R                  ;  a  U R                  R                  S5        U R                  XUS9nUu  nnn[        UR                  5      n[        R                  UU R                  R                  [         S9n/ nU R"                  b  UR%                  SU R"                  45        U R&                  b-  SU R&                  ;  a  UR%                  SU R&                  45        Ub  UR%                  SU45        Ub  UR%                  S	U45        Ub  UR%                  S
U45        Ub  UR%                  SU45        U	b  UR%                  SU	45        [)        UU5      n[+        UUXS9nUU S.nSU
0n[-        SUUUS9   UR/                  UUUX:S9nUsSSS5        $ ! , (       d  f       g= f)a  Perform a multipart upload.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.

:type content_type: str
:param content_type: Type of content being uploaded (or :data:`None`).

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``stream``). If not provided, the upload will be concluded once
    ``stream`` is exhausted (or :data:`None`).

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. The request metadata will be amended
    to include the computed value. Using this option will override a
    manually-set checksum value. 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.
:type retry: google.api_core.retry.Retry
: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 configure backoff and timeout options.

    This private method does not accept ConditionalRetryPolicy values
    because the information necessary to evaluate the policy is instead
    evaluated in blob._do_upload().

    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.

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:rtype: :class:`~requests.Response`
:returns: The "200 OK" response object returned after the multipart
          upload request.
:raises: :exc:`ValueError` if ``size`` is not :data:`None` but the
         ``stream`` has fewer than ``size`` bytes remaining.
Nr@   r^  r   rk   r   r   cryptoKeyVersionsrK   predefinedAclifGenerationMatchifGenerationNotMatchifMetagenerationMatchifMetaGenerationNotMatchr   r  r   )r  r  r   z Storage.MultipartUpload/transmitrA   r  r{   r  r  )readlen_READ_LESS_THAN_SIZEr   rb   r   r   rS   rV  addrb  r   r   _MULTIPART_URL_TEMPLATErU   rx   r"   r~   r   rJ   r   r   r$   transmit)rT   r{   r	  r   sizepredefined_aclr   r   r   r   r   r  r   r_  rK  r  r  r  r   rX  r   r   r   
upload_urluploadr  r  r   s                               rW   _do_multipart_uploadBlob._do_multipart_upload.  s_   H <;;=D;;t$D4y4*11$D	B o%%%f-''/	)))j.MMMj)))&)P15.,!&"4"45*114;;+;+; 2 
 (##]D4E4E$FG )#4+<+<<##\43D3D$EF%##_n$EF*##%8:M$NO".##%;=T$UV".##%<>U$VW&2##+-HI +85EF
 (

 #"*
 7#3'	
 4, ' H 
 
 
s   H33
Ic           
         U R                  U5      nUc  U R                  nUc  [        nU R                  U5      nSU R                  ;   a+  SU R
                  ;  a  U R
                  R                  S5        U R                  XUS9nUu  nnnUb  UR                  U5        [        UR                  5      n[        R                  UU R                  R                  [        S9n/ nU R                   b  UR#                  SU R                   45        U R$                  b-  SU R$                  ;  a  UR#                  SU R$                  45        Ub  UR#                  SU45        Ub  UR#                  SU45        U	b  UR#                  S	U	45        U
b  UR#                  S
U
45        Ub  UR#                  SU45        ['        UU5      n[)        UUUXS9nUR+                  UUUUUSUS9  UU4$ )a>  Initiate a resumable upload.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.

:type content_type: str
:param content_type: Type of content being uploaded (or :data:`None`).

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``stream``). If not provided, the upload will be concluded once
    ``stream`` is exhausted (or :data:`None`).

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

:type extra_headers: dict
:param extra_headers:
    (Optional) Extra headers to add to standard headers.

:type chunk_size: int
:param chunk_size:
    (Optional) Chunk size to use when creating a
    :class:`~google.cloud.storage._media.requests.ResumableUpload`.
    If not passed, will fall back to the chunk size on the
    current blob, if the chunk size of a current blob is also
    `None`, will set the default value.
    The default value of ``chunk_size`` is 100 MB.

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. After the upload is complete, the
    server-computed checksum of the resulting object will be checked
    and google.cloud.storage.exceptions.DataCorruption will be raised on
    a mismatch. On a validation failure, the client will attempt to
    delete the uploaded object automatically. 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.

:type retry: google.api_core.retry.Retry
: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 configure backoff and timeout options.

    This private method does not accept ConditionalRetryPolicy values
    because the information necessary to evaluate the policy is instead
    evaluated in blob._do_upload().

    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.

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:rtype: tuple
:returns:
    Pair of

    * The :class:`~google.cloud.storage._media.requests.ResumableUpload`
      that was created
    * The ``transport`` used to initiate the upload.
r@   r^  re  r   rf  rK   rg  rh  ri  rj  rk  rl  F)total_bytesstream_finalr   )r   rO   _DEFAULT_CHUNKSIZEr   rS   rV  rq  rb  r   r   r   _RESUMABLE_URL_TEMPLATEr   rU   rx   r"   r~   r   rJ   r   r   initiate)rT   r{   r	  r   rt  ru  extra_headersrO   r   r   r   r   r   r  r   r_  r  r  r   rX  r   r   r   rv  rw  s                            rW   _initiate_resumable_uploadBlob._initiate_resumable_upload  s   p %%f-J!/
''/	)))j.MMMj)))&)P15.,$NN=)!&"4"45*114;;+;+; 2 
 (##]D4E4E$FG )#4+<+<<##\43D3D$EF%##_n$EF*##%8:M$NO".##%;=T$UV".##%<>U$VW&2##+-HI +85EF
 
Gh
 	 	 	
 y  rY   c                 r   U R                  UUUUUUUUU	U
UUUS9u  pUR                  UR                  U S.nSU
0n[        SUUUS9   UR                  (       d#   UR                  XS9nUR                  (       d  M#  WsSSS5        $ ! [         a    U R                  5         e f = f! , (       d  f       g= f)a  Perform a resumable upload.

Assumes ``chunk_size`` is not :data:`None` on the current blob.
The default value of ``chunk_size`` is 100 MB.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.

:type content_type: str
:param content_type: Type of content being uploaded (or :data:`None`).

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``stream``). If not provided, the upload will be concluded once
    ``stream`` is exhausted (or :data:`None`).

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. After the upload is complete, the
    server-computed checksum of the resulting object will be checked
    and google.cloud.storage.exceptions.DataCorruption will be raised on
    a mismatch. On a validation failure, the client will attempt to
    delete the uploaded object automatically. 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.

:type retry: google.api_core.retry.Retry
: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 configure backoff and timeout options.

    This private method does not accept ConditionalRetryPolicy values
    because the information necessary to evaluate the policy is instead
    evaluated in blob._do_upload().

    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.

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:rtype: :class:`~requests.Response`
:returns: The "200 OK" response object returned after the final chunk
          is uploaded.
)	ru  r   r   r   r   r   r  r   r_  )r  zupload.chunk_sizer  r   z)Storage.ResumableUpload/transmitNextChunkrm  r  N)r  resumable_urlrO   r$   r  transmit_next_chunkr.   r   )rT   r{   r	  r   rt  ru  r   r   r   r   r   r  r   r_  rw  r  r  r  r   s                      rW   _do_resumable_uploadBlob._do_resumable_upload  s    P !;;) 3$;$;(C < 
  ,,!'!2!2"*

 7#<'	
 oo%99)9UH ooo 
 
 & KKM
 
s*   	B(B	+B(>B(	B%%B((
B6c                    [        U[        5      (       a  UUS.nUR                  US9nUb5  U[        ::  a+  U R	                  UUUUUUUUU	U
UUUS9nUR                  5       $ U R                  UUUUUUUUU	U
UUUS9nUR                  5       $ )aG  Determine an upload strategy and then perform the upload.

If the size of the data to be uploaded exceeds 8 MB a resumable media
request will be used, otherwise the content and the metadata will be
uploaded in a single multipart upload request.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.

:type content_type: str
:param content_type: Type of content being uploaded (or :data:`None`).

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``stream``). If not provided, the upload will be concluded once
    ``stream`` is exhausted (or :data:`None`).

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. If the upload is completed in a single
    request, the checksum will be entirely precomputed and the remote
    server will handle verification and error handling. If the upload
    is too large and must be transmitted in multiple requests, the
    checksum will be incrementally computed and the client will handle
    verification and error handling, raising
    google.cloud.storage.exceptions.DataCorruption on a mismatch and
    attempting to delete the corrupted file. 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.

: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_generation_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.

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:rtype: dict
:returns: The parsed JSON from the "200 OK" response. This will be the
          **only** response in the multipart case and it will be the
          **final** response in the resumable case.
rh  rj  r   r   r  r   r_  )
isinstancer0   "get_retry_policy_if_conditions_met_MAX_MULTIPART_SIZErx  r  json)rT   r{   r	  r   rt  ru  r   r   r   r   r   r  r   r_  r   r   s                   rW   
_do_uploadBlob._do_upload$	  s    f e344 &9)@L <<,<WE(; ;00#''+! 1 H@ }}! 00#''+! 1 H  }}rY   c                     [        XS9  [        R                  " U5      n U R                  UUUUUUUU	U
UUUUS9nU R	                  U5        g! [
         a  n[        U5         SnAgSnAff = f)a  Upload the contents of this blob from a file-like object.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

.. note::
   The effect of uploading to an existing blob depends on the
   "versioning" and "lifecycle" policies defined on the blob's
   bucket.  In the absence of those policies, upload will
   overwrite any existing contents.

   See the [`object versioning`](https://cloud.google.com/storage/docs/object-versioning)
   and [`lifecycle`](https://cloud.google.com/storage/docs/lifecycle)
   API documents for details.

If the size of the data to be uploaded exceeds 8 MB a resumable media
request will be used, otherwise the content and the metadata will be
uploaded in a single multipart upload request.

For more fine-grained over the upload process, check out
[`google-resumable-media`](https://googleapis.dev/python/google-resumable-media/latest/index.html).

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

:type file_obj: file
:param file_obj: A file handle opened in binary mode for reading.

:type rewind: bool
:param rewind:
    If True, seek to the beginning of the file handle before writing
    the file to Cloud Storage.

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``file_obj``). If not provided, the upload will be concluded once
    ``file_obj`` is exhausted.

:type content_type: str
:param content_type: (Optional) Type of content being uploaded.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. If the upload is completed in a single
    request, the checksum will be entirely precomputed and the remote
    server will handle verification and error handling. If the upload
    is too large and must be transmitted in multiple requests, the
    checksum will be incrementally computed and the client will handle
    verification and error handling, raising
    google.cloud.storage.exceptions.DataCorruption on a mismatch and
    attempting to delete the corrupted file. 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.

: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_generation_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.

:type command: str
:param command:
    (Optional) Information about which interface for upload was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.

:raises: :class:`~google.cloud.exceptions.GoogleCloudError`
         if the upload response returns an error status.
)rewindr  N)_maybe_rewindr%   validate_predefinedr  _set_propertiesr/   _raise_from_invalid_response)rT   r  r  rt  r   r{   ru  r   r   r   r   r   r  r   r_  created_jsonexcs                    rW   _prep_and_do_uploadBlob._prep_and_do_upload	  s    J 	h.00@	.??#''+! + L   . 	.(--	.s   ,A 
A-A((A-c                     [        SS9   U R                  UUUUUUUUU	U
UUUS9  SSS5        g! , (       d  f       g= f)a4  Upload the contents of this blob from a file-like object.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

.. note::
   The effect of uploading to an existing blob depends on the
   "versioning" and "lifecycle" policies defined on the blob's
   bucket.  In the absence of those policies, upload will
   overwrite any existing contents.

   See the [`object versioning`](https://cloud.google.com/storage/docs/object-versioning)
   and [`lifecycle`](https://cloud.google.com/storage/docs/lifecycle)
   API documents for details.

If the size of the data to be uploaded exceeds 8 MB a resumable media
request will be used, otherwise the content and the metadata will be
uploaded in a single multipart upload request.

For more fine-grained over the upload process, check out
[`google-resumable-media`](https://googleapis.dev/python/google-resumable-media/latest/index.html).

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

:type file_obj: file
:param file_obj: A file handle opened in binary mode for reading.

:type rewind: bool
:param rewind:
    If True, seek to the beginning of the file handle before writing
    the file to Cloud Storage.

:type size: int
:param size:
    The number of bytes to be uploaded (which will be read from
    ``file_obj``). If not provided, the upload will be concluded once
    ``file_obj`` is exhausted.

:type content_type: str
:param content_type: (Optional) Type of content being uploaded.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. If the upload is completed in a single
    request, the checksum will be entirely precomputed and the remote
    server will handle verification and error handling. If the upload
    is too large and must be transmitted in multiple requests, the
    checksum will be incrementally computed and the client will handle
    verification and error handling, raising
    google.cloud.storage.exceptions.DataCorruption on a mismatch and
    attempting to delete the corrupted file. 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.

: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_generation_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.

:raises: :class:`~google.cloud.exceptions.GoogleCloudError`
         if the upload response returns an error status.
zStorage.Blob.uploadFromFilerH   )r  rt  r   r{   ru  r   r   r   r   r   r  r   N)r$   r  )rT   r  r  rt  r   r{   ru  r   r   r   r   r   r  r   s                 rW   upload_from_fileBlob.upload_from_filea
  sU    | $AB$$)-$7(?(?,G! %  CBBs   /
=c                     U R                  X!S9n[        US5       n[        R                  " UR	                  5       5      R
                  nU R                  " U/UQ7UUS.UD6  SSS5        g! , (       d  f       g= f)a8  Upload this blob's contents from the content of a named file.

:type filename: str
:param filename: The path to the file.

:type content_type: str
:param content_type: (Optional) Type of content being uploaded.

For *args and **kwargs, refer to the documentation for upload_from_filename() for more information.
r]  rb)r   rt  N)rS  r*  r+  fstatfilenost_sizer  )rT   r0  r   r  r1  r  r{  s          rW   _handle_filename_and_upload Blob._handle_filename_and_upload
  sz     --l-N(D!X((8??#45==K$$ 	) 
  "!!s   AA--
A;c                 |    [        SS9   U R                  UUUUUUUUU	U
US9  SSS5        g! , (       d  f       g= f)a:  Upload this blob's contents from the content of a named file.

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The value given by ``mimetypes.guess_type``
- The default value ('application/octet-stream')

.. note::
   The effect of uploading to an existing blob depends on the
   "versioning" and "lifecycle" policies defined on the blob's
   bucket.  In the absence of those policies, upload will
   overwrite any existing contents.

   See the [`object versioning`](https://cloud.google.com/storage/docs/object-versioning)
   and [`lifecycle`](https://cloud.google.com/storage/docs/lifecycle)
   API documents for details.

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

See a [code sample](https://cloud.google.com/storage/docs/samples/storage-upload-encrypted-file#storage_upload_encrypted_file-python)
to upload a file with a
[`customer-supplied encryption key`](https://cloud.google.com/storage/docs/encryption#customer-supplied).

:type filename: str
:param filename: The path to the file.

:type content_type: str
:param content_type: (Optional) Type of content being uploaded.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. If the upload is completed in a single
    request, the checksum will be entirely precomputed and the remote
    server will handle verification and error handling. If the upload
    is too large and must be transmitted in multiple requests, the
    checksum will be incrementally computed and the client will handle
    verification and error handling, raising
    google.cloud.storage.exceptions.DataCorruption on a mismatch and
    attempting to delete the corrupted file. 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.

: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_generation_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.Blob.uploadFromFilenamerH   )
r   r{   ru  r   r   r   r   r   r  r   N)r$   r  )rT   r0  r   r{   ru  r   r   r   r   r   r  r   s               rW   upload_from_filenameBlob.upload_from_filename  sO    X $EF,,)-$7(?(?,G! -  GFFs   -
;z
text/plainc                     [        SS9   [        USS9n[        U5      nU R                  U[	        U5      UUUUUUUU	U
US9  SSS5        g! , (       d  f       g= f)a  Upload contents of this blob from the provided string.

.. note::
   The effect of uploading to an existing blob depends on the
   "versioning" and "lifecycle" policies defined on the blob's
   bucket.  In the absence of those policies, upload will
   overwrite any existing contents.

   See the [`object versioning`](https://cloud.google.com/storage/docs/object-versioning)
   and [`lifecycle`](https://cloud.google.com/storage/docs/lifecycle)
   API documents for details.

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

:type data: bytes or str
:param data:
    The data to store in this blob.  If the value is text, it will be
    encoded as UTF-8.

:type content_type: str
:param content_type:
    (Optional) Type of content being uploaded. Defaults to
    ``'text/plain'``.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. If the upload is completed in a single
    request, the checksum will be entirely precomputed and the remote
    server will handle verification and error handling. If the upload
    is too large and must be transmitted in multiple requests, the
    checksum will be incrementally computed and the client will handle
    verification and error handling, raising
    google.cloud.storage.exceptions.DataCorruption on a mismatch and
    attempting to delete the corrupted file. 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.

: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_generation_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.Blob.uploadFromStringrH   rE  rJ  )r  rt  r   r{   ru  r   r   r   r   r   r  r   N)r$   r   r   r  ro  )rT   rK  r   r{   ru  r   r   r   r   r   r  r   r:  s                rW   upload_from_stringBlob.upload_from_string  sk    H $CDTG4D#DMM!!&Y)-$7(?(?,G! "  EDDs   9A
Ac                    [        SS9   [        U[        5      (       a  UU
S.nUR                  US9n0 nUb  X>S'    [	        S5      nU R                  UUUUUUU	U
UUU R                  UUUS9u  nnUR                  sSSS5        $ ! [         a  n[        U5         SnAOSnAff = f SSS5        g! , (       d  f       g= f)	a  Create a resumable upload session.

Resumable upload sessions allow you to start an upload session from
one client and complete the session in another. This method is called
by the initiator to set the metadata and limits. The initiator then
passes the session URL to the client that will upload the binary data.
The client performs a PUT request on the session URL to complete the
upload. This process allows untrusted clients to upload to an
access-controlled bucket.

For more details, see the
documentation on [`signed URLs`](https://cloud.google.com/storage/docs/access-control/signed-urls#signing-resumable).

The content type of the upload will be determined in order
of precedence:

- The value passed in to this method (if not :data:`None`)
- The value stored on the current blob
- The default value ('application/octet-stream')

.. note::
   The effect of uploading to an existing blob depends on the
   "versioning" and "lifecycle" policies defined on the blob's
   bucket.  In the absence of those policies, upload will
   overwrite any existing contents.

   See the [`object versioning`](https://cloud.google.com/storage/docs/object-versioning)
   and [`lifecycle`](https://cloud.google.com/storage/docs/lifecycle)
   API documents for details.

If :attr:`encryption_key` is set, the blob will be encrypted with
a [`customer-supplied`](https://cloud.google.com/storage/docs/encryption#customer-supplied)
encryption key.

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

:type size: int
:param size:
    (Optional) The maximum number of bytes that can be uploaded using
    this session. If the size is not known when creating the session,
    this should be left blank.

:type content_type: str
:param content_type: (Optional) Type of content being uploaded.

:type origin: str
:param origin:
    (Optional) If set, the upload can only be completed by a user-agent
    that uploads from the given origin. This can be useful when passing
    the session to a web client.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

: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 checksum: str
:param checksum:
    (Optional) The type of checksum to compute to verify
    the integrity of the object. After the upload is complete, the
    server-computed checksum of the resulting object will be checked
    and google.cloud.storage.exceptions.DataCorruption will be raised on
    a mismatch. On a validation failure, the client will attempt to
    delete the uploaded object automatically. 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.

:type predefined_acl: str
:param predefined_acl: (Optional) Predefined access control list

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

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

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

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

: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_generation_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: str
:returns: The resumable upload session URL. The upload can be
          completed by making an HTTP PUT request with the
          file's contents.

:raises: :class:`google.cloud.exceptions.GoogleCloudError`
         if the session creation response returns an error status.
z)Storage.Blob.createResumableUploadSessionrH   r  r  NOriginrY   )
ru  r   r   r   r   r  rO   r   r  r   )
r$   r  r0   r  r   r  ra   r  r/   r  )rT   r   rt  originr{   r   r  ru  r   r   r   r   r   r   r  fake_streamrw  rR  r  s                      rW   create_resumable_upload_session$Blob.create_resumable_upload_session  s    J $OP%!788 *=-D  @@!- A  M! +1h'2%cl !;; #1(;,C,C0K"/#88#% < 	" ++W QPX # 2,S1121[ QPPs.   3B3?B
B&B!B3!B&&B33
Cc           	      "   [        SS9   U R                  U5      n0 nU R                  b  U R                  US'   Ub  X%S'   UR                  U R                   S3UUUSS9n[
        R                  " U5      sSSS5        $ ! , (       d  f       g= f)a  Retrieve the IAM policy for the object.

.. note::

   Blob- / object-level IAM support does not yet exist and methods
   currently call an internal ACL backend not providing any utility
   beyond the blob's :attr:`acl` at this time. The API may be enhanced
   in the future and is currently undocumented. Use :attr:`acl` for
   managing object access control.

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

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the current object's bucket.

:type requested_policy_version: int or ``NoneType``
:param requested_policy_version:
    (Optional) The version of IAM policies to request.  If a policy
    with a condition is requested without setting this, the server will
    return an error.  This must be set to a value of 3 to retrieve IAM
    policies containing conditions. This is to prevent client code that
    isn't aware of IAM conditions from interpreting and modifying
    policies incorrectly.  The service might return a policy with
    version lower than the one that was requested, based on the feature
    syntax in the policy fetched.

: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: :class:`google.api_core.iam.Policy`
:returns: the policy instance, based on the resource returned from
          the ``getIamPolicy`` API request.
zStorage.Blob.getIamPolicyrH   Nr   optionsRequestedPolicyVersion/iamr   r   r   r   )r$   r   r~   r   rx   r   from_api_repr)rT   r{   requested_policy_versionr   r   r   r  s          rW   get_iam_policyBlob.get_iam_policy  s    b $?@))&1FL  ,.2.?.?]+'3@X<=''99+T")# ( D ''-% A@@s   A,B  
Bc           
      X   [        SS9   U R                  U5      n0 nU R                  b  U R                  US'   U R                   S3nUR	                  5       nU R                  US'   UR                  UUUUUSS9n[        R                  " U5      sSSS5        $ ! , (       d  f       g= f)a  Update the IAM policy for the bucket.

.. note::

   Blob- / object-level IAM support does not yet exist and methods
   currently call an internal ACL backend not providing any utility
   beyond the blob's :attr:`acl` at this time. The API may be enhanced
   in the future and is currently undocumented. Use :attr:`acl` for
   managing object access control.

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

:type policy: :class:`google.api_core.iam.Policy`
:param policy: policy instance used to update bucket's IAM policy.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the current bucket.

: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: :class:`google.api_core.iam.Policy`
:returns: the policy instance, based on the resource returned from
          the ``setIamPolicy`` API request.
zStorage.Blob.setIamPolicyrH   Nr   r  
resourceIdr  )r$   r   r~   rx   to_api_repr_put_resourcer   r  )	rT   policyr{   r   r   r   rx   r   r  s	            rW   set_iam_policyBlob.set_iam_policy  s    R $?@))&1FL  ,.2.?.?]+ii[%D))+H%)YYH\"'')# ( D ''-' A@@s   BB
B)c           	         [        SS9   U R                  U5      nSU0nU R                  b  U R                  US'   U R                   S3nUR	                  UUUUSS9nUR                  S/ 5      sSSS5        $ ! , (       d  f       g= f)a  API call:  test permissions

.. note::

   Blob- / object-level IAM support does not yet exist and methods
   currently call an internal ACL backend not providing any utility
   beyond the blob's :attr:`acl` at this time. The API may be enhanced
   in the future and is currently undocumented. Use :attr:`acl` for
   managing object access control.

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

:type permissions: list of string
:param permissions: the permissions to check

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the current bucket.

: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: list of string
:returns: the permissions returned by the ``testIamPermissions`` API
          request.
zStorage.Blob.testIamPermissionsrH   permissionsNr   z/iam/testPermissionsr  )r$   r   r~   rx   r   r   )rT   r  r{   r   r   r   rx   resps           rW   test_iam_permissionsBlob.test_iam_permissions0  s    J $EF))&1F);7L  ,.2.?.?]+ii[ 45D'')# ( D 88M2.! GFFs   A%A99
Bc                     [        SS9   U R                  R                  5       R                  5         U R                  R	                  UUUUUUUS9  SSS5        g! , (       d  f       g= f)ag  Update blob's ACL, granting read access to anonymous users.

:type client: :class:`~google.cloud.storage.client.Client` or
              ``NoneType``
:param client: (Optional) The client to use.  If not passed, falls back
               to the ``client`` stored on the blob's bucket.

: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_generation_match: long
:param if_generation_match:
    (Optional) See :ref:`using-if-generation-match`

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

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

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

: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`
zStorage.Blob.makePublicrH   r{   r   r   r   r   r   r   N)r$   rp   all
grant_readsaverT   r{   r   r   r   r   r   r   s           rW   make_publicBlob.make_publicg  sZ    T $=>HHLLN%%'HHMM$7(?(?,G   ?>>   AA
A)c                     [        SS9   U R                  R                  5       R                  5         U R                  R	                  UUUUUUUS9  SSS5        g! , (       d  f       g= f)ah  Update blob's ACL, revoking read access for anonymous users.

:type client: :class:`~google.cloud.storage.client.Client` or
              ``NoneType``
:param client: (Optional) The client to use.  If not passed, falls back
               to the ``client`` stored on the blob's bucket.

: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_generation_match: long
:param if_generation_match:
    (Optional) See :ref:`using-if-generation-match`

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

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

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

: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`
zStorage.Blob.makePrivaterH   r  N)r$   rp   r  revoke_readr  r  s           rW   make_privateBlob.make_private  s[    T $>?HHLLN&&(HHMM$7(?(?,G   @??r  c           
      d   [        SS9   [        U5      nU R                  U5      n0 n	[        U[        5      (       a4  [
        R                  " [        [        SS9  Ub  [        [        5      eUnSn[        U[        5      (       a   [
        R                  " [        [        SS9  SnUc  S/U-  n[        U5      U:w  a  [        [        5      e/ n
[        X5       HC  u  pUR                  UR                  S.n0 nUb  XS'   U(       a  XS'   U
R!                  U5        ME     U
U R"                  R%                  5       S	.nU R&                  b  U R&                  U	S
'   [)        U	UUS9  UR+                  U R,                   S3UU	UUU S9nU R/                  U5        SSS5        g! , (       d  f       g= f)a
  Concatenate source blobs into this one.

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

See [API reference docs](https://cloud.google.com/storage/docs/json_api/v1/objects/compose)
and a [code sample](https://cloud.google.com/storage/docs/samples/storage-compose-file#storage_compose_file-python).

:type sources: list of :class:`Blob`
:param sources: Blobs whose contents will be composed into this blob.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

: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_generation_match: long
:param if_generation_match:
    (Optional) Makes the operation conditional on whether the
    destination object's current generation matches the given value.
    Setting to 0 makes the operation succeed only if there are no live
    versions of the object.
    Note: In a previous version, this argument worked identically to the
    ``if_source_generation_match`` argument. For
    backwards-compatibility reasons, if a list is passed in,
    this argument will behave like ``if_source_generation_match``
    and also issue a DeprecationWarning.

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

    If a list of long is passed in, no match operation will be
    performed.  (Deprecated: type(list of long) is supported for
    backwards-compatability reasons only.)

:type if_source_generation_match: list of long
:param if_source_generation_match:
    (Optional) Makes the operation conditional on whether the current
    generation of each source blob matches the corresponding generation.
    The list must match ``sources`` item-to-item.

:type retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
:param retry:
    (Optional) How to retry the RPC.
    The default value is ``DEFAULT_RETRY_IF_GENERATION_SPECIFIED``, a conditional retry
    policy which will only enable retries if ``if_generation_match`` or ``generation``
    is set, in order to ensure requests are idempotent before retrying them.
    Change the value to ``DEFAULT_RETRY`` or another `google.api_core.retry.Retry` object
    to enable retries regardless of generation precondition setting.
    See [Configuring Retries](https://cloud.google.com/python/docs/reference/storage/latest/retry_timeout).
zStorage.Blob.composerH   r   r   N)rA   rL   rh  objectPreconditions)sourceObjectsdestinationr   )r   r   z/composer  )r$   ro  r   r  listr   r   &_COMPOSE_IF_GENERATION_LIST_DEPRECATEDDeprecationWarningrb   :_COMPOSE_IF_GENERATION_LIST_AND_IF_SOURCE_GENERATION_ERROR*_COMPOSE_IF_METAGENERATION_LIST_DEPRECATED,_COMPOSE_IF_SOURCE_GENERATION_MISMATCH_ERRORziprA   rL   r   rS   copyr~   r   _post_resourcerx   r  )rT   sourcesr{   r   r   r   if_source_generation_matchr   sources_lenr   source_objectssourcesource_generationsource_objectpreconditionsrequestapi_responses                    rW   composeBlob.compose  s   J $:;g,K))&1FL-t44:&  .9$R  .A*&*#1488>&  +/')1.2Vk-A*-.+= !MNNN-0-U))/FDUDU V "$09J"56 ;H"78%%m4 .V "0#//446G
   ,.2.?.?]+,$7(? "0099+X&)# 1 L   .K <;;s   FF!!
F/c                    [        SS9   U R                  U5      n[        U R                  5      nUR	                  [        UR                  SS95        U R
                  nSU;   a  US	 U(       a  X/S'   UR                  (       a  UR                  US'   U R                  b  S	U R                  ;  a  U R                  US
'   [        UUUUUUU	U
US9	  UR                   SU R                   3nUR                  UU R                  UUUUU S9n[        US   5      n[        US   5      nUS   (       a"  U R                  US   5        SUU4sSSS5        $ US   UU4sSSS5        $ ! , (       d  f       g= f)a  Rewrite source blob into this one.

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

.. note::

   ``rewrite`` is not supported in a ``Batch`` context.

:type source: :class:`Blob`
:param source: blob whose contents will be rewritten into this blob.

:type token: str
:param token:
    (Optional) Token returned from an earlier, not-completed call to
    rewrite the same source blob.  If passed, result will include
    updated status, total bytes written.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type if_generation_match: long
:param if_generation_match:
    (Optional) See :ref:`using-if-generation-match`
    Note that the generation to be matched is that of the
    ``destination`` blob.

:type if_generation_not_match: long
:param if_generation_not_match:
    (Optional) See :ref:`using-if-generation-not-match`
    Note that the generation to be matched is that of the
    ``destination`` blob.

:type if_metageneration_match: long
:param if_metageneration_match:
    (Optional) See :ref:`using-if-metageneration-match`
    Note that the metageneration to be matched is that of the
    ``destination`` blob.

:type if_metageneration_not_match: long
:param if_metageneration_not_match:
    (Optional) See :ref:`using-if-metageneration-not-match`
    Note that the metageneration to be matched is that of the
    ``destination`` blob.

:type if_source_generation_match: long
:param if_source_generation_match:
    (Optional) Makes the operation conditional on whether the source
    object's generation matches the given value.

:type if_source_generation_not_match: long
:param if_source_generation_not_match:
    (Optional) Makes the operation conditional on whether the source
    object's generation does not match the given value.

:type if_source_metageneration_match: long
:param if_source_metageneration_match:
    (Optional) Makes the operation conditional on whether the source
    object's current metageneration matches the given value.

:type if_source_metageneration_not_match: long
:param if_source_metageneration_not_match:
    (Optional) Makes the operation conditional on whether the source
    object'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.
    The default value is ``DEFAULT_RETRY_IF_GENERATION_SPECIFIED``, a conditional retry
    policy which will only enable retries if ``if_generation_match`` or ``generation``
    is set, in order to ensure requests are idempotent before retrying them.
    Change the value to ``DEFAULT_RETRY`` or another `google.api_core.retry.Retry` object
    to enable retries regardless of generation precondition setting.
    See [Configuring Retries](https://cloud.google.com/python/docs/reference/storage/latest/retry_timeout).

:rtype: tuple
:returns: ``(token, bytes_rewritten, total_bytes)``, where ``token``
          is a rewrite token (``None`` if the rewrite is complete),
          ``bytes_rewritten`` is the number of bytes rewritten so far,
          and ``total_bytes`` is the total number of bytes to be
          rewritten.
zStorage.Blob.rewriterH   T)r  rL   rewriteTokensourceGenerationNrf  destinationKmsKeyName)r   r   r   r   r  if_source_generation_not_matchif_source_metageneration_match"if_source_metageneration_not_matchz
/rewriteTor   totalBytesRewritten
objectSizedoner   )r$   r   r   rR   r   r   rL   rJ   r   rx   r  rS   intr  )rT   r  tokenr{   r   r   r   r   r  r  r  r  r   r   r   r   rx   r  	rewrittenrt  s                       rW   rewriteBlob.rewrite_  s   R $:;))&1F-d.B.BCGNN263I3IRVWX--L|+ ./4^,  393D3D/0 !!-'t/@/@@8<8I8I45,$7(?(?,G+E/M/M3U
 kk]*TYYK8D!00  )# 1 L L)>?@I|L12D
 F#$$\*%=>Y,q <;t  /D@u <;;s   D?E$E$$
E2c                     [        SS9   U R                  SU5        U R                  U UUUUUUU	U
UUS9u  n  nUb#  U R                  U UUUUUUUU	U
UUS9u  n  nUb  M#  SSS5        g! , (       d  f       g= f)a  Update blob's storage class via a rewrite-in-place. This helper will
wait for the rewrite to complete before returning, so it may take some
time for large files.

See
https://cloud.google.com/storage/docs/per-object-storage-class

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

:type new_class: str
:param new_class:
    new storage class for the object.   One of:
    :attr:`~google.cloud.storage.constants.NEARLINE_STORAGE_CLASS`,
    :attr:`~google.cloud.storage.constants.COLDLINE_STORAGE_CLASS`,
    :attr:`~google.cloud.storage.constants.ARCHIVE_STORAGE_CLASS`,
    :attr:`~google.cloud.storage.constants.STANDARD_STORAGE_CLASS`,
    :attr:`~google.cloud.storage.constants.MULTI_REGIONAL_LEGACY_STORAGE_CLASS`,
    or
    :attr:`~google.cloud.storage.constants.REGIONAL_LEGACY_STORAGE_CLASS`.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use.  If not passed, falls back to the
    ``client`` stored on the blob's bucket.

:type if_generation_match: long
:param if_generation_match:
    (Optional) See :ref:`using-if-generation-match`
    Note that the generation to be matched is that of the
    ``destination`` blob.

:type if_generation_not_match: long
:param if_generation_not_match:
    (Optional) See :ref:`using-if-generation-not-match`
    Note that the generation to be matched is that of the
    ``destination`` blob.

:type if_metageneration_match: long
:param if_metageneration_match:
    (Optional) See :ref:`using-if-metageneration-match`
    Note that the metageneration to be matched is that of the
    ``destination`` blob.

:type if_metageneration_not_match: long
:param if_metageneration_not_match:
    (Optional) See :ref:`using-if-metageneration-not-match`
    Note that the metageneration to be matched is that of the
    ``destination`` blob.

:type if_source_generation_match: long
:param if_source_generation_match:
    (Optional) Makes the operation conditional on whether the source
    object's generation matches the given value.

:type if_source_generation_not_match: long
:param if_source_generation_not_match:
    (Optional) Makes the operation conditional on whether the source
    object's generation does not match the given value.

:type if_source_metageneration_match: long
:param if_source_metageneration_match:
    (Optional) Makes the operation conditional on whether the source
    object's current metageneration matches the given value.

:type if_source_metageneration_not_match: long
:param if_source_metageneration_not_match:
    (Optional) Makes the operation conditional on whether the source
    object'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.
    The default value is ``DEFAULT_RETRY_IF_GENERATION_SPECIFIED``, a conditional retry
    policy which will only enable retries if ``if_generation_match`` or ``generation``
    is set, in order to ensure requests are idempotent before retrying them.
    Change the value to ``DEFAULT_RETRY`` or another `google.api_core.retry.Retry` object
    to enable retries regardless of generation precondition setting.
    See [Configuring Retries](https://cloud.google.com/python/docs/reference/storage/latest/retry_timeout).
zStorage.Blob.updateStorageClassrH   rC   )
r   r   r   r   r  r  r  r  r   r   N)r  r   r   r   r   r  r  r  r  r   r   )r$   _patch_propertyr  )rT   	new_classr{   r   r   r   r   r  r  r  r  r   r   r  rR  s                  rW   update_storage_classBlob.update_storage_class  s    H $EF  ; ,,$7(?(?,G+E/M/M3U ' KE1a #"ll(;,C,C0K/I3Q3Q7Y# + q! #% GFFs   AA))
A7c           	      H   [        SS9   US:X  aI  U(       d  U(       d  U(       a  [        S5      eU(       a  [        S5      e[        U 4SU0UD6sSSS5        $ US:X  a7  U(       d  U(       d  U(       a  [        S5      e[        U 4X#S	.UD6sSSS5        $ US
;   a3  U(       a  [        S5      e[	        [        U 4SU0UD6UUUS9sSSS5        $ US;   a2  USL a  [        S5      e[	        [        U 4USS	.UD6UUUS9sSSS5        $ [        S5      e! , (       d  f       g= f)a  Create a file handler for file-like I/O to or from this blob.

This method can be used as a context manager, just like Python's
built-in 'open()' function.

While reading, as with other read methods, if blob.generation is not set
the most recent blob generation will be used. Because the file-like IO
reader downloads progressively in chunks, this could result in data from
multiple versions being mixed together. If this is a concern, use
either bucket.get_blob(), or blob.reload(), which will download the
latest generation number and set it; or, if the generation is known, set
it manually, for instance with bucket.blob(generation=123456).

Checksumming (hashing) to verify data integrity is disabled for reads
using this feature because reads are implemented using request ranges,
which do not provide checksums to validate. See
https://cloud.google.com/storage/docs/hashes-etags for details.

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

Keyword arguments to pass to the underlying API calls.
For both uploads and downloads, the following arguments are
supported:

- ``if_generation_match``
- ``if_generation_not_match``
- ``if_metageneration_match``
- ``if_metageneration_not_match``
- ``timeout``
- ``retry``

For downloads only, the following additional arguments are supported:

- ``raw_download``

For uploads only, the following additional arguments are supported:

- ``content_type``
- ``predefined_acl``
- ``checksum``

:type mode: str
:param mode:
    (Optional) A mode string, as per standard Python `open()` semantics.The first
    character must be 'r', to open the blob for reading, or 'w' to open
    it for writing. The second character, if present, must be 't' for
    (unicode) text mode, or 'b' for bytes mode. If the second character
    is omitted, text mode is the default.

:type chunk_size: long
:param chunk_size:
    (Optional) For reads, the minimum number of bytes to read at a time.
    If fewer bytes than the chunk_size are requested, the remainder is
    buffered. For writes, the maximum number of bytes to buffer before
    sending data to the server, and the size of each request when data
    is sent. Writes are implemented as a "resumable upload", so
    chunk_size for writes must be exactly a multiple of 256KiB as with
    other resumable uploads. The default is 40 MiB.

:type ignore_flush: bool
:param ignore_flush:
    (Optional) For non text-mode writes, makes flush() do nothing
    instead of raising an error. flush() without closing is not
    supported by the remote service and therefore calling it normally
    results in io.UnsupportedOperation. However, that behavior is
    incompatible with some consumers and wrappers of file objects in
    Python, such as zipfile.ZipFile or io.TextIOWrapper. Setting
    ignore_flush will cause flush() to successfully do nothing, for
    compatibility with those contexts. The correct way to actually flush
    data to the remote server is to close() (using a context manager,
    such as in the example, will cause this to happen automatically).

:type encoding: str
:param encoding:
    (Optional) For text mode only, the name of the encoding that the stream will
    be decoded or encoded with. If omitted, it defaults to
    locale.getpreferredencoding(False).

:type errors: str
:param errors:
    (Optional) For text mode only, an optional string that specifies how encoding
    and decoding errors are to be handled. Pass 'strict' to raise a
    ValueError exception if there is an encoding error (the default of
    None has the same effect), or pass 'ignore' to ignore errors. (Note
    that ignoring encoding errors can lead to data loss.) Other more
    rarely-used options are also available; see the Python 'io' module
    documentation for 'io.TextIOWrapper' for a complete list.

:type newline: str
:param newline:
    (Optional) For text mode only, controls how line endings are handled. It can
    be None, '', '\n', '\r', and '\r\n'. If None, reads use "universal
    newline mode" and writes use the system default. See the Python
    'io' module documentation for 'io.TextIOWrapper' for details.

:returns: A 'BlobReader' or 'BlobWriter' from
    'google.cloud.storage.fileio', or an 'io.TextIOWrapper' around one
    of those classes, depending on the 'mode' argument.
zStorage.Blob.openrH   r  z=encoding, errors and newline arguments are for text mode onlyz5ignore_flush argument is for non-text write mode onlyrO   Nr)  )rO   ignore_flush)rrt)rJ  errorsnewline)wwtFzIignore_flush is required for text mode writing and cannot be set to FalseTzFSupported modes strings are 'r', 'rb', 'rt', 'w', 'wb', and 'wt' only.)r$   rb   r4   r5   r   NotImplementedError)rT   moderO   r  rJ  r  r  r1  s           rW   r*  	Blob.open  sh   Z $78t|v$W   $O  "$H:HH 98 v$W  "%/NT! 98& $$O  %tE
EfE%!#	1 98< $5($1  %)3$JP &!#I 98Z *\ [ 98s$   AD3D/D.DD
D!r9   r:   r;   r<   r=   c                    [        U[        5      (       a  UU
S.nUR                  US9nU R                  U5      nU R	                  UUU	U
US9n[        U R                  5      nSUS'   [        UUUS9  0 [        UR                  R                  US9EUEUR                  EnUR                  n U R                  UUUUUUUUUUS9
  g	! [         a  n[        U5         S	nAg	S	nAff = f)
ap  Download the contents of a blob object into a file-like object.

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

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

:type file_obj: file
:param file_obj: A file handle to which to write the blob's data.

:type client: :class:`~google.cloud.storage.client.Client`
:param client:
    (Optional) The client to use. If not passed, falls back to the
    ``client`` stored on the blob's bucket.

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

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

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

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

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

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

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

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

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

: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 checksum: str
:param checksum:
    (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.

: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.

:type command: str
:param command:
    (Optional) Information about which interface for download was used,
    to be included in the X-Goog-API-Client header. Please leave as None
    unless otherwise directed.
r  r  r   gzipzaccept-encodingr   r^  )r   r  r   N)r  r0   r  r   r   r   rR   r   r   r   r`  ra  r   r   r/   r  )rT   r  r{   r
  r  r  r   r   r   r   r   r   r   r  r   r_  r   r  r   r  r  s                        rW   r$  Blob._prep_and_do_downloadd  s1   X e344 &9)@L <<,<WE%%f--- 3$;$;(C . 
 *$*>*>?%+!"'/	

"6#5#5#@#@'R

 ##
 LL		.!    	.(--	.s   .C 
C&C!!C&c                 V    U R                   R                  S5      nUb  [        U5      $ g)a  Number of underlying components that make up this object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: int or ``NoneType``
:returns: The component count (in case of a composed object) or
          ``None`` if the blob's resource has not been loaded from
          the server.  This property will not be set on objects
          not created via ``compose``.
componentCountNrS   r   r  )rT   component_counts     rW   r  Blob.component_count  s1     **../?@&'' 'rY   c                 8    U R                   R                  S5      $ )aL  Retrieve the ETag for the object.

See [`RFC 2616 (etags)`](https://tools.ietf.org/html/rfc2616#section-3.11) and
[`API reference docs`](https://cloud.google.com/storage/docs/json_api/v1/objects).

:rtype: str or ``NoneType``
:returns: The blob etag or ``None`` if the blob's resource has not
          been loaded from the server.
r   rS   r   r[   s    rW   r   	Blob.etag  s     ##F++rY   eventBasedHoldc                 V    U R                   R                  S5      nUb  [        U5      $ g)zRetrieve the generation for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: int or ``NoneType``
:returns: The generation of the blob or ``None`` if the blob's
          resource has not been loaded from the server.
rL   Nr  )rT   rL   s     rW   rL   Blob.generation+  s/     %%)),7
!z?" "rY   c                 8    U R                   R                  S5      $ )a4  Retrieve the ID for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

The ID consists of the bucket name, object name, and generation number.

:rtype: str or ``NoneType``
:returns: The ID of the blob or ``None`` if the blob's
          resource has not been loaded from the server.
idr  r[   s    rW   r  Blob.id9  s     ##D))rY   r?   c                 8    U R                   R                  S5      $ )a  Retrieve the media download URI for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: str or ``NoneType``
:returns: The media link for the blob or ``None`` if the blob's
          resource has not been loaded from the server.
	mediaLinkr  r[   s    rW   r   Blob.media_linkU  s     ##K00rY   c                 `    [         R                  " U R                  R                  S5      5      $ )a  Retrieve arbitrary/application specific metadata for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:setter: Update arbitrary/application specific metadata for the
         object.
:getter: Retrieve arbitrary/application specific metadata for
         the object.

:rtype: dict or ``NoneType``
:returns: The metadata associated with the blob or ``None`` if the
          property is not set.
r@   r  deepcopyrS   r   r[   s    rW   r@   Blob.metadataa  s$     }}T--11*=>>rY   c                     Ub2  UR                  5        VVs0 s H  u  p#X#b  [        U5      OS_M     nnnU R                  SU5        gs  snnf )a  Update arbitrary/application specific metadata for the object.

Values are stored to GCS as strings. To delete a key, set its value to
None and call blob.patch().

See https://cloud.google.com/storage/docs/json_api/v1/objects

:type value: dict
:param value: The blob metadata to set.
Nr@   )itemsstrr  )rT   rd   kvs       rW   r@   r#  r  sI     FKkkmTmdaQ-AT9mETZ/ Us   A	c                 V    U R                   R                  S5      nUb  [        U5      $ g)a  Retrieve the metageneration for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: int or ``NoneType``
:returns: The metageneration of the blob or ``None`` if the blob's
          resource has not been loaded from the server.
r   Nr  )rT   r   s     rW   r   Blob.metageneration  s1     ))--.>?%~&& &rY   c                 `    [         R                  " U R                  R                  S5      5      $ )a  Retrieve info about the owner of the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: dict or ``NoneType``
:returns: Mapping of owner's role/ID, or ``None`` if the blob's
          resource has not been loaded from the server.
ownerr!  r[   s    rW   r,  
Blob.owner  s$     }}T--11':;;rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)a/  Retrieve timestamp at which the object's retention period expires.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the property is not set locally.
retentionExpirationTimeNrS   r   r   rc   s     rW   retention_expiration_timeBlob.retention_expiration_time  s1       $$%>?-e44 rY   c                 8    U R                   R                  S5      $ )zRetrieve the URI for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: str or ``NoneType``
:returns: The self link for the blob or ``None`` if the blob's
          resource has not been loaded from the server.
selfLinkr  r[   s    rW   	self_linkBlob.self_link  s     ##J//rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)zSize of the object, in bytes.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: int or ``NoneType``
:returns: The size of the blob or ``None`` if the blob's
          resource has not been loaded from the server.
rt  Nr  )rT   rt  s     rW   rt  	Blob.size  s/     ##F+t9 rY   c                 8    U R                   R                  S5      $ )zResource name of Cloud KMS key used to encrypt the blob's contents.

:rtype: str or ``NoneType``
:returns:
    The resource name or ``None`` if no Cloud KMS key was used,
    or the blob's resource has not been loaded from the server.
rK   r  r[   s    rW   rJ   Blob.kms_key_name  s     ##L11rY   c                 (    U R                  SU5        g)zSet KMS encryption key for object.

:type value: str or ``NoneType``
:param value: new KMS key name (None to clear any existing key).
rK   N)r  rc   s     rW   rJ   r:    s     	\51rY   rC   temporaryHoldc                 V    U R                   R                  S5      nUb  [        U5      $ g)a  Retrieve the timestamp at which the object was deleted.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the blob's resource has not been loaded from
          the server (see :meth:`reload`). If the blob has
          not been deleted, this will never be set.
timeDeletedNr0  rc   s     rW   time_deletedBlob.time_deleted  s0       $$]3-e44 rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)a[  Retrieve the timestamp at which the object was created.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the blob's resource has not been loaded from
          the server (see :meth:`reload`).
timeCreatedNr0  rc   s     rW   time_createdBlob.time_created	  s0       $$]3-e44 rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)a[  Retrieve the timestamp at which the object was updated.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the blob's resource has not been loaded from
          the server (see :meth:`reload`).
r-  Nr0  rc   s     rW   r-  Blob.updated  s0       $$Y/-e44 rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)aL  Retrieve the custom time for the object.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the blob's resource has not been loaded from
          the server (see :meth:`reload`).
r>   Nr0  rc   s     rW   custom_timeBlob.custom_time'  s0       $$\2-e44 rY   c                 D    Ub  [        U5      nU R                  SU5        g)a  Set the custom time for the object.

Once set on the server side object, this value can't be unset, but may
only changed to a custom datetime in the future.

If :attr:`custom_time` must be unset, either perform a rewrite
operation or upload the data again.

See https://cloud.google.com/storage/docs/json_api/v1/objects

:type value: :class:`datetime.datetime`
:param value: new value
Nr>   )r   r  rc   s     rW   rH  rI  6  s$     (/E\51rY   c                 d    U R                   R                  S0 5      n[        R                  X5      $ )zRetrieve the retention configuration for this object.

:rtype: :class:`Retention`
:returns: an instance for managing the object's retention configuration.
rB   )rS   r   	Retentionr  )rT   r  s     rW   rB   Blob.retentionJ  s-     ##K4&&t22rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)a  If this object has been soft-deleted, returns the time at which it became soft-deleted.

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns:
    (readonly) The time that the object became soft-deleted.
     Note this property is only set for soft-deleted objects.
softDeleteTimeNr0  )rT   soft_delete_times     rW   rP  Blob.soft_delete_timeT  3      ++//0@A'-.>?? (rY   c                 V    U R                   R                  S5      nUb  [        U5      $ g)a   If this object has been soft-deleted, returns the time at which it will be permanently deleted.

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns:
    (readonly) The time that the object will be permanently deleted.
    Note this property is only set for soft-deleted objects.
hardDeleteTimeNr0  )rT   hard_delete_times     rW   rU  Blob.hard_delete_timea  rR  rY   )rQ   rP   r^   rR   rO   )NNNN)N)NNGETNNNNNNNNNNNNFNhttp)NN)r  NNNNN)j__name__
__module____qualname____firstlineno____doc__r^   ra   r-   r+   r)   r(   r*   r,   STORAGE_CLASSESrN   propertyrU   rO   setterrI   staticmethodrm   rp   ru   rx   r{   r~   r   r   r   classmethodr   r   r   r'   r1   r   r   r   r   r  r   r%  r3  r6  r;  r@  rL  rS  rZ  rb  rx  r  r  r  r  r  r  r  r  r  r  r2   r  r  r  r  r3   r  r  r  r*  r   cache_controlcontent_dispositioncontent_encodingcontent_languager   r   r=   r$  r  r   event_based_holdrL   r  md5_hashr   r@   r   r,  r1  r5  rt  rJ   storage_classtemporary_holdr?  rC  r-  rH  rB   rP  rU  __static_attributes____classcell__rV   s   @rW   rE   rE      s5    D K%D 	+%O	 8>       ! ! $ $ % % 7 7  H 	= 	= " " ( (=   
 
& 7 7< 5 5<  !"""'`
H   $ $$( j\   $ $$( IV& ! $ $$(9Av(C`  FLV   $ $$( AF4<   $ $$( wv   $ $$( v,t   $ $$( j\   $ $$( s(j<B#6` !lh   $ $$( !z!N !Jn !_H   $ $$( Z.~   $ $$( M^6   $ $$( y| "  $ $$( tp    $ $$(r2l !% C.P  +<.~ #'0@5/r    $ $$(4p    $ $$(4r    $#'3J/^   $ $$(#''+'++/ 3cAP   $ $$(#''+'++/ 3DP \| %^4M ++?@ ((9: ((9: $$78L h'F    $ $$( !^.@ ( ( 
, 
, ((89 # # * *  	*H 	1 	1 ? ?  __0 0 ' ' 	< 	< 5 5 	0 	0   2 2 2 2 %^4M, &o6N 5 5 5 5 5 5 5 5 2 2& 3 3 
@ 
@ 
@ 
@rY   rE   c                 \    [        U S5      (       d  U R                  $ U R                  5       $ )zReturns the host name from the given connection.

:type connection: :class:`~google.cloud.storage._http.Connection`
:param connection: The connection object.

:rtype: str
:returns: The host name.
get_api_base_url_for_mtls)hasattrAPI_BASE_URLro  )
connections    rW   r   r   o  s5     z#>?? 	 113rY   c                     U c  0 $ [        U 5      n [        R                  " U 5      R                  5       n[        R
                  " U5      n[        R
                  " U 5      n U(       a  SnOSnUS-   SUS-   [        U 5      US-   [        U5      0$ )aK  Builds customer encryption key headers

:type key: bytes
:param key: 32 byte key to build request key and hash.

:type source: bool
:param source: If true, return headers for the "source" blob; otherwise,
               return headers for the "destination" blob.

:rtype: dict
:returns: dict of HTTP headers being sent in request.
zX-Goog-Copy-Source-Encryption-zX-Goog-Encryption-	AlgorithmAES256Keyz
Key-Sha256)r   hashlibsha256r  base64	b64encoder   )rY  r  key_hashprefixs       rW   r   r     s     {	
C.C~~c"))+H)H


3
C1% 	h)#.0: rY   c                 (    [        U SS9n [        XS9$ )a  URL-quote a string.

If the value is unicode, this method first UTF-8 encodes it as bytes and
then quotes the bytes. (In Python 3, ``urllib.parse.quote`` does this
encoding automatically, but in Python 2, non-ASCII characters cannot be
quoted.)

:type value: str or bytes
:param value: The value to be URL-quoted.

:type safe: bytes
:param safe: Bytes *not* to be quoted.  By default, includes only ``b'~'``.

:rtype: str
:returns: The encoded value (bytes in Python 2, unicode in Python 3).
rE  r  r   )r   r   )rd   r   s     rW   rj   rj     s    " eg.E""rY   c                 T    U(       a!  U R                  S[        R                  5        gg)zRewind the stream if desired.

:type stream: IO[bytes]
:param stream: A bytes IO object open for reading.

:type rewind: bool
:param rewind: Indicates if we should seek to the beginning of the stream.
r   N)seekr+  SEEK_SET)r	  r  s     rW   r  r    s     Ar{{# rY   c                 ,   U R                   nUR                  (       a  UR                  S-   [        U 5      -   nO[        U 5      nUR                  R                   SUR                  R
                   SU 3n[        R                  " UR                  X1S9e)aC  Re-wrap and raise an ``InvalidResponse`` exception.

:type error: :exc:`google.cloud.storage.exceptions.InvalidResponse`
:param error: A caught exception from the ``google-resumable-media``
              library.

:raises: :class:`~google.cloud.exceptions.GoogleCloudError` corresponding
         to the failed status code
z:  )r   )	r   textr&  r  r   urlr   from_http_statusstatus_code)errorr   error_messagemessages       rW   r  r    s     ~~H }} ,s5z9E
!!(()8+;+;+?+?*@=/RG

%
%h&:&:G
WWrY   c                     [        U5      S:X  a  U $ [        U 5      u  p#pEn[        U5      nUR                  U5        [	        X#U[        U5      U45      $ )aI  Add one query parameter to a base URL.

:type base_url: string
:param base_url: Base URL (may already contain query parameters)

:type name_value_pairs: list of (string, string) tuples.
:param name_value_pairs: Names and values of the query parameters to add

:rtype: string
:returns: URL with additional query strings appended.
r   )ro  r	   r   extendr
   r   )r   r   r   netlocrx   queryfrags          rW   r   r     sX     !(0(:%FDeE	LL!"vtYu-=tDEErY   c                      ^  \ rS rSrSr   SU 4S jjr\S 5       r\S 5       r	\S 5       r
\
R                  S 5       r
\S 5       r\R                  S	 5       r\S
 5       rSrU =r$ )rL  i  a  Map an object's retention configuration.

:type blob: :class:`Blob`
:params blob: blob for which this retention configuration applies to.

:type mode: str or ``NoneType``
:params mode:
    (Optional) The mode of the retention configuration, which can be either Unlocked or Locked.
    See: https://cloud.google.com/storage/docs/object-lock

:type retain_until_time: :class:`datetime.datetime` or ``NoneType``
:params retain_until_time:
    (Optional) The earliest time that the object can be deleted or replaced, which is the
    retention configuration set for this object.

:type retention_expiration_time: :class:`datetime.datetime` or ``NoneType``
:params retention_expiration_time:
    (Optional) The earliest time that the object can be deleted, which depends on any
    retention configuration set for the object and any retention policy set for the bucket
    that contains the object. This value should normally only be set by the back-end API.
c                    > SU0nUb  [        U5      nX5S'   Ub  [        U5      nXES'   [        [        U ]  U5        Xl        g )Nr
  retainUntilTimer/  )r   rM   rL  rN   _blob)rT   blobr
  retain_until_timer1  rK  rV   s         rW   rN   Retention.__init__	  sX     ~( 45F G"3$0(<=V(W%*C&'i'-
rY   c                 8    U " U5      nUR                  U5        U$ )a,  Factory:  construct instance from resource.

:type blob: :class:`Blob`
:params blob: Blob for which this retention configuration applies to.

:type resource: dict
:param resource: mapping as returned from API call.

:rtype: :class:`Retention`
:returns: Retention configuration created from resource.
)r   )r   r   r  instances       rW   r  Retention.from_api_repr  s     t9!rY   c                     U R                   $ )znBlob for which this retention configuration applies to.

:rtype: :class:`Blob`
:returns: the instance's blob.
r  r[   s    rW   r  Retention.blob-  s     zzrY   c                 $    U R                  S5      $ )zThe mode of the retention configuration. Options are 'Unlocked' or 'Locked'.

:rtype: string
:returns: The mode of the retention configuration, which can be either set to 'Unlocked' or 'Locked'.
r
  )r   r[   s    rW   r
  Retention.mode6  s     xxrY   c                 D    XS'   U R                   R                  SU 5        g )Nr
  rB   )r  r  rc   s     rW   r
  r  ?  s    V		!!+t4rY   c                 B    U R                  S5      nUb  [        U5      $ g)a\  The earliest time that the object can be deleted or replaced, which is the
retention configuration set for this object.

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns: Datetime object parsed from RFC3339 valid timestamp, or
          ``None`` if the blob's resource has not been loaded from
          the server (see :meth:`reload`).
r  Nr   r   rc   s     rW   r  Retention.retain_until_timeD  s)     *+-e44 rY   c                 `    Ub  [        U5      nXS'   U R                  R                  SU 5        g)zSet the retain_until_time for the object retention configuration.

:type value: :class:`datetime.datetime`
:param value: The earliest time that the object can be deleted or replaced.
Nr  rB   )r   r  r  rc   s     rW   r  r  R  s1     (/E"'		!!+t4rY   c                 B    U R                  S5      nUb  [        U5      $ g)a7  The earliest time that the object can be deleted, which depends on any
retention configuration set for the object and any retention policy set for
the bucket that contains the object.

:rtype: :class:`datetime.datetime` or ``NoneType``
:returns:
    (readonly) The earliest time that the object can be deleted.
r/  Nr  )rT   r1  s     rW   r1  #Retention.retention_expiration_time^  s+     %)HH-F$G!$0-.GHH 1rY   r  )NNN)rY  rZ  r[  r\  r]  rN   rb  r  r_  r  r
  r`  r  r1  rk  rl  rm  s   @rW   rL  rL    s    2 "&&          
[[5 5 5 5 	5 	5 I IrY   rL  )F)   ~)kr]  ry  r  rw  ior   r   loggingrO  r+  r   email.parserr   urllib.parser   r   r   r	   r
   r   $google.cloud.storage._media.requestsr   r   r   r   r   r   google.api_core.iamr   google.cloudr   google.cloud._helpersr   r   r   r   google.cloud.exceptionsr   google.cloud.storage._helpersr   r   r   r   r   r   r   r   google.cloud.storage._signingr    r!   r"   r#   +google.cloud.storage._opentelemetry_tracingr$   google.cloud.storage.aclr%   r&   google.cloud.storage.constantsr'   r(   r)   r*   r+   r,   r-   google.cloud.storage.exceptionsr.   r/   google.cloud.storage.retryr0   r1   r2   r3   google.cloud.storage.fileior4   r5   rQ  r   _BASE_UPLOAD_TEMPLATErr  r~  r   rW  rp  r  r  r  r  r  r?  r   compiler   r}  r  	getLoggerrY  r  rE   r   r   rj   r  r  r   rH  rL   rY   rW   <module>r     s  "        	 	 % "  " ! #  @ 9 < C @ @ & # 3 6 < + , A J 8 : D E > G @ @ 6 H I ( . ; @ A N A H A : ; = 4 D L 2 2 3 T H  0+= /+=  $ 
  Y , #
5 'L ; + O -, 
#  

I    


H
%UG@> UG@pN&B#*
$X0F*xI xIrY   