Ë
    ö%9j§j  ã                   óH  — d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZ  ej@                  e!«      Z"dZ#	 dZ$	 dZ%	 dZ&dZ'e'jQ                  e&¬«      Z)dZ* ejV                  e%d«      Z,	 dZ-dZ.ej                  j^                  Z0ejb                  jd                  Z3d„ Z4d„ Z5d„ Z6d+d„Z7d„ Z8d„ Z9ed,d„«       Z: G d„ d e;«      Z<d!„ Z=d-d"„Z>d#„ Z?d$„ Z@d%„ ZAd&„ ZBd,d'„ZCd(„ ZD	 	 	 d.d)„ZEd*„ ZFy)/zVHelper functions for Cloud Storage utility classes.

These are *not* part of the API.
é    N)Úcontextmanager)Úmd5)ÚurlsplitÚ
urlunsplit)Úuuid4)Ú
exceptions)Úenvironment_vars)ÚNotFound)Ú_is_bucket_metadata_disabled)Úcreate_trace_span)Ú_DEFAULT_TIMEOUT)ÚDEFAULT_RETRYÚ)DEFAULT_RETRY_IF_METAGENERATION_SPECIFIEDÚSTORAGE_EMULATOR_HOSTÚAPI_ENDPOINT_OVERRIDEÚAPI_VERSION_OVERRIDEzgoogleapis.comzstorage.{universe_domain})Úuniverse_domainzhttps://Úv1))Úif_etag_matchzIf-Match)Úif_etag_not_matchzIf-None-Match))Úif_generation_matchÚifGenerationMatch)Úif_generation_not_matchÚifGenerationNotMatch)Úif_metageneration_matchÚifMetagenerationMatch)Úif_metageneration_not_matchÚifMetagenerationNotMatch)Úif_source_generation_matchÚifSourceGenerationMatch)Úif_source_generation_not_matchÚifSourceGenerationNotMatch)Úif_source_metageneration_matchÚifSourceMetagenerationMatch)Ú"if_source_metageneration_not_matchÚifSourceMetagenerationNotMatchc                  óJ   — t         j                  j                  t        d «      S ©N)ÚosÚenvironÚgetÚSTORAGE_EMULATOR_ENV_VAR© ó    úY/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/cloud/storage/_helpers.pyÚ_get_storage_emulator_overrider0   `   s   € Ü�:‰:�>‰>Ô2°DÓ9Ð9r.   c                  óL   — t        j                  t        t        t        z   «      S r(   )r)   ÚgetenvÚ_API_ENDPOINT_OVERRIDE_ENV_VARÚ_DEFAULT_SCHEMEÚ_TRUE_DEFAULT_STORAGE_HOSTr-   r.   r/   Ú_get_default_storage_base_urlr6   d   s   € Ü�9‰9Ü&¬Ô:TÑ(Tóð r.   c                  óH   — t        «       t        t        z   k7  r
t        «       S y)zIThis is an experimental configuration variable. Use api_endpoint instead.N)r6   r4   r5   r-   r.   r/   Ú_get_api_endpoint_overrider8   j   s   € ä$Ó&¬/Ô<VÑ*VÒVÜ,Ó.Ð.Ør.   c                 óz   — t        | «      }|› d|j                  › �}t        |j                  ||rdndddf«      }|S )z²Returns the scheme and netloc sections of the url, with the bucket
    prepended to the netloc.

    Not intended for use with netlocs which include a username and password.
    ú.ú/Ú )r   Únetlocr   Úscheme)ÚurlÚbucketÚtrailing_slashÚ
parsed_urlÚ
new_netlocÚbase_urls         r/   Ú_virtual_hosted_style_base_urlrE   q   sM   € ô ˜#“€JØ�8˜1˜Z×.Ñ.Ð/Ð0€JÜØ	×	Ñ	˜J©~©À2ÀrÈ2ÐNó€Hð €Or.   c                  óŒ   — t        j                  t        j                  t        j                  t        j                  «      «      S r(   )r)   r2   r	   ÚPROJECTÚLEGACY_PROJECTr-   r.   r/   Ú_get_environ_projectrI      s/   € Ü�9‰9Ü× Ñ Ü
�	‰	Ô"×1Ñ1Ó2óð r.   c                 ó€   — | €yt        | d   j                  «       | d   j                  «       g«      st        d«      ‚| S )zÁPre-flight ``Bucket`` name validation.

    :type name: str or :data:`NoneType`
    :param name: Proposed bucket name.

    :rtype: str or :data:`NoneType`
    :returns: ``name`` if valid.
    Nr   éÿÿÿÿz8Bucket names must start and end with a number or letter.)ÚallÚisalnumÚ
