
    (ph?                         S 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r
SrS	rS
rSrSrSrSrSr\R'                  \\5      r\R*                  " \5      rSr " S S\5      rS rg)zConfigure 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                   L   \ rS rSrSrSSSSS\S4S jr\S 5       r\	S 5       r
\	S 5       r\	S 5       r\	S	 5       r\	S
 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       r\	S 5       rS rS rS\S4S jrS\\4S jrS\\4S jrS\\4S jrSrg)BucketNotification1   ac  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	                 (   Xl         X l        Uc  UR                  R                  nUc  [	        S5      eX0l        0 U l        Ub  X@R                  S'   Ub  XPR                  S'   Ub  X`R                  S'   Ub  XR                  S'   XpR                  S'   g )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	            T/var/www/html/venv/lib/python3.13/site-packages/google/cloud/storage/notification.py__init__BucketNotification.__init__X   s     % "MM11M WXX+(4E01".9]+'5E12&%4T"-;)*    c                 x    UR                  S5      nUc  [        S5      e[        U5      u  pEU " X$US9nXl        U$ )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_repr BucketNotification.from_api_repr~   sG     \\'*
455)*5v7;'r&   c                     U R                   $ )z*Bucket to which the notification is bound.)r   r   s    r#   r   BucketNotification.bucket   s     ||r&   c                     U R                   $ )z0Topic name to which notifications are published.)r   r3   s    r#   r   BucketNotification.topic_name   s     r&   c                     U R                   $ )z9Project ID of topic to which notifications are published.)r   r3   s    r#   r     BucketNotification.topic_project   s     """r&   c                 8    U R                   R                  S5      $ )z2Custom attributes passed with notification events.r   r   r)   r3   s    r#   r   $BucketNotification.custom_attributes   s     ##$788r&   c                 8    U R                   R                  S5      $ )z8Event types for which notification events are published.r   r:   r3   s    r#   r   BucketNotification.event_types   s     ##M22r&   c                 8    U R                   R                  S5      $ )zAPrefix of blob names for which notification events are published.r   r:   r3   s    r#   r!   #BucketNotification.blob_name_prefix   s     ##$899r&   c                 8    U R                   R                  S5      $ )z)Format of payload of notification events.r   r:   r3   s    r#   r   !BucketNotification.payload_format   s     ##$455r&   c                 8    U R                   R                  S5      $ )z'Server-set ID of notification resource.r   r:   r3   s    r#   r"   "BucketNotification.notification_id   s     ##D))r&   c                 8    U R                   R                  S5      $ ))Server-set ETag of notification resource.etagr:   r3   s    r#   rF   BucketNotification.etag   s     ##F++r&   c                 8    U R                   R                  S5      $ )rE   selfLinkr:   r3   s    r#   	self_linkBucketNotification.self_link   s     ##J//r&   c                 .    U R                   R                  $ )z%The client bound to this notfication.)r   r   r3   s    r#   r   BucketNotification.client   s     {{!!!r&   c                 N    SU R                   R                   SU R                   3$ )z#The URL path for this notification./b/z/notificationConfigs/)r   r.   r"   r3   s    r#   pathBucketNotification.path   s*     T[[%%&&;D<P<P;QRRr&   c                 $    Uc  U R                   nU$ )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_client"BucketNotification._require_client   s     >[[Fr&   c                 n    U R                   R                  5         U R                   R                  U5        g)z_Helper for :meth:`reload`.

:type response: dict
:param response: resource mapping from server
N)r   clearupdate)r   responses     r#   _set_properties"BucketNotification._set_properties   s*     	 )r&   c           	      p   [        SS9   U R                  b  [        SU R                   S35      eU R                  U5      n0 nU R                  R
                  b  U R                  R
                  US'   SU R                  R                   S3nU R                  R                  5       nU R                  c$  [        R                  U R                  S	5      US
'   O-[        R                  U R                  U R                  5      US
'   UR                  UUUUUS9U l        SSS5        g! , (       d  f       g= f)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.userProjectrO   z/notificationConfigs r(   query_paramstimeoutretry)r   r"   r   rS   r   user_projectr.   r   copyr   _TOPIC_REF_FMTformatr    _post_resource)r   r   ra   rb   r`   rP   
propertiess          r#   createBucketNotification.create   s%   . $GH##/ 5d6J6J5KKst  ))&1FL{{''3.2kk.F.F]+))**>?D))..0J&&4&;&;D<N<NPR&S
7#&4&;&;&&'
7#  &44)  5  D- IHHs   DD''
D5c                 l   [        SS9   U R                  c  [        S5      eU R                  U5      n0 nU R                  R
                  b  U R                  R
                  US'    UR                  U R                  UUUS9   SSS5        g! [         a     SSS5        gf = f! , (       d  f       g= f)	aw  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.existsr\   N8Notification ID not set: set an explicit notification_idr]   r_   TF)	r   r"   r   rS   r   rc   _get_resourcerP   r   r   r   ra   rb   r`   s        r#   existsBucketNotification.exists  s    4 $GH##+ N  ))&1FL{{''3.2kk.F.F]+
$$II!-#	 %  - IH&  ) IH&' IHs0   AB%'BB%
B"B%!B""B%%
B3c                 Z   [        SS9   U R                  c  [        S5      eU R                  U5      n0 nU R                  R
                  b  U R                  R
                  US'   UR                  U R                  UUUS9nU R                  U5        SSS5        g! , (       d  f       g= f)aD  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.reloadr\   Nrl   r]   r_   )	r   r"   r   rS   r   rc   rm   rP   rY   )r   r   ra   rb   r`   rX   s         r#   reloadBucketNotification.reloadQ  s    2 $GH##+ N  ))&1FL{{''3.2kk.F.F]+++		)	 , H   *% IHHs   B	B
B*c                 8   [        SS9   U R                  c  [        S5      eU R                  U5      n0 nU R                  R
                  b  U R                  R
                  US'   UR                  U R                  UUUS9  SSS5        g! , (       d  f       g= f)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.deleter\   Nrl   r]   r_   )r   r"   r   rS   r   rc   _delete_resourcerP   rn   s        r#   deleteBucketNotification.delete~  s    4 $GH##+ N  ))&1FL{{''3.2kk.F.F]+##		)	 $  IHHs   A8B
B)r   r   r   r   )__name__
__module____qualname____firstlineno____doc__NONE_PAYLOAD_FORMATr$   classmethodr0   propertyr   r   r    r   r   r!   r   r"   rF   rJ   r   rP   rS   rY   r   ri   r   ro   rr   rv   __static_attributes__ r&   r#   r   r   1   st   $R *$<L  0       # # 9 9 3 3 : : 6 6 * * , , 0 0 " " S S* !*:$ 3j !*:- 0d !*:- ++Z !*:- +r&   r   c                     [         R                  U 5      nUc  [        [        R	                  U 5      5      eUR                  S5      UR                  S5      4$ )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_TOPICrf   group)r-   r   s     r#   r*   r*     sL    2 
+E}**:677;;vI 666r&   )r|   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_FORMATr}   re   _PROJECT_PATTERN_TOPIC_NAME_PATTERNrf   _TOPIC_REF_PATTERNcompiler   r   objectr   r*   r   r&   r#   <module>r      s   
 
 / I ; 4 / $< !* , *  @? 9 #**+;=PQ 

-.! x xv7r&   