Ë
    ö%9jÓ?  ã                   óÌ   — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	 dZ
dZd	Zd
ZdZdZdZdZdZej'                  ee«      Z ej*                  e«      ZdZ G d„ de«      Zd„ Zy)zÇConfigure bucket notification resources to interact with Google Cloud Pub/Sub.

See [Cloud Pub/Sub Notifications for Google Cloud Storage](https://cloud.google.com/storage/docs/pubsub-notifications)
é    N)ÚNotFound)Úcreate_trace_span)Ú_DEFAULT_TIMEOUT)ÚDEFAULT_RETRYÚOBJECT_FINALIZEÚOBJECT_METADATA_UPDATEÚOBJECT_DELETEÚOBJECT_ARCHIVEÚJSON_API_V1ÚNONEz-//pubsub.googleapis.com/projects/{}/topics/{}z)(?P<project>[a-z][a-z0-9-]{4,28}[a-z0-9])z (?P<name>[A-Za-z](\w|[-_.~+%])+)zpResource has invalid topic: {}; see https://cloud.google.com/storage/docs/json_api/v1/notifications/insert#topicc                   ó:  — e Zd ZdZdddddedfd„Zed„ «       Zed„ «       Z	ed„ «       Z
ed„ «       Zed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Zd„ Zdedfd„Zdeefd„Zdeefd„Zdeefd„Zy)ÚBucketNotificationaÏ  Represent a single notification resource for a bucket.

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

    :type bucket: :class:`google.cloud.storage.bucket.Bucket`
    :param bucket: Bucket to which the notification is bound.

    :type topic_name: str
    :param topic_name:
        (Optional) Topic name to which notifications are published.

    :type topic_project: str
    :param topic_project:
        (Optional) Project ID of topic to which notifications are published.
        If not passed, uses the project ID of the bucket's client.

    :type custom_attributes: dict
    :param custom_attributes:
        (Optional) Additional attributes passed with notification events.

    :type event_types: list(str)
    :param event_types:
        (Optional) Event types for which notification events are published.

    :type blob_name_prefix: str
    :param blob_name_prefix:
        (Optional) Prefix of blob names for which notification events are
        published.

    :type payload_format: str
    :param payload_format:
        (Optional) Format of payload for notification events.

    :type notification_id: str
    :param notification_id:
        (Optional) The ID of the notification.
    Nc	                 ó,  — || _         || _        |€|j                  j                  }|€t	        d«      ‚|| _        i | _        |�|| j                  d<   |�|| j                  d<   |�|| j                  d<   |�|| j                  d<   || j                  d<   y )Nz8Client project not set:  pass an explicit topic_project.Úcustom_attributesÚevent_typesÚobject_name_prefixÚidÚpayload_format)Ú_bucketÚ_topic_nameÚclientÚprojectÚ
ValueErrorÚ_topic_projectÚ_properties)	ÚselfÚbucketÚ
topic_nameÚtopic_projectr   r   Úblob_name_prefixr   Únotification_ids	            ú]/var/www/html/truck-me/venv/lib/python3.12/site-packages/google/cloud/storage/notification.pyÚ__init__zBucketNotification.__init__W   sµ   € ð ˆŒØ%ˆÔàÐ Ø"ŸM™M×1Ñ1ˆMàÐ ÜÐWÓXÐXà+ˆÔàˆÔàÐ(Ø4EˆD×ÑÐ0Ñ1àÐ"Ø.9ˆD×Ñ˜]Ñ+àÐ'Ø5EˆD×ÑÐ1Ñ2àÐ&Ø%4ˆD×Ñ˜TÑ"à-;ˆ×ÑÐ)Ò*ó    c                 ó‚   — |j                  d«      }|€t        d«      ‚t        |«      \  }} | |||¬«      }||_        |S )aÎ  Construct an instance from the JSON repr returned by the server.

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

        :type resource: dict
        :param resource: JSON repr of the notification

        :type bucket: :class:`google.cloud.storage.bucket.Bucket`
        :param bucket: Bucket to which the notification is bound.

        :rtype: :class:`BucketNotification`
        :returns: the new notification instance
        ÚtopiczResource has no topic)r   )Úgetr   Ú_parse_topic_pathr   )ÚclsÚresourcer   Ú