ValueError)Únames    r/   Ú_validate_namerP   †   sD   € ð €|Øô ��Q‘—‘Ó! 4¨¡8×#3Ñ#3Ó#5Ð6Ô7ÜÐSÓTÐTØ€Kr.   c              +   ón  K  — |rt        |«      ni }|r©t        |t        «      r™| r—t        | d«      r‹| j                  rt        «       su	 |dv r| j                  j                  |«      }n| j                  j                  |«      }|r7t        |t        «      r't        |«      dk(  r|\  }}|j                  ||dœ«       d|vr| r| |d<   t        |fd|i|¤Ž5 }
	 |
–— 	 d d d «       y # t        $ r"}	t        j                  d|	› �«       Y d }	~	ŒOd }	~	ww xY w# t        t         j                  f$ ry |rut        |t        «      re| rct        | d«      rW| j                  rK	 | j                  j#                  |«       ‚ # t        $ r"}	t        j                  d|	› �«       Y d }	~	‚ d }	~	ww xY w‚ w xY w# 1 sw Y   y xY w­w)	NÚ_bucket_metadata_cache)zStorage.Client.getBucketzStorage.Client.lookupBucketzStorage.Bucket.reloadzStorage.Bucket.existsé   )zgcp.resource.destination.idz!gcp.resource.destination.locationz1Failed cache lookup in create_trace_span_helper: ÚclientÚ
attributesz:Failed cache eviction on 404 in create_trace_span_helper: )ÚdictÚ
isinstanceÚstrÚhasattrrR   r   r+   Úget_or_queue_fetchÚtupleÚlenÚupdateÚ	ExceptionÚ_loggerÚdebugÚ_base_create_trace_spanr
   Úapi_exceptionsÚcheck_and_evict)rT   Úbucket_namerO   rU   ÚkwargsÚ
span_attrsÚcachedÚdest_idÚlocÚeÚspans              r/   Úcreate_trace_span_helperrl   ˜   sÈ  è ø€ á%/”�jÔ!°R€Jñ 	Ü�{¤CÔ(ÙÜ�FÐ4Ô5Ø×)Ò)Ü,Ô.ð	SØð ñ ð  ×6Ñ6×:Ñ:¸;ÓG‘à×6Ñ6×IÑIÈ+ÓV�áœ* V¬UÔ3¼¸F»ÀqÒ8HØ%‘�˜Ø×!Ñ!à7>Ø=@ñôð �vÑ¡&Ø!ˆˆxÑä	  Ñ	G°*Ð	GÀÑ	Gð È4ð	Ø‹J÷ð øô ò 	SÜ�M‰MÐMÈaÈSÐQ×RÑRûð	Sûô œ.×1Ñ1Ð2ò 	áÜ˜{¬CÔ0ÙÜ˜FÐ$<Ô=Ø×1Ò1ðØ×1Ñ1×AÑAÀ+ÔNð
 øô	 !ò Ü—M‘MØTÐUVÐTWÐX÷ð ð ûð	úð ð	ú÷ð üs†   ‚AF5Á	A4C& Â=F5ÃF)ÃDÃ	F5Ã&	DÃ/DÄF5ÄDÄF5ÄAF&ÅE6Å5F&Å6	F!Å?FÆF&ÆF!Æ!F&Æ&F)Æ)F2Æ.F5c                   óÐ   — e Zd ZdZdd„Zed„ «       Zed„ «       Zed„ «       Zd„ Z	e
