a
    !f                     @   sD   d Z ddlZddlmZ G dd deZG dd deddZdS )	zMonitored Resource Descriptors for the
`Google Stackdriver Monitoring API (V3)`_.

.. _Google Stackdriver Monitoring API (V3):
    https://cloud.google.com/monitoring/api/ref_v3/rest/v3/    projects.monitoredResourceDescriptors
    N)LabelDescriptorc                   @   sF   e Zd ZdZdd Zedd ZedddZed	d
 Zdd Z	dS )ResourceDescriptora@  Specification of a monitored resource type and its schema.

    :type name: string
    :param name:
        The "resource name" of the monitored resource descriptor:
        ``"projects/<project_id>/monitoredResourceDescriptors/<type>"``

    :type type_: string
    :param type_:
        The monitored resource type. For example: ``"gce_instance"``

    :type display_name: string
    :param display_name:
        A concise name that might be displayed in user interfaces.

    :type description: string
    :param description:
        A detailed description that might be used in documentation.

    :type labels: list of :class:`~gcloud.monitoring.label.LabelDescriptor`
    :param labels:
        A sequence of label descriptors specifying the labels used
        to identify a specific instance of this monitored resource.
    c                 C   s"   || _ || _|| _|| _|| _d S N)nametypedisplay_namedescriptionlabels)selfr   type_r   r   r	    r   [/var/www/html/python-backend/venv/lib/python3.9/site-packages/gcloud/monitoring/resource.py__init__6   s
    zResourceDescriptor.__init__c                 C   s*   dj |j|d}|jjd|d}| |S )a  Look up a monitored resource descriptor by type.

        :type client: :class:`gcloud.monitoring.client.Client`
        :param client: The client to use.

        :type resource_type: string
        :param resource_type: The resource type name.

        :rtype: :class:`ResourceDescriptor`
        :returns: The resource descriptor instance.

        :raises: :class:`gcloud.exceptions.NotFound` if the resource descriptor
            is not found.
        z7/projects/{project}/monitoredResourceDescriptors/{type})projectr   GET)methodpath)formatr   
connectionapi_request
_from_dict)clsclientZresource_typer   infor   r   r   _fetch=   s    zResourceDescriptor._fetchNc           	      C   s   dj |jd}g }d}i }|dur*||d< |dur:||d< |jjd||d}|dd	D ]}|| | qX|d
}|sqq|S )aS  List all monitored resource descriptors for the project.

        :type client: :class:`gcloud.monitoring.client.Client`
        :param client: The client to use.

        :type filter_string: string or None
        :param filter_string:
            An optional filter expression describing the resource descriptors
            to be returned. See the `filter documentation`_.

        :rtype: list of :class:`ResourceDescriptor`
        :returns: A list of resource descriptor instances.

        .. _filter documentation:
            https://cloud.google.com/monitoring/api/v3/filters
        z1/projects/{project}/monitoredResourceDescriptors/)r   NfilterZ	pageTokenr   )r   r   Zquery_paramsZresourceDescriptorsr   ZnextPageToken)r   r   r   r   getappendr   )	r   r   Zfilter_stringr   ZdescriptorsZ
page_tokenparamsresponser   r   r   r   _listS   s&    
zResourceDescriptor._listc                 C   s@   | |d |d | dd| ddtdd | dd	D d
S )a  Construct a resource descriptor from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.

        :rtype: :class:`ResourceDescriptor`
        :returns: A resource descriptor.
        r   r   ZdisplayName r   c                 s   s   | ]}t |V  qd S r   )r   r   ).0labelr   r   r   	<genexpr>   s   z0ResourceDescriptor._from_dict.<locals>.<genexpr>r	   r   )r   r   r   r   r	   )r   tupler   r   r   r   r   r      s    


zResourceDescriptor._from_dictc                 C   s   dj f i | jS )Nz<ResourceDescriptor:
 name={name!r},
 type={type!r},
 labels={labels!r},
 display_name={display_name!r},
 description={description!r}>)r   __dict__)r
   r   r   r   __repr__   s    zResourceDescriptor.__repr__)N)
__name__
__module____qualname____doc__r   classmethodr   r    r   r(   r   r   r   r   r      s   
+
r   c                   @   s    e Zd ZdZdZedd ZdS )Resourcea6  A monitored resource identified by specifying values for all labels.

    :type type: string
    :param type: The resource type name.

    :type labels: dict
    :param labels: A mapping from label names to values for all labels
                   enumerated in the associated :class:`ResourceDescriptor`.
    r   c                 C   s   | |d | di dS )a  Construct a resource object from the parsed JSON representation.

        :type info: dict
        :param info:
            A ``dict`` parsed from the JSON wire-format representation.

        :rtype: :class:`Resource`
        :returns: A resource object.
        r   r	   )r   r	   )r   r&   r   r   r   r      s    
zResource._from_dictN)r)   r*   r+   r,   	__slots__r-   r   r   r   r   r   r.      s   	r.   ztype labels)r,   collectionsZgcloud.monitoring.labelr   objectr   
namedtupler.   r   r   r   r   <module>   s
    