topic_pathÚnamer   Úinstances          r"   Úfrom_api_reprz BucketNotification.from_api_repr}   sM   € ð —\‘\ 'Ó*ˆ
ØÐÜÐ4Ó5Ð5ä)¨*Ó5‰ˆˆgÙ�v˜t°7Ô;ˆØ'ˆÔàˆr$   c                 ó   — | j                   S )z*Bucket to which the notification is bound.)r   ©r   s    r"   r   zBucketNotification.bucket–   s   € ð �|‰|Ðr$   c                 ó   — | j                   S )z0Topic name to which notifications are published.)r   r0   s    r"   r   zBucketNotification.topic_name›   s   € ð ×ÑÐr$   c                 ó   — | j                   S )z9Project ID of topic to which notifications are published.)r   r0   s    r"   r   z BucketNotification.topic_project    s   € ð ×"Ñ"Ð"r$   c                 ó8   — | j                   j                  d«      S )z2Custom attributes passed with notification events.r   ©r   r'   r0   s    r"   r   z$BucketNotification.custom_attributes¥   s   € ð ×Ñ×#Ñ#Ð$7Ó8Ð8r$   c                 ó8   — | j                   j                  d«      S )z8Event types for which notification events are published.r   r4   r0   s    r"   r   zBucketNotification.event_typesª   s   € ð ×Ñ×#Ñ# MÓ2Ð2r$   c                 ó8   — | j                   j                  d«      S )zAPrefix of blob names for which notification events are published.r   r4   r0   s    r"   r    z#BucketNotification.blob_name_prefix¯   s   € ð ×Ñ×#Ñ#Ð$8Ó9Ð9r$   c                 ó8   — | j                   j                  d«      S )z)Format of payload of notification events.r   r4   r0   s    r"   r   z!BucketNotification.payload_format´   s   € ð ×Ñ×#Ñ#Ð$4Ó5Ð5r$   c                 ó8   — | j                   j                  d«      S )z'Server-set ID of notification resource.r   r4   r0   s    r"   r!   z"BucketNotification.notification_id¹   s   € ð ×Ñ×#Ñ# DÓ)Ð)r$   c                 ó8   — | j                   j                  d«      S )ú)Server-set ETag of notification resource.Úetagr4   r0   s    r"   r;   zBucketNotification.etag¾   s   € ð ×Ñ×#Ñ# FÓ+Ð+r$   c                 ó8   — | j                   j                  d«      S )r:   ÚselfLinkr4   r0   s    r"   Ú	self_linkzBucketNotification.self_linkÃ   s   € ð ×Ñ×#Ñ# JÓ/Ð/r$   c                 ó.   — | j                   j                  S )z%The client bound to this notfication.)r   r   r0   s    r"   r   zBucketNotification.clientÈ   s   € ð �{‰{×!Ñ!Ð!r$   c                 óN   — d| j                   j                  › d| j                  › �S )z#The URL path for this notification.ú/b/z/notificationConfigs/)r   r,   r!   r0   s    r"   ÚpathzBucketNotification.pathÍ   s*   € ð �T—[‘[×%Ñ%Ð&Ð&;¸D×<PÑ<PÐ;QÐRÐRr$   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.

        :rtype: :class:`google.cloud.storage.client.Client`
        :returns: The client passed in or the bucket's client.
        )r   )r   r   s     r"   Ú_require_clientz"BucketNotification._require_clientÒ   s   € ð ˆ>Ø—[‘[ˆFØˆr$   c                 ón   — | j                   j                  «        | j                   j                  |«       y)zwHelper for :meth:`reload`.

        :type response: dict
        :param response: resource mapping from server
        N)r   ÚclearÚupdate)r   Úresponses     r"   Ú_set_propertiesz"BucketNotification._set_propertiesà   s*   € ð 	×Ñ×ÑÔ Ø×Ñ×Ñ Õ)r$   c                 ól  — t        d¬«      5  | j                  �t        d| j                  › d�«      ‚| j                  |«      }i }| j                  j
                  �| j                  j
                  |d<   d| j                  j                  › d�}| j                  j                  «       }| j                  €$t        j                  | j                  d	«      |d