dd„«       Zd	„ Zed
„ «       Zddddddddeedfd„Zd„ Zd„ Zdddddeedfd„Zdddddeedfd„Zy)Ú_PropertyMixina1  Abstract mixin for cloud storage classes with associated properties.

    Non-abstract subclasses should implement:
      - path
      - client
      - user_project

    :type name: str
    :param name: The name of the object. Bucket names must start and end with a
                 number or letter.
    Nc                 ó>   — || _         i | _        t        «       | _        y r(   )rO   Ú_propertiesÚsetÚ_changes)ÚselfrO   s     r/   Ú__init__z_PropertyMixin.__init__Þ   s   € ØˆŒ	ØˆÔÜ›ˆ�r.   c                 ó   — t         ‚)z$Abstract getter for the object path.©ÚNotImplementedError©rs   s    r/   Úpathz_PropertyMixin.pathã   ó
   € ô "Ð!r.   c                 ó   — t         ‚)z&Abstract getter for the object client.rv   rx   s    r/   rT   z_PropertyMixin.clientè   rz   r.   c                 ó   — t         ‚)z,Abstract getter for the object user_project.rv   rx   s    r/   Úuser_projectz_PropertyMixin.user_projectí   rz   r.   c                 ó"   — |€| j                   }|S )a£  Check client or verify over-ride.

        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: the client to use.  If not passed, falls back to the
                       ``client`` stored on the current object.

        :rtype: :class:`google.cloud.storage.client.Client`
        :returns: The client passed in or the currently bound client.
        )rT   )rs   rT   s     r/   Ú_require_clientz_PropertyMixin._require_clientò   s   € ð ˆ>Ø—[‘[ˆFØˆr.   c              +   ó
  K  — ddl m} ddlm} t	        | |«      r| j
                  }| j                  }nLt	        | |«      r<t        | dd «      }|rt        |d«      rt        |dd «      nd }|rt        |dd «      nd }nd }d }t        |«      r	  |«       }|j                  dd «      }
|
xs |}t        |||fd|i|¤Ž5 }|–— d d d «       y # t        $ r"}	t        j                  d|	› �«       Y d }	~	Œ\d }	~	ww xY w# 1 sw Y   y xY w­w)	Nr   )ÚBlob)ÚBucketr@   rT   rO   z>Failed callable bucket_name resolution in _create_trace_span: rU   )Úgoogle.cloud.storage.blobr�   Úgoogle.cloud.storage.bucketr‚   rW   rT   rO   ÚgetattrrY   Úcallabler^   r_   r`   Úpoprl   )rs   rO   rU   re   r�   r‚   rT   rd   r@   rj   Úclient_overrideÚactive_clientrk   s                r/   Ú_create_trace_spanz!_PropertyMixin._create_trace_span  s"  è ø€ å2Ý6ä�d˜FÔ#Ø—[‘[ˆFØŸ)™)‰KÜ˜˜dÔ#Ü˜T 8¨TÓ2ˆFñ œg f¨hÔ7ô ˜ ¨$Ô/àð ñ
 <Bœ' &¨&°$Ô7Àt‰KàˆFØˆKä�KÔ ðÙ)›m�ð !Ÿ*™* X¨tÓ4ˆØ'Ò1¨6ˆä%Ø˜;¨ñ
Ø9Cð
ØGMñ
ð 	àØŠJ÷	ð 	øô ò Ü—‘ØTÐUVÐTWÐX÷ñ ûðú÷	ð 	üsH   ‚B	DÂC	 Â(DÂ;C7Ã 	DÃ		C4ÃC/Ã*DÃ/C4Ã4DÃ7D Ã<Dc                 ó   — i S )a@  Return any encryption headers needed to fetch the object.

        .. note::
           Defined here because :meth:`reload` calls it, but this method is
           really only relevant for :class:`~google.cloud.storage.blob.Blob`.

        :rtype: dict
        :returns: a mapping of encryption-related headers.
        r-   rx   s    r/   Ú_encryption_headersz"_PropertyMixin._encryption_headers%  s	   € ð ˆ	r.   c                 ó@   — i }| j                   �| j                   |d<   |S )zDefault query parameters.ÚuserProject)r}   )rs   Úparamss     r/   Ú_query_paramsz_PropertyMixin._query_params1  s*   € ð ˆØ×ÑÐ(Ø$(×$5Ñ$5ˆF�=Ñ!Øˆr.   ÚnoAclc                 ó4  — | j                  |«      }| j                  }||d<   t        |||||¬«       |�||d<   | j                  |d<   | j	                  «       }t        |||¬«       |j                  | j                  |||	|
