FRTc@sddlmZddlmZddlmZddlmZddlmZdefdYZ de fd YZ d e fd YZ d S( i(tdatetime(t ListElement(t Dimension(tjson(tsixt MetricAlarmscBs&eZddZdZdZRS(cCstj|||_dS(s0 Parses a list of MetricAlarms. N(tlistt__init__t connection(tselfR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyRs cCs-|dkr)t|}|j||SdS(Ntmember(t MetricAlarmtappend(R tnametattrsRt metric_alarm((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyt startElement&s   cCsdS(N((R R tvalueR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyt endElement,sN(t__name__t __module__tNoneRRR(((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyRs  R cBseZdZdZdZidd6dd6dd6d d 6Zed ejeDZ ddddddddddd ddddd Z dZ dZ dZddZdZdZdZddddddZddZddZddZdZRS(tOKtALARMtINSUFFICIENT_DATAtGreaterThanOrEqualToThresholds>=tGreaterThanThresholdt>tLessThanThresholdt<stcCs||_||_||_||_||_|dk rKt||_n d|_|jj ||_ |dk rt ||_ n d|_ | dk rt | |_ n d|_ d|_d|_d|_| |_| |_d|_d|_| |_| |_||_||_dS(s 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 teh 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(R Rtmetrict namespacet statisticRtfloatt thresholdt_cmp_maptgett comparisontinttperiodtevaluation_periodstactions_enabledt alarm_arnt last_updatedt descriptiont dimensionst state_reasont state_valuetunitt alarm_actionstinsufficient_data_actionst ok_actions(R RR R#R$R%R*R'R,R-R5R1R2R6R7R8((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR>s4K                     cCs&d|j|j|j|j|jfS(NsMetricAlarm:%s[%s(%s) %s %s](R R#R%R*R'(R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyt__repr__scCs|dkrt|_|jS|dkr>t|_|jS|dkr]t|_|jS|dkr|t|_|jSdS(Nt AlarmActionstInsufficientDataActionst OKActionst Dimensions(RR6R7R8RR2(R R RR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyRs        cCs|dkr||_n|dkr0||_nh|dkrH||_nP|dkr`||_n8|dkrx||_n |dkrt|d|j|n|dkrt||_n|d kr||_ n|d kr||_ n|d kr t||_ n|d kr"||_ nv|d kr:||_ n^|dkrR||_nF|dkrpt||_n(|dkr||_nt|||dS(NtActionsEnabledtAlarmArnt"AlarmConfigurationUpdatedTimestamptAlarmDescriptiont AlarmNametComparisonOperatorR*tEvaluationPeriodst MetricNamet NamespacetPeriodt StateReasont StateValuet Statistict ThresholdtUnit(R.R/R0R1R tsetattrt _rev_cmp_mapR+R-R#R$R,R3R4R%R&R'R5(R R RR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyRs>                          cCs|jj|j|||S(s$ 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). (Rtset_alarm_stateR (R Rtreasontdata((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyt set_states cCs|jj|S(N(Rt update_alarm(R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytupdatescCs|jj|jgS(N(Rtenable_alarm_actionsR (R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytenable_actionsscCs|jj|jgS(N(Rtdisable_alarm_actionsR (R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytdisable_actionsscCs"|jj|j|||||S(N(Rtdescribe_alarm_historyR (R t start_datetend_datet max_recordsthistory_item_typet next_token((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytdescribe_historyscCs'|s dSd|_|jj|dS(s& 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. Nttrue(R.R6R (R t action_arn((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytadd_alarm_actions  cCs'|s dSd|_|jj|dS(sR 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. NR`(R.R7R (R Ra((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytadd_insufficient_data_action s  cCs'|s dSd|_|jj|dS(s4 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. NR`(R.R8R (R Ra((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyt add_ok_actions  cCs|jj|jgdS(N(Rt delete_alarmsR (R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pytdelete'sN(RRRRRR(tdictRt iteritemsRNRRR9RRRRRTRVRXR_RbRcRdRf(((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR 0s8      d   "        tAlarmHistoryItemcBs/eZddZdZdZdZRS(cCs ||_dS(N(R(R R((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR,scCsd|j|j|jfS(NsAlarmHistory:%s[%s at %s](R tsummaryt timestamp(R ((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR9/scCsdS(N((R R RR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR2scCs|dkr||_n|dkr9tj||_n|dkrQ||_ni|dkri||_nQ|dkrytj|d|_Wqt k rtj|d|_qXndS(NRBt HistoryDatatHistoryItemTypetHistorySummaryt Timestamps%Y-%m-%dT%H:%M:%S.%fZs%Y-%m-%dT%H:%M:%SZ( R RtloadsRQttem_typeRjRtstrptimeRkt ValueError(R R RR((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyR5s          N(RRRRR9RR(((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyRi+s   N( Rtboto.ec2.cloudwatch.listelementRtboto.ec2.cloudwatch.dimensionRt boto.compatRRRRtobjectR Ri(((sF/opt/freeware/lib/python2.7/site-packages/boto/ec2/cloudwatch/alarm.pyts