
    	]j                      *    d Z ddlmZ  G d de      Zy)zDefine Cloud Logging API Sinks.    )NotFoundc                       e Zd ZdZddddddZed        Zed        Zed        Zed        Z	ed	        Z
d
 Zeddd       Zd ZddddZdddZdddZddddZdddZy)SinkzSinks represent filtered exports for log entries.

    See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks
    N)filter_parentdestinationclientc                X    || _         || _        || _        || _        || _        d| _        y)a  
        Args:
            name (str): The name of the sink.
            parent(Optional[str]): The resource in which to create the sink:

                ::

                    "projects/[PROJECT_ID]"
                    "organizations/[ORGANIZATION_ID]"
                    "billingAccounts/[BILLING_ACCOUNT_ID]"
                    "folders/[FOLDER_ID]".

                Defaults to the project stored on the client.
            filter_ (Optional[str]): The advanced logs filter expression defining
                the entries exported by the sink.
            destination (Optional[str]): Destination URI for the entries exported by the sink.
                If not passed, the instance should already exist, to
                be refreshed via :meth:`reload`.
            client (Optional[~logging_v2.client.Client]): A client which holds
                credentials and project configuration for the sink (which requires a project).
        N)namer   r   _client_parent_writer_identity)selfr   r   r   r   r	   s         F/root/env/lib/python3.12/site-packages/google/cloud/logging_v2/sink.py__init__zSink.__init__   s0    0 	& $    c                     | j                   S )zClient bound to the sink.r   r   s    r   r	   zSink.client9   s     ||r   c                 n    | j                   d| j                  j                   | _         | j                   S )zOParent resource of the sink (project, organization, billingAccount, or folder).z	projects/)r   r	   projectr   s    r   r   zSink.parent>   s1     <<&t{{':':&;<DL||r   c                 8    | j                    d| j                   S )z&Fully-qualified name used in sink APIsz/sinks/)r   r   r   s    r   	full_namezSink.full_nameE   s     ++gdii[11r   c                      d| j                    S )zURL path for the sink's APIs/)r   r   s    r   pathz	Sink.pathJ   s     4>>"##r   c                     | j                   S )z&Identity used for exports via the sink)r   r   s    r   writer_identityzSink.writer_identityO   s     $$$r   c                 p    |d   | _         |j                  d      | _        |j                  d      | _        y)z0Helper for API methods returning sink resources.r   filterwriterIdentityN)r   getr   r   )r   resources     r   _update_from_api_reprzSink._update_from_api_reprT   s1    #M2||H- (-= >r   )r   c                H    |d   } | |||      }|j                  |       |S )a  Construct a sink given its API representation

        Args:
            resource (dict): sink resource representation returned from the API
            client (~logging_v2.client.Client): Client which holds
                credentials and project configuration for the sink.
            parent(Optional[str]): The resource in which to create the sink:

                ::

                    "projects/[PROJECT_ID]"
                    "organizations/[ORGANIZATION_ID]"
                    "billingAccounts/[BILLING_ACCOUNT_ID]"
                    "folders/[FOLDER_ID]".

                Defaults to the project stored on the client.

        Returns:
            ~logging_v2.sink.Sink: Sink parsed from ``resource``.

        Raises:
            ValueError: if ``client`` is not ``None`` and the
                project from the resource does not agree with the project
                from the client.
        r   )r	   r   )r$   )clsr#   r	   r   	sink_nameinstances         r   from_api_reprzSink.from_api_reprZ   s/    6 V$	y?&&x0r   c                 "    || j                   }|S )a  Check client or verify over-ride. Also sets ``parent``.

        Args:
            client (Union[None, ~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.

        Returns:
            ~logging_v2.client.Client: The client passed in
                or the currently bound client.
        r   r   r	   s     r   _require_clientzSink._require_clientz   s     >\\Fr   F)r	   unique_writer_identityc                    | j                  |      }|j                  j                  | j                  | j                  | j
                  | j                  |      }| j                  |       y)a  Create the sink via a PUT request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/create

        Args:
            client (Optional[~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.
            unique_writer_identity (Optional[bool]): Determines the kind of
                IAM identity returned as writer_identity in the new sink.
        r-   N)r,   	sinks_apisink_creater   r   r   r   r$   r   r	   r-   r#   s       r   createzSink.create   s`     %%f-##//KKIILL#9 0 
 	""8,r   )r	   c                    | j                  |      }	 |j                  j                  | j                         y# t        $ r Y yw xY w)a  Test for the existence of the sink via a GET request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get

        Args:
            client (Optional[~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.

        Returns:
            bool: Boolean indicating existence of the sink.
        TF)r,   r0   sink_getr   r   r+   s     r   existszSink.exists   sJ     %%f-	%%dnn5   		s   %9 	AAc                    | j                  |      }|j                  j                  | j                        }| j	                  |       y)a`  Sync local sink configuration via a GET request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/get

        Args:
            client (Optional[~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.
        N)r,   r0   r5   r   r$   )r   r	   r#   s      r   reloadzSink.reload   s<     %%f-##,,T^^<""8,r   c                    | j                  |      }|j                  j                  | j                  | j                  | j
                  |      }| j                  |       y)a  Update sink configuration via a PUT request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update

        Args:
            client (Optional[~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.
            unique_writer_identity (Optional[bool]): Determines the kind of
                IAM identity returned as writer_identity in the new sink.
        r/   N)r,   r0   sink_updater   r   r   r$   r2   s       r   updatezSink.update   sY     %%f-##//NNLL#9	 0 
 	""8,r   c                p    | j                  |      }|j                  j                  | j                         y)aV  Delete a sink via a DELETE request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/delete

        Args:
            client (Optional[~logging_v2.client.Client]):
                The client to use.  If not passed, falls back to the
                ``client`` stored on the current sink.
        N)r,   r0   sink_deleter   r+   s     r   deletezSink.delete   s,     %%f-$$T^^4r   )__name__
__module____qualname____doc__r   propertyr	   r   r   r   r   r$   classmethodr)   r,   r3   r6   r8   r;   r>    r   r   r   r      s      $Dd4%>     2 2 $ $ % %? 7;  >   $E -.  $ .  $ -  $E -,  $ 5r   r   N)rB   google.cloud.exceptionsr   objectr   rE   r   r   <module>rH      s    & ,U56 U5r   