| ¬«      }| j                  |«       y)aÊ  Reload properties from Cloud Storage.

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

        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: the client to use. If not passed, falls back to the
                       ``client`` stored on the current object.

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

        :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
            the object metadata 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
        Ú
projection©r   r   r   r   NÚsoftDeletedÚ
generation)r   r   )Úquery_paramsÚheadersÚtimeoutÚretryÚ_target_object)	r   r�   Ú _add_generation_match_parametersr–   rŒ   Ú_add_etag_match_headersÚ_get_resourcery   Ú_set_properties)rs   rT   r“   r   r   r   r   r   r   r™   rš   Úsoft_deletedr—   r˜   Úapi_responses                  r/   Úreloadz_PropertyMixin.reload9  sÀ   € ðD ×%Ñ% fÓ-ˆØ×)Ñ)ˆð &0ˆ�\Ñ"Ü(ØØ 3Ø$;Ø$;Ø(Cõ	
ð Ð#Ø*6ˆL˜Ñ'ð *.¯©ˆL˜Ñ&Ø×*Ñ*Ó,ˆÜØ =ÐDUõ	
ð ×+Ñ+Ø�I‰IØ%ØØØØð ,ó 
ˆð 	×Ñ˜\Õ*r.   c                 óX   — | j                   j                  |«       || j                  |<   y)aµ  Update field of this object's properties.

        This method will only update the field provided and will not
        touch the other fields.

        It **will not** reload the properties from the server. The behavior is
        local only and syncing occurs via :meth:`patch`.

        :type name: str
        :param name: The field name to update.

        :type value: object
        :param value: The value being updated.
        N)rr   Úaddrp   )rs   rO   Úvalues      r/   Ú_patch_propertyz_PropertyMixin._patch_propertyš  s&   € ð 	�‰×Ñ˜$ÔØ!&ˆ×Ñ˜Òr.   c                 ó0   — || _         t        «       | _        y)z±Set the properties for the current object.

        :type value: dict or :class:`google.cloud.storage.batch._FutureDict`
        :param value: The properties to be set.
        N)rp   rq   rr   )rs   r¥   s     r/   rŸ   z_PropertyMixin._set_properties¬  s   € ð !ˆÔä›ˆ�r.   Fc	                 ó2  — | j                  |«      }| j                  }	d|	d<   |r||	d<   t        |	||||¬«       | j                  D �
ci c]  }
|
| j                  |
   “Œ }}
|j                  | j                  ||	| ||¬«      }| j                  |«       yc c}
w )aj  Sends all changed properties in a PATCH request.

        Updates the ``_properties`` with the response from the backend.

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

        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: the client to use. If not passed, falls back to the
                       ``client`` stored on the current object.

        :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 override_unlocked_retention: bool
        :param override_unlocked_retention:
            (Optional) override_unlocked_retention must be set to True if the operation includes
            a retention property that changes the mode from Unlocked to Locked, reduces the
            retainUntilTime, or removes the retention configuration from the object. See:
            https://cloud.google.com/storage/docs/json_api/v1/objects/patch
        Úfullr“   ÚoverrideUnlockedRetentionr”   )r—   r›   r™   rš   N)r   r�   rœ   rr   rp   Ú_patch_resourcery   rŸ   )rs   rT   r   r   r   r   r™   rš   Úoverride_unlocked_retentionr—   ÚkeyÚupdate_propertiesr¡   s                r/   Úpatchz_PropertyMixin.patch¶  sÀ   € ðl ×%Ñ% fÓ-ˆØ×)Ñ)ˆð &,ˆ�\Ñ"Ù&Ø8SˆLÐ4Ñ5Ü(ØØ 3Ø$;Ø$;Ø(Cõ	
