o ckF[/@spddlmZddlmZddlmZddlmZddlmZGdddeZ Gdd d e Z Gd d d e Z d S) )datetime) ListElement) Dimension)json)sixc@s&eZdZdddZddZddZdS) MetricAlarmsNcCst|||_dS)z0 Parses a list of MetricAlarms. N)list__init__ connectionselfr r ;/usr/lib/python3/dist-packages/boto/ec2/cloudwatch/alarm.pyr s  zMetricAlarms.__init__cCs"|dkrt|}|||SdS)Nmember) MetricAlarmappend)r nameattrsr metric_alarmr r r startElement&s  zMetricAlarms.startElementcCdSNr r rvaluer r r r endElement,zMetricAlarms.endElementr)__name__ __module__ __qualname__r rrr r r rrs  rc@seZdZdZdZdZdddddZed d e eDZ d'd dZ ddZ ddZ ddZd(ddZddZddZddZ d)ddZd(dd Zd(d!d"Zd(d#d$Zd%d&Zd S)*rOKALARMINSUFFICIENT_DATAGreaterThanOrEqualToThresholdGreaterThanThresholdLessThanThresholdLessThanOrEqualToThreshold)z>=><szMetricAlarm.NcCs||_||_||_||_||_|durt||_nd|_|j||_ |dur-t ||_ nd|_ | dur:t | |_ nd|_ d|_ d|_d|_| |_| |_d|_d|_| |_| |_||_||_dS)a Creates a new Alarm. :type name: str :param name: Name of alarm. :type metric: str :param metric: Name of alarm's associated metric. :type namespace: str :param namespace: The namespace for the alarm's metric. :type statistic: str :param statistic: The statistic to apply to the alarm's associated metric. Valid values: SampleCount|Average|Sum|Minimum|Maximum :type comparison: str :param comparison: Comparison used to compare statistic with threshold. Valid values: >= | > | < | <= :type threshold: float :param threshold: The value against which the specified statistic is compared. :type period: int :param period: The period in seconds over which the specified statistic is applied. :type evaluation_periods: int :param evaluation_periods: The number of periods over which data is compared to the specified threshold. :type unit: str :param unit: Allowed 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 description: str :param description: Description of MetricAlarm :type dimensions: dict :param dimensions: A dictionary of dimension key/values where the key is the dimension name and the value is either a scalar value or an iterator of values to be associated with that dimension. Example: { 'InstanceId': ['i-0123456', 'i-0123457'], 'LoadBalancerName': 'test-lb' } :type alarm_actions: list of strs :param alarm_actions: A list of the ARNs of the actions to take in ALARM state :type insufficient_data_actions: list of strs :param insufficient_data_actions: A list of the ARNs of the actions to take in INSUFFICIENT_DATA state :type ok_actions: list of strs :param ok_actions: A list of the ARNs of the actions to take in OK state N)rr metric namespace statisticfloat threshold_cmp_mapget comparisonintperiodevaluation_periodsactions_enabled alarm_arn last_updated description dimensions state_reason state_valueunit alarm_actionsinsufficient_data_actions ok_actions)r r rr-r.r/r4r1r6r7r?r;r<r@rArBr r rr >s4K    zMetricAlarm.__init__cCsd|j|j|j|j|jfS)NzMetricAlarm:%s[%s(%s) %s %s])rr-r/r4r1r r r r__repr__s zMetricAlarm.__repr__cCs^|dkr t|_|jS|dkrt|_|jS|dkr!t|_|jS|dkr,t|_|jS dS)N AlarmActionsInsufficientDataActions OKActions Dimensions)rr@rArBrr<r rrr r r rrszMetricAlarm.startElementcCs6|dkr ||_dS|dkr||_dS|dkr||_dS|dkr$||_dS|dkr-||_dS|dkrr/r0r1r?rr r rrs>           zMetricAlarm.endElementcCs|j|j|||S)a$ Temporarily sets the state of an alarm. :type value: str :param value: OK | ALARM | INSUFFICIENT_DATA :type reason: str :param reason: Reason alarm set (human readable). :type data: str :param data: Reason data (will be jsonified). )r set_alarm_stater)r rreasondatar r r set_states zMetricAlarm.set_statecCs |j|Sr)r update_alarmrCr r rupdates zMetricAlarm.updatecC|j|jgSr)r enable_alarm_actionsrrCr r renable_actionszMetricAlarm.enable_actionscCrar)r disable_alarm_actionsrrCr r rdisable_actionsrdzMetricAlarm.disable_actionscCs|j|j|||||Sr)r describe_alarm_historyr)r start_dateend_date max_recordshistory_item_type next_tokenr r rdescribe_historys zMetricAlarm.describe_historycC|sdSd|_|j|dS)a& Adds an alarm action, represented as an SNS topic, to this alarm. What do do when alarm is triggered. :type action_arn: str :param action_arn: SNS topics to which notification should be sent if the alarm goes to state ALARM. Ntrue)r8r@rr action_arnr r radd_alarm_action zMetricAlarm.add_alarm_actioncCrn)aR Adds an insufficient_data action, represented as an SNS topic, to this alarm. What to do when the insufficient_data state is reached. :type action_arn: str :param action_arn: SNS topics to which notification should be sent if the alarm goes to state INSUFFICIENT_DATA. Nro)r8rArrpr r radd_insufficient_data_action rsz(MetricAlarm.add_insufficient_data_actioncCrn)a4 Adds an ok action, represented as an SNS topic, to this alarm. What to do when the ok state is reached. :type action_arn: str :param action_arn: SNS topics to which notification should be sent if the alarm goes to state INSUFFICIENT_DATA. Nro)r8rBrrpr r r add_ok_actionrszMetricAlarm.add_ok_actioncCs|j|jgdSr)r delete_alarmsrrCr r rdelete'zMetricAlarm.delete)NNNNNNNNNNr,NNNNr)NNNNN)rrrrr r!r2dictr iteritemsrZr rDrrr^r`rcrfrmrrrtrurwr r r rr0s> i "    rc@s.eZdZd ddZddZddZdd ZdS) AlarmHistoryItemNcCs ||_dSr)r r r r rr ,s zAlarmHistoryItem.__init__cCsd|j|j|jfS)NzAlarmHistory:%s[%s at %s])rsummary timestamprCr r rrD/rxzAlarmHistoryItem.__repr__cCrrr rIr r rr2rzAlarmHistoryItem.startElementcCs|dkr ||_dS|dkrt||_dS|dkr||_dS|dkr'||_dS|dkrGz t|d|_WdSt yFt|d|_YdSwdS)NrN HistoryDataHistoryItemTypeHistorySummary Timestampz%Y-%m-%dT%H:%M:%S.%fZz%Y-%m-%dT%H:%M:%SZ) rrloadsr]tem_typer|rstrptimer} ValueErrorrr r rr5s"    zAlarmHistoryItem.endElementr)rrrr rDrrr r r rr{+s   r{N) rboto.ec2.cloudwatch.listelementrboto.ec2.cloudwatch.dimensionr boto.compatrrrrobjectrr{r r r rs     |