<   n-t        j                  | j                  | j                  «      |d
<   |j                  |||||¬«      | _        ddd«       y# 1 sw Y   yxY w)a¢  API wrapper: create the notification.

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

        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 notification'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 retry: google.api_core.retry.Retry or google.cloud.storage.retry.ConditionalRetryPolicy
        :param retry:
            (Optional) How to retry the RPC. See: :ref:`configuring_retries`

        :raises ValueError: if the notification already exists.
        z!Storage.BucketNotification.create©r,   Nznotification_id already set to z(; must be None to create a Notification.ÚuserProjectrA   z/notificationConfigsÚ r&   ©Úquery_paramsÚtimeoutÚretry)r   r!   r   rD   r   Úuser_projectr,   r   Úcopyr   Ú_TOPIC_REF_FMTÚformatr   Ú_post_resource)r   r   rP   rQ   rO   rB   Ú
propertiess          r"   ÚcreatezBucketNotification.createé   s-  € ô. Ð$GÔHñ 	Ø×#Ñ#Ð/Ü Ø5°d×6JÑ6JÐ5KÐKsÐtóð ð ×)Ñ)¨&Ó1ˆFàˆLØ�{‰{×'Ñ'Ð3Ø.2¯k©k×.FÑ.F�˜]Ñ+à˜Ÿ™×)Ñ)Ð*Ð*>Ð?ˆDØ×)Ñ)×.Ñ.Ó0ˆJà�‰Ð&Ü&4×&;Ñ&;¸D×<NÑ<NÐPRÓ&S�
˜7Ò#ä&4×&;Ñ&;Ø×&Ñ&¨¯©ó'�
˜7Ñ#ð  &×4Ñ4ØØØ)ØØð  5ó  ˆDÔ÷-	÷ 	ñ 	ús   �DD*Ä*D3c                 óh  — t        d¬«      5  | j                  €t        d«      ‚| j                  |«      }i }| j                  j
                  �| j                  j
                  |d<   	 |j                  | j                  |||¬«       	 ddd«       y# t        $ r Y ddd«       yw xY w# 1 sw Y   yxY w)	a  Test whether this notification exists.

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

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

        :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 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: bool
        :returns: True, if the notification exists, else False.
        :raises ValueError: if the notification has no ID.
        z!Storage.BucketNotification.existsrK   Nú8Notification ID not set: set an explicit notification_idrL   rN   TF)	r   r!   r   rD   r   rR   Ú_get_resourcerB   r   ©r   r   rP   rQ   rO   s        r"   ÚexistszBucketNotification.exists  sÉ   € ô4 Ð$GÔHñ 	Ø×#Ñ#Ð+Ü ØNóð ð ×)Ñ)¨&Ó1ˆFàˆLØ�{‰{×'Ñ'Ð3Ø.2¯k©k×.FÑ.F�˜]Ñ+ð
Ø×$Ñ$Ø—I‘IØ!-Ø#Øð	 %ô ð ÷-	ð 	øô& ò Ø÷)	ð 	ð&ú÷'	ð 	ús0   �AB(Á(BÂB(Â	B%ÂB(Â$B%Â%B(Â(B1c                 óX  — t        d¬«      5  | j                  €t        d«      ‚| j                  |«      }i }| j                  j
                  �| j                  j
                  |d<   |j                  | j                  |||¬«      }| j                  |«       ddd«       y# 1 sw Y   yxY w)aÌ  Update this notification from the server configuration.

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

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

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


        :raises ValueError: if the notification has no ID.
        z!Storage.BucketNotification.reloadrK   NrZ   rL   rN   )	r   r!   r   rD   r   rR   r[   rB   rI   )r   r   rP   rQ   rO   rH   s         r"   ÚreloadzBucketNotification.reloadP  s®   € ô2 Ð$GÔHñ 	+Ø×#Ñ#Ð+Ü ØNóð ð ×)Ñ)¨&Ó1ˆFàˆLØ�{‰{×'Ñ'Ð3Ø.2¯k©k×.FÑ.F�˜]Ñ+à×+Ñ+Ø—	‘	Ø)ØØð	 ,ó ˆHð × Ñ  Ô*÷%	+÷ 	+ñ 	+ús   �B
