a
    !f                     @   sX   d Z ddlZddlmZ ddlmZ G dd deddZG dd	 d	ed	d
ZdS )aM  Time series for the `Google Stackdriver Monitoring API (V3)`_.

Features intentionally omitted from this first version of the client library:
  * Writing time series.
  * Natural representation of distribution values.

.. _Google Stackdriver Monitoring API (V3):
    https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries
    N)Metric)Resourcec                   @   s>   e Zd ZdZdZedd ZdddZedd Z	d	d
 Z
dS )
TimeSeriesak  A single time series of metric values.

    :type metric: :class:`~gcloud.monitoring.metric.Metric`
    :param metric: A metric object.

    :type resource: :class:`~gcloud.monitoring.resource.Resource`
    :param resource: A resource object.

    :type metric_kind: string
    :param metric_kind:
        The kind of measurement: :data:`MetricKind.GAUGE`,
        :data:`MetricKind.DELTA`, or :data:`MetricKind.CUMULATIVE`.
        See :class:`~gcloud.monitoring.metric.MetricKind`.

    :type value_type: string
    :param value_type:
        The value type of the metric: :data:`ValueType.BOOL`,
        :data:`ValueType.INT64`, :data:`ValueType.DOUBLE`,
        :data:`ValueType.STRING`, or :data:`ValueType.DISTRIBUTION`.
        See :class:`~gcloud.monitoring.metric.ValueType`.

    :type points: list of :class:`Point`
    :param points: A list of point objects.
    Nc                 C   s>   | j du r8d| jji}|| jj || jj || _ | j S )zA single dictionary with values for all the labels.

        This combines ``resource.labels`` and ``metric.labels`` and also
        adds ``"resource_type"``.
        NZresource_type)_labelsresourcetypeupdatelabelsmetric)selfr	    r   ]/var/www/html/python-backend/venv/lib/python3.9/site-packages/gcloud/monitoring/timeseries.pyr	   <   s    
zTimeSeries.labelsc                 C   s   |rt |ng }| j|dS )zCopy everything but the point data.

        :type points: list of :class:`Point`, or None
        :param points: An optional point list.

        :rtype: :class:`TimeSeries`
        :returns: The new time series object.
        )points)list_replace)r   r   r   r   r   headerK   s    	zTimeSeries.headerc                 C   sR   t |d }t|d }|d }|d }dd |ddD }| |||||S )	a	  Construct a time series from the parsed JSON representation.

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

        :rtype: :class:`TimeSeries`
        :returns: A time series object.
        r
   r   Z
metricKindZ	valueTypec                 S   s   g | ]}t |qS r   )Point
_from_dict).0pr   r   r   
<listcomp>f       z)TimeSeries._from_dict.<locals>.<listcomp>r   r   )r   r   r   get)clsinfor
   r   metric_kind
value_typer   r   r   r   r   W   s    zTimeSeries._from_dictc                 C   s"   dj t| j| j| j| j| jdS )z6Return a representation string with the points elided.zv<TimeSeries with {num} points:
 metric={metric!r},
 resource={resource!r},
 metric_kind={kind!r}, value_type={type!r}>)numr
   r   kindr   )formatlenr   r
   r   r   r   )r   r   r   r   __repr__i   s    zTimeSeries.__repr__)N)__name__
__module____qualname____doc__r   propertyr	   r   classmethodr   r!   r   r   r   r   r      s   


r   z-metric resource metric_kind value_type pointsc                   @   s    e Zd ZdZdZedd ZdS )r   aX  A single point in a time series.

    :type end_time: string
    :param end_time: The end time in RFC3339 UTC "Zulu" format.

    :type start_time: string or None
    :param start_time: An optional start time in RFC3339 UTC "Zulu" format.

    :type value: object
    :param value: The metric value. This can be a scalar or a distribution.
    r   c                 C   sH   |d d }|d  d}|d  \\}}|dkr<t|}| |||S )zConstruct a Point from the parsed JSON representation.

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

        :rtype: :class:`Point`
        :returns: A point object.
        intervalZendTimeZ	startTimevalueZ
int64Value)r   itemsint)r   r   end_time
start_timer   r)   r   r   r   r      s    zPoint._from_dictN)r"   r#   r$   r%   	__slots__r'   r   r   r   r   r   r   y   s   r   zend_time start_time value)	r%   collectionsZgcloud.monitoring.metricr   Zgcloud.monitoring.resourcer   
namedtupler   r   r   r   r   r   <module>   s   
Z