o
    rMfX  ã                   @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é    )ÚMetricAlarm)Ú	Dimensionc                   @   sf   e Zd Zg d¢Zg d¢Zddd„Zdd„ Zdd	„ Zd
d„ Zddd„Z				ddd„Z
		ddd„ZdS )ÚMetric)ÚMinimumÚMaximumÚSumÚAverageÚSampleCount)ÚSecondsÚMicrosecondsÚMillisecondsÚBytesÚ	KilobytesÚ	MegabytesÚ	GigabytesÚ	TerabytesÚBitsÚKilobitsÚMegabitsÚGigabitsÚTerabitsÚPercentÚCountzBytes/SecondzKilobytes/SecondzMegabytes/SecondzGigabytes/SecondzTerabytes/SecondzBits/SecondzKilobits/SecondzMegabits/SecondzGigabits/SecondzTerabits/SecondzCount/SecondNNc                 C   s   || _ d | _d | _d | _d S ©N)Ú
connectionÚnameÚ	namespaceÚ
dimensions)Úselfr   © r   ú\/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/boto/ec2/cloudwatch/metric.pyÚ__init__(   s   
zMetric.__init__c                 C   s
   d| j  S )Nz	Metric:%s)r   )r   r   r   r    Ú__repr__.   s   
zMetric.__repr__c                 C   s   |dkrt ƒ | _| jS d S )NÚ
Dimensions)r   r   )r   r   Úattrsr   r   r   r    ÚstartElement1   s   þzMetric.startElementc                 C   s4   |dkr	|| _ d S |dkr|| _d S t| ||ƒ d S )NÚ
MetricNameÚ	Namespace)r   r   Úsetattr)r   r   Úvaluer   r   r   r    Ú
endElement6   s
   

zMetric.endElementé<   c              
   C   s0   t |tƒs|g}| j |||| j| j|| j|¡S )a®  
        :type start_time: datetime
        :param start_time: The time stamp to use for determining the
            first datapoint to return. The value specified is
            inclusive; results include datapoints with the time stamp
            specified.

        :type end_time: datetime
        :param end_time: The time stamp to use for determining the
            last datapoint to return. The value specified is
            exclusive; results will include datapoints up to the time
            stamp specified.

        :type statistics: list
        :param statistics: A list of statistics names Valid values:
            Average | Sum | SampleCount | Maximum | Minimum

        :type unit: string
        :param unit: The unit for the metric.  Value values are:
            Seconds | Microseconds | Milliseconds | Bytes | Kilobytes |
            Megabytes | Gigabytes | Terabytes | Bits | Kilobits |
            Megabits | Gigabits | Terabits | Percent | Count |
            Bytes/Second | Kilobytes/Second | Megabytes/Second |
            Gigabytes/Second | Terabytes/Second | Bits/Second |
            Kilobits/Second | Megabits/Second | Gigabits/Second |
            Terabits/Second | Count/Second | None

        :type period: integer
        :param period: The granularity, in seconds, of the returned datapoints.
            Period must be at least 60 seconds and must be a multiple
            of 60. The default value is 60.

        )Ú
isinstanceÚlistr   Úget_metric_statisticsr   r   r   )r   Ú
start_timeÚend_timeÚ
statisticsÚunitÚperiodr   r   r    Úquery>   s   
"ùzMetric.queryTc                 C   sH   |	s| j }	t| j|| j| j||||||||	|
||ƒ}| j |¡r"|S dS )a‚  
        Creates or updates an alarm and associates it with this metric.
        Optionally, this operation can associate one or more
        Amazon Simple Notification Service resources with the alarm.

        When this operation creates an alarm, the alarm state is immediately
        set to INSUFFICIENT_DATA. The alarm is evaluated and its StateValue is
        set appropriately. Any actions associated with the StateValue is then
        executed.

        When updating an existing alarm, its StateValue is left unchanged.

        :type alarm: boto.ec2.cloudwatch.alarm.MetricAlarm
        :param alarm: MetricAlarm object.
        N)r   r   r   r   r   Úput_metric_alarm)r   r   Ú
comparisonÚ	thresholdr3   Úevaluation_periodsÚ	statisticÚenabledÚdescriptionr   Úalarm_actionsÚ
ok_actionsÚinsufficient_data_actionsr2   Úalarmr   r   r    Úcreate_alarmk   s   ûÿzMetric.create_alarmc                 C   s   | j  | j| j||||¡S )aV  
        Retrieves all alarms for this metric. Specify a statistic, period,
        or unit to filter the set of alarms further.

        :type period: int
        :param period: The period in seconds over which the statistic
            is applied.

        :type statistic: string
        :param statistic: The statistic for the metric.

        :type dimensions: dict
        :param dimension: A dictionary containing name/value
            pairs that will be used to filter the results. The key in
            the dictionary is the name of a Dimension. The value in
            the dictionary is either a scalar value of that Dimension
            name that you want to filter on, a list of values to
            filter on or None if you want all metrics with that
            Dimension name.

        :type unit: string

        :rtype list
        )r   Údescribe_alarms_for_metricr   r   )r   r3   r9   r   r2   r   r   r    Údescribe_alarmsŠ   s   
ûzMetric.describe_alarmsr   )Nr+   )TNNNNNN)NNNN)Ú__name__Ú
__module__Ú__qualname__Ú
StatisticsÚUnitsr!   r"   r%   r*   r4   r@   rB   r   r   r   r    r      s    

/
üÿr   N)Úboto.ec2.cloudwatch.alarmr   Úboto.ec2.cloudwatch.dimensionr   Úobjectr   r   r   r   r    Ú<module>   s   