ð DHÇ=Á=ÖQ¸C˜S $×"2Ñ"2°3Ñ"7Ñ7ÐQÐÐQð ×-Ñ-Ø�I‰IØØ%ØØØð .ó 
ˆð 	×Ñ˜\Õ*ùò Rs   ÁBc	                 óî   — | j                  |«      }| j                  }	d|	d<   |r||	d<   t        |	||||¬«       |j                  | j                  | j
                  |	||| ¬«      }
| j                  |
«       y)a`  Sends all properties in a PUT request.

        Updates the ``_properties`` with the response from the backend.

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

        :type client: :class:`~google.cloud.storage.client.Client` or
                      ``NoneType``
        :param client: the client to use. If not passed, falls back to the
                       ``client`` stored on the current object.

        :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 override_unlocked_retention: bool
        :param override_unlocked_retention:
            (Optional) override_unlocked_retention must be set to True if the operation includes
            a retention property that changes the mode from Unlocked to Locked, reduces the
            retainUntilTime, or removes the retention configuration from the object. See:
            https://cloud.google.com/storage/docs/json_api/v1/objects/patch
        r©   r“   rª   r”   )r—   r™   rš   r›   N)r   r�   rœ   Ú_put_resourcery   rp   rŸ   )rs   rT   r   r   r   r   r™   rš   r¬   r—   r¡   s              r/   r]   z_PropertyMixin.update  s’   € ðl ×%Ñ% fÓ-ˆà×)Ñ)ˆØ%+ˆ�\Ñ"Ù&Ø8SˆLÐ4Ñ5Ü(ØØ 3Ø$;Ø$;Ø(Cõ	
ð ×+Ñ+Ø�I‰IØ×ÑØ%ØØØð ,ó 
ˆð 	×Ñ˜\Õ*r.   r(   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__rt   Úpropertyry   rT   r}   r   r   rŠ   rŒ   r�   r   r   r¢   r¦   rŸ   r¯   r   r]   r-   r.   r/   rn   rn   Ñ   sð   „ ñ
óð
 ñ"ó ð"ð ñ"ó ð"ð ñ"ó ð"òð ò!ó ð!òF
ð ñó ðð ØØØØ Ø $Ø $Ø$(Ø ØØó_+òB'ò$ð Ø Ø $Ø $Ø$(Ø ØØ$)óO+ðf Ø Ø $Ø $Ø$(Ø Ø7Ø$)ôL+r.   rn   c                 ó0   ‡ — ˆ fd„}ˆ fd„}t        ||«      S )zHCreate a property descriptor around the :class:`_PropertyMixin` helpers.c                 ó:   •— | j                   j                  ‰«      S )zScalar property getter.)rp   r+   )rs   Ú	fieldnames    €r/   Ú_getterz!_scalar_property.<locals>._getterY  s   ø€ à×Ñ×#Ñ# IÓ.Ð.r.   c                 ó*   •— | j                  ‰|«       y)zScalar property setter.N)r¦   )rs   r¥   r¹   s     €r/   Ú_setterz!_scalar_property.<locals>._setter]  s   ø€ à×Ñ˜Y¨Õ.r.   )r¶   )r¹   rº   r¼   s   `  r/   Ú_scalar_propertyr½   V  s   ø€ ô/ô/ô �G˜WÓ%Ð%r.   c                 ó¦   — | j                  |«      }t        |«      dkD  r2|j                  |«       | j                  |«      }t        |«      dkD  rŒ1yy)a¯  Read blocks from a buffer and update a hash with them.

    :type buffer_object: bytes buffer
    :param buffer_object: Buffer containing bytes used to update a hash object.

    :type hash_obj: object that implements update
    :param hash_obj: A hash object (MD5 or CRC32-C).

    :type digest_block_size: int
    :param digest_block_size: The block size to write to the hash.
                              Defaults to 8192.
    r   N)Úreadr\   r]   )Úbuffer_objectÚhash_objÚdigest_block_sizeÚblocks       r/   Ú_write_buffer_to_hashrÄ   d  sJ   € ð ×ÑÐ0Ó1€Eä