B Â B)c                 ó6  — t        d¬«      5  | j                  €t        d«      ‚| j                  |«      }i }| j                  j
                  �| j                  j
                  |d<   |j                  | j                  |||¬«       ddd«       y# 1 sw Y   yxY w)a  Delete this notification.

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

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

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

        :raises: :class:`google.api_core.exceptions.NotFound`:
            if the notification does not exist.
        :raises ValueError: if the notification has no ID.
        z!Storage.BucketNotification.deleterK   NrZ   rL   rN   )r   r!   r   rD   r   rR   Ú_delete_resourcerB   r\   s        r"   ÚdeletezBucketNotification.delete}  sœ   € ô4 Ð$GÔHñ 	Ø×#Ñ#Ð+Ü ØNóð ð ×)Ñ)¨&Ó1ˆFàˆLØ�{‰{×'Ñ'Ð3Ø.2¯k©k×.FÑ.F�˜]Ñ+à×#Ñ#Ø—	‘	Ø)ØØð	 $ô ÷	÷ 	ñ 	ús   �A9BÂB)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚNONE_PAYLOAD_FORMATr#   Úclassmethodr.   Úpropertyr   r   r   r   r   r    r   r!   r;   r>   r   rB   rD   rI   r   rX   r   r]   r_   rb   © r$   r"   r   r   0   st  „ ñ$ðR ØØØØØ*Øó$<ðL ñó ðð0 ñó ðð ñ ó ð ð ñ#ó ð#ð ñ9ó ð9ð ñ3ó ð3ð ñ:ó ð:ð ñ6ó ð6ð ñ*ó ð*ð ñ,ó ð,ð ñ0ó ð0ð ñ"ó ð"ð ñSó ðSòò*ð !Ð*:À$ó 3ðj !Ð*:À-ó 0ðd !Ð*:À-ó ++ðZ !Ð*:À-ô +r$   r   c                 ó°   — t         j                  | «      }|€t        t        j	                  | «      «      ‚|j                  d«      |j                  d«      fS )aë  Verify that a topic path is in the correct format.

    Expected to be of the form:

        //pubsub.googleapis.com/projects/{project}/topics/{topic}

    where the ``project`` value must be "6 to 30 lowercase letters, digits,
    or hyphens. It must start with a letter. Trailing hyphens are prohibited."
    (see [`resource manager docs`](https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects#Project.FIELDS.project_id))
    and ``topic`` must have length at least two,
    must start with a letter and may only contain alphanumeric characters or
    ``-``, ``_``, ``.``, ``~``, ``+`` or ``%`` (i.e characters used for URL
    encoding, see [`topic spec`](https://cloud.google.com/storage/docs/json_api/v1/notifications/insert#topic)).

    Args:
        topic_path (str): The topic path to be verified.

    Returns:
        Tuple[str, str]: The ``project`` and ``topic`` parsed from the
        ``topic_path``.

    Raises:
        ValueError: If the topic path is invalid.
    r,   r   )Ú_TOPIC_REF_REÚmatchr   Ú
_BAD_TOPICrU   Úgroup)r+   rm   s     r"   r(   r(   «  sL   € ô2 ×Ñ 
Ó+€EØ€}Üœ×*Ñ*¨:Ó6Ó7Ð7à�;‰;�vÓ §¡¨IÓ 6Ð6Ð6r$   )rf   ÚreÚgoogle.api_core.exceptionsr   Ú+google.cloud.storage._opentelemetry_tracingr   Úgoogle.cloud.storage.constantsr   Úgoogle.cloud.storage.retryr   ÚOBJECT_FINALIZE_EVENT_TYPEÚ!OBJECT_METADATA_UPDATE_EVENT_TYPEÚOBJECT_DELETE_EVENT_TYPEÚOBJECT_ARCHIVE_EVENT_TYPEÚJSON_API_V1_PAYLOAD_FORMATrg   rT   Ú_PROJECT_PATTERNÚ_TOPIC_NAME_PATTERNrU   Ú_TOPIC_REF_PATTERNÚcompilerl   rn   Úobjectr   r(   rj   r$   r"   ú<module>r      s”   ðñó
 
å /å IÝ ;Ý 4à.Ð Ø$<Ð !Ø*Ð Ø,Ð à*Ð ØÐ à@€Ø?Ð Ø9Ð Ø#×*Ñ*Ð+;Ð=PÓQÐ Ø�—
‘
Ð-Ó.€ð!ð ôx˜ô xóv7r$   