
    	]j                     *    d Z ddlmZ  G d de      Zy)z!Define Cloud Logging API Metrics.    )NotFoundc                       e Zd ZdZdddddZed        Zed        Zed        Zed	        Z	e
d
        Zd ZdddZdddZdddZdddZdddZy)MetriczMetrics represent named filters for log entries.

    See
    https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics
    N filter_clientdescriptionc                <    || _         || _        || _        || _        y)a.  
        Args:
            name (str): The name of the metric.
            filter_ (str): the advanced logs filter expression defining the entries
                   tracked by the metric.  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).
            description (Optional[str]): An optional description of the metric.

        N)name_clientr   r
   )selfr   r   r	   r
   s        H/root/env/lib/python3.12/site-packages/google/cloud/logging_v2/metric.py__init__zMetric.__init__   s!     	&    c                     | j                   S )zClent bound to the logger.r   r   s    r   r	   zMetric.client,   s     ||r   c                 .    | j                   j                  S )zProject bound to the logger.)r   projectr   s    r   r   zMetric.project1   s     ||###r   c                 :    d| j                    d| j                   S )z(Fully-qualified name used in metric APIsz	projects/z	/metrics/)r   r   r   s    r   	full_namezMetric.full_name6   s     4<<.	$))==r   c                      d| j                    S )zURL path for the metric's APIs/)r   r   s    r   pathzMetric.path;   s     4>>"##r   c                 R    |d   }|d   }|j                  dd      } | ||||      S )ad  Construct a metric given its API representation

        Args:
            resource (dict): metric resource representation returned from the API
            client (~logging_v2.client.Client): Client which holds
                credentials and project configuration for the sink.

        Returns:
            google.cloud.logging_v2.metric.Metric
        r   filterr
   r   r   )get)clsresourcer	   metric_namer   r
   s         r   from_api_reprzMetric.from_api_repr@   s9     v&8$ll="5;KXXr   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:
            google.cloud.logging_v2.client.Client: The client passed in
                or the currently bound client.
        r   r   r	   s     r   _require_clientzMetric._require_clientQ   s     >\\Fr   )r	   c                    | j                  |      }|j                  j                  | j                  | j                  | j
                  | j                         y)aY  Create the metric via a PUT request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/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.
        N)r%   metrics_apimetric_creater   r   r   r
   r$   s     r   createzMetric.createa   C     %%f-((LL$))T\\43C3C	
r   c                    | j                  |      }	 |j                  j                  | j                  | j                         y# t
        $ r Y yw xY w)a  Test for the existence of the metric via a GET request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/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 metric.
        TF)r%   r'   
metric_getr   r   r   r$   s     r   existszMetric.existsq   sP     %%f-	))$,,		B   		s   0A 	AAc                    | j                  |      }|j                  j                  | j                  | j                        }|j                  dd      | _        |d   | _        y)ao  API call:  sync local metric configuration via a GET request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/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.
        r
   r   r   N)r%   r'   r,   r   r   r   r
   r   )r   r	   datas      r   reloadzMetric.reload   sR     %%f-!!,,T\\499E88M26H~r   c                    | j                  |      }|j                  j                  | j                  | j                  | j
                  | j                         y)an  API call:  update metric configuration via a PUT request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/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.
        N)r%   r'   metric_updater   r   r   r
   r$   s     r   updatezMetric.update   r*   r   c                    | j                  |      }|j                  j                  | j                  | j                         y)ae  API call:  delete a metric via a DELETE request

        See
        https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/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%   r'   metric_deleter   r   r$   s     r   deletezMetric.delete   s2     %%f-((tyyAr   )__name__
__module____qualname____doc__r   propertyr	   r   r   r   classmethodr"   r%   r)   r-   r0   r3   r6    r   r   r   r      s     )-Tr '"   $ $ > > $ $ Y Y    $ 
   $ .  $ &   $ 
   $ Br   r   N)r:   google.cloud.exceptionsr   objectr   r=   r   r   <module>r@      s    ( ,`BV `Br   