ˆe‹*�qŠ.Ø�‰˜Ôà×"Ñ"Ð#4Ó5ˆô ˆe‹*�q�.r.   c                 ó¸   — t         j                  dk\  rt        d¬«      }n
t        «       }t        | |«       |j	                  «       }t        j                  |«      S )a  Get MD5 hash of bytes (as base64).

    :type buffer_object: bytes buffer
    :param buffer_object: Buffer containing bytes used to compute an MD5
                          hash (as base64).

    :rtype: str
    :returns: A base64 encoded digest of the MD5 hash.
    )é   é	   F)Úusedforsecurity)ÚsysÚversion_infor   rÄ   ÚdigestÚbase64Ú	b64encode)rÀ   rÁ   Údigest_bytess      r/   Ú_base64_md5hashrÏ   y  sJ   € ô ×Ñ˜6Ò!Ü uÔ-‰ä“5ˆÜ˜-¨Ô2Ø—?‘?Ó$€LÜ×Ñ˜LÓ)Ð)r.   c                 ó–   — t         D ]@  \  }}|j                  |«      }|€Œt        |t        «      r|g}dj	                  |«      | |<   ŒB y)zßAdd generation match parameters into the given parameters list.

    :type headers: dict
    :param headers: Headers dict.

    :type match_parameters: dict
    :param match_parameters: if*etag*match parameters to add.
    Nú, )Ú_ETAG_MATCH_PARAMETERSr+   rW   rX   Újoin)r˜   Úmatch_parametersÚsnakecase_nameÚheader_namer¥   s        r/   r�   r�   Œ  sR   € ô (>ò 4Ñ#ˆ˜Ø ×$Ñ$ ^Ó4ˆàÑÜ˜%¤Ô%Ø˜�Ø#'§9¡9¨UÓ#3ˆG�KÒ ñ4r.   c                 óÐ   — t         D ]]  \  }}|j                  |«      }|€Œt        | t        «      r| j	                  ||f«       Œ>t        | t
        «      r|| |<   ŒTt        d«      ‚ y)ab  Add generation match parameters into the given parameters list.

    :type parameters: list or dict
    :param parameters: Parameters list or dict.

    :type match_parameters: dict
    :param match_parameters: if*generation*match parameters to add.

    :raises: :exc:`ValueError` if ``parameters`` is not a ``list()``
             or a ``dict()``.
    Nz5`parameters` argument should be a dict() or a list().)Ú_GENERATION_MATCH_PARAMETERSr+   rW   ÚlistÚappendrV   rN   )Ú
parametersrÔ   rÕ   Úcamelcase_namer¥   s        r/   rœ   rœ   ž  sr   € ô +Gò Ñ&ˆ˜Ø ×$Ñ$ ^Ó4ˆàÑÜ˜*¤dÔ+Ø×!Ñ! >°5Ð"9Õ:ä˜J¬Ô-Ø-2�
˜>Ò*ô !ØKóð ñr.   c                  óî   — t        d„ | j                  «       D «       «      dkD  rM| j                  «       D �cg c]  }d|› d�‘Œ
 }}dj                  |dd «      }|d   }d|› d|› �}t	        |«      ‚yc c}w )	zéRaise ``ValueError`` exception if more than one parameter was set.

    :type error: :exc:`ValueError`
    :param error: Description of which fields were set

    :raises: :class:`~ValueError` containing the fields that were set
    c              3   ó$   K  — | ]  }|d u–— Œ
 y ­wr(   r-   )Ú.0Úargs     r/   ú	<genexpr>z._raise_if_more_than_one_set.<locals>.<genexpr>Â  s   è ø€ Ò
