<s> from boto . ec2 . cloudwatch . alarm import MetricAlarm <EOL> from boto . ec2 . cloudwatch . dimension import Dimension <EOL> class Metric ( object ) : <EOL> Statistics = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> Units = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , None ] <EOL> def __init__ ( self , connection = None ) : <EOL> self . connection = connection <EOL> self . name = None <EOL> self . namespace = None <EOL> self . dimensions = None <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % self . name <EOL> def startElement ( self , name , attrs , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . dimensions = Dimension ( ) <EOL> return self . dimensions <EOL> def endElement ( self , name , value , connection ) : <EOL> if name == '<STR_LIT>' : <EOL> self . name = value <EOL> elif name == '<STR_LIT>' : <EOL> self . namespace = value <EOL> else : <EOL> setattr ( self , name , value ) <EOL> def query ( self , start_time , end_time , statistics , unit = None , period = <NUM_LIT> ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( statistics , list ) : <EOL> statistics = [ statistics ] <EOL> return self . connection . get_metric_statistics ( period , <EOL> start_time , <EOL> end_time , <EOL> self . name , <EOL> self . namespace , <EOL> statistics , <EOL> self . dimensions , <EOL> unit ) <EOL> def create_alarm ( self , name , comparison , threshold , <EOL> period , evaluation_periods , <EOL> statistic , enabled = True , description = None , <EOL> dimensions = None , alarm_actions = None , ok_actions = None , <EOL> insufficient_data_actions = None , unit = None ) : <EOL> """<STR_LIT>""" <EOL> if not dimensions : <EOL> dimensions = self . dimensions <EOL> alarm = MetricAlarm ( self . connection , name , self . name , <EOL> self . namespace , statistic , comparison , <EOL> threshold , period , evaluation_periods , <EOL> unit , description , dimensions , <EOL> alarm_actions , insufficient_data_actions , <EOL> ok_actions ) <EOL> if self . connection . put_metric_alarm ( alarm ) : <EOL> return alarm <EOL> def describe_alarms ( self , period = None , statistic = None , <EOL> dimensions = None , unit = None ) : <EOL> """<STR_LIT>""" <EOL> return self . connection . describe_alarms_for_metric ( self . name , <EOL> self . namespace , <EOL> period , <EOL> statistic , <EOL> dimensions , <EOL> unit ) </s>
