Fix merge conflicts for cloudwatch.
This commit is contained in:
parent
2d65b0a020
commit
93f56322d8
7 changed files with 264 additions and 0 deletions
50
moto/cloudwatch/models.py
Normal file
50
moto/cloudwatch/models.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from moto.core import BaseBackend
|
||||
|
||||
|
||||
class Dimension(object):
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
|
||||
class FakeAlarm(object):
|
||||
def __init__(self, name, comparison_operator, evaluation_periods, period,
|
||||
threshold, statistic, description, dimensions, alarm_actions,
|
||||
ok_actions, insufficient_data_actions, unit):
|
||||
self.name = name
|
||||
self.comparison_operator = comparison_operator
|
||||
self.evaluation_periods = evaluation_periods
|
||||
self.period = period
|
||||
self.threshold = threshold
|
||||
self.statistic = statistic
|
||||
self.description = description
|
||||
self.dimensions = [Dimension(dimension['name'], dimension['value']) for dimension in dimensions]
|
||||
self.alarm_actions = alarm_actions
|
||||
self.ok_actions = ok_actions
|
||||
self.insufficient_data_actions = insufficient_data_actions
|
||||
self.unit = unit
|
||||
|
||||
|
||||
class CloudWatchBackend(BaseBackend):
|
||||
|
||||
def __init__(self):
|
||||
self.alarms = {}
|
||||
|
||||
def put_metric_alarm(self, name, comparison_operator, evaluation_periods,
|
||||
period, threshold, statistic, description, dimensions,
|
||||
alarm_actions, ok_actions, insufficient_data_actions, unit):
|
||||
alarm = FakeAlarm(name, comparison_operator, evaluation_periods, period,
|
||||
threshold, statistic, description, dimensions, alarm_actions,
|
||||
ok_actions, insufficient_data_actions, unit)
|
||||
self.alarms[name] = alarm
|
||||
return alarm
|
||||
|
||||
def get_all_alarms(self):
|
||||
return self.alarms.values()
|
||||
|
||||
def delete_alarms(self, alarm_names):
|
||||
for alarm_name in alarm_names:
|
||||
self.alarms.pop(alarm_name, None)
|
||||
|
||||
|
||||
cloudwatch_backend = CloudWatchBackend()
|
||||
Loading…
Add table
Add a link
Reference in a new issue