6˜sˆ3�dŒ?Ñ
6ùs   ‚é   ú'rÑ   NrK   zPass at most one of z and )ÚsumÚvaluesÚkeysrÓ   rN   )re   rO   Úescaped_keysÚkeys_but_lastÚlast_keyÚmsgs         r/   Ú_raise_if_more_than_one_setrë   º  s�   € ô Ñ
6 f§m¡m£oÔ
6Ó6¸Ò:Ø06·±³Ö>¨˜!˜D˜6 šÐ>ˆÐ>àŸ	™	 ,¨s°Ð"3Ó4ˆØ Ñ#ˆà$ ] O°5¸¸
ÐCˆä˜‹oÐð ;ùÚ>s   ¶A2c                 óZ   — t        | «      }|j                  r|j                  r| S |› d| › �S )a!  Helper to build bucket bound hostname URL.

    :type host: str
    :param host: Host name.

    :type scheme: str
    :param scheme: (Optional) Web scheme. If passed, use it
                   as a scheme in the result URL.

    :rtype: str
    :returns: A bucket bound hostname URL.
    z://)r   r>   r=   )Úhostr>   Ú	url_partss      r/   Ú_bucket_bound_hostname_urlrï   Í  s4   € ô ˜“€IØ×Ò˜I×,Ò,ØˆàˆX�S˜˜ÐÐr.   c                  ó.   — dt        t        «       «      z   S )Nzgccl-invocation-id/)rX   r   r-   r.   r/   Ú_get_invocation_idrñ   á  s   € Ø ¤3¤u£w£<Ñ/Ð/r.   c                 óN   — | › dt        «       › �}|r|d|› �z  }dd| |||xs |dœS )a§  Get the headers for a request.

    :type user_agent: str
    :param user_agent: The user-agent for requests.

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

    :rtype: dict
    :returns: The headers to be used for the request.
    ú z gccl-gcs-cmd/zapplication/jsonzgzip, deflate)ÚAcceptzAccept-Encodingz
User-AgentzX-Goog-API-Clientzcontent-typezx-upload-content-type)rñ   )Ú
user_agentÚcontent_typeÚx_upload_content_typeÚcommandÚx_goog_api_clients        r/   Ú_get_default_headersrú   å  sR   € ð( &˜, aÔ(:Ó(<Ð'=Ð>ÐáØ˜~¨g¨YÐ7Ñ7Ðð %Ø*Ø Ø.Ø$Ø!6Ò!F¸,ñð r.   c                  óX   — t        j                  d«      } t        j                  | d«      S )a  Generates a secure 56 bit random integer.


    If 64 bit int is used, sometimes the random int generated is greater than
    max positive value of signed 64 bit int which is 2^63 -1 causing overflow
    issues.

    :rtype: int
    :returns: A secure random 56 bit integer.
    é   Úbig)ÚsecretsÚtoken_bytesÚintÚ
from_bytes)Úrandom_bytess    r/   Úgenerate_random_56_bit_integerr    s%   € ô ×&Ñ& qÓ)€Lä�>‰>˜,¨Ó.Ð.r.   )Fr(   )i    )zapplication/json; charset=UTF-8NN)Grµ   rÌ   ÚdatetimeÚloggingr)   rþ   rÉ   Ú
contextlibr   Úhashlibr   Úurllib.parser   r   Úuuidr   Úgoogle.api_corer   rb   Úgoogle.authr	   Úgoogle.cloud.exceptionsr
   Ú+google.cloud.storage._opentelemetry_tracingr   r   ra   Úgoogle.cloud.storage.constantsr   Úgoogle.cloud.storage.retryr   r   Ú	getLoggerr²   r_   r,   r3   Ú_API_VERSION_OVERRIDE_ENV_VARÚ_DEFAULT_UNIVERSE_DOMAINÚ_STORAGE_HOST_TEMPLATEÚformatr5   r4   r2   Ú_API_VERSIONrÒ   rØ   ÚnowÚ_NOWÚtimezoneÚutcÚ_UTCr0   r6   r8   rE   rI   rP   rl   Úobjectrn   r½   rÄ   rÏ   r�   rœ   rë   rï   rñ   rú   r  r-   r.   r/   ú<module>r     sl  ðñó
 Û Û Û 	Û Û 
Ý %Ý ß -Ý å 8Ý (Ý ,õõõ <÷ð
 ˆ'×
Ñ
˜HÓ
%€à2Ð Ø >à!8Ð Ø Oà 6Ð Ø Oà+Ð à4Ð à3×:Ñ:Ø,ð ;ó Ð ð €àˆr�y‰yÐ6¸Ó=€Ø -ðÐ ð	 Ð ð ×Ñ×Ñ€Ø×Ñ×Ñ€ò:òòóòòð$ ò5ó ð5ôpB+�Vô B+òJ&ó6ò**ò&4ò$ò8ó& ò(0ð 3ØØó	 óF/r.   