aws-sdk 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/aws.rb +2 -0
- data/lib/aws/api_config/CloudWatch-2010-08-01.yml +424 -0
- data/lib/aws/api_config/STS-2011-06-15.yml +4 -0
- data/lib/aws/auto_scaling/activity.rb +2 -2
- data/lib/aws/auto_scaling/activity_collection.rb +1 -1
- data/lib/aws/auto_scaling/group_collection.rb +1 -1
- data/lib/aws/auto_scaling/instance_collection.rb +1 -1
- data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/notification_configuration_collection.rb +1 -1
- data/lib/aws/auto_scaling/scaling_policy_collection.rb +1 -1
- data/lib/aws/auto_scaling/scheduled_action_collection.rb +1 -1
- data/lib/aws/auto_scaling/tag_collection.rb +1 -1
- data/lib/aws/cloud_watch.rb +75 -0
- data/lib/aws/cloud_watch/alarm.rb +272 -0
- data/lib/aws/cloud_watch/alarm_collection.rb +153 -0
- data/lib/aws/cloud_watch/alarm_history_item.rb +50 -0
- data/lib/aws/cloud_watch/alarm_history_item_collection.rb +84 -0
- data/lib/aws/cloud_watch/client.rb +333 -0
- data/lib/aws/cloud_watch/config.rb +18 -0
- data/lib/aws/cloud_watch/errors.rb +22 -0
- data/lib/aws/cloud_watch/metric.rb +135 -0
- data/lib/aws/cloud_watch/metric_alarm_collection.rb +160 -0
- data/lib/aws/cloud_watch/metric_collection.rb +131 -0
- data/lib/aws/cloud_watch/metric_statistics.rb +69 -0
- data/lib/aws/cloud_watch/request.rb +23 -0
- data/lib/aws/core.rb +1 -1
- data/lib/aws/core/client.rb +2 -2
- data/lib/aws/core/client/query_json.rb +2 -0
- data/lib/aws/core/collection.rb +58 -25
- data/lib/aws/core/collection/simple.rb +18 -26
- data/lib/aws/core/collection/with_limit_and_next_token.rb +71 -0
- data/lib/aws/core/collection/with_next_token.rb +97 -0
- data/lib/aws/core/credential_providers.rb +36 -0
- data/lib/aws/core/option_grammar.rb +19 -0
- data/lib/aws/core/page_result.rb +5 -3
- data/lib/aws/dynamo_db/client.rb +0 -16
- data/lib/aws/dynamo_db/item_collection.rb +1 -1
- data/lib/aws/dynamo_db/request.rb +5 -1
- data/lib/aws/dynamo_db/table_collection.rb +1 -1
- data/lib/aws/iam/collection.rb +1 -1
- data/lib/aws/s3/client.rb +1 -1
- data/lib/aws/s3/paginated_collection.rb +1 -1
- data/lib/aws/simple_db/domain_collection.rb +14 -41
- data/lib/aws/simple_db/item_collection.rb +2 -2
- data/lib/aws/simple_email_service/identity_collection.rb +1 -1
- data/lib/aws/simple_workflow/domain_collection.rb +1 -1
- data/lib/aws/simple_workflow/history_event_collection.rb +1 -1
- data/lib/aws/simple_workflow/type_collection.rb +1 -1
- data/lib/aws/simple_workflow/workflow_execution_collection.rb +1 -1
- data/lib/aws/sns/topic.rb +1 -1
- data/lib/aws/sts.rb +9 -1
- data/lib/aws/sts/client.rb +31 -14
- data/lib/net/http/connection_pool.rb +11 -5
- metadata +19 -4
- data/lib/aws/core/collection/limitable.rb +0 -99
@@ -1,6 +1,5 @@
|
|
1
1
|
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
-
|
3
|
-
|
2
|
+
#
|
4
3
|
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
5
4
|
# may not use this file except in compliance with the License. A copy of
|
6
5
|
# the License is located at
|
@@ -12,6 +11,7 @@
|
|
12
11
|
# ANY KIND, either express or implied. See the License for the specific
|
13
12
|
# language governing permissions and limitations under the License.
|
14
13
|
|
14
|
+
|
15
15
|
module AWS
|
16
16
|
class AutoScaling
|
17
17
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
require 'aws/core'
|
15
|
+
require 'aws/cloud_watch/config'
|
16
|
+
|
17
|
+
module AWS
|
18
|
+
class CloudWatch
|
19
|
+
|
20
|
+
AWS.register_autoloads(self, 'aws/cloud_watch') do
|
21
|
+
autoload :Alarm, 'alarm'
|
22
|
+
autoload :AlarmCollection, 'alarm_collection'
|
23
|
+
autoload :AlarmHistoryItem, 'alarm_history_item'
|
24
|
+
autoload :AlarmHistoryItemCollection, 'alarm_history_item_collection'
|
25
|
+
autoload :Client, 'client'
|
26
|
+
autoload :Errors, 'errors'
|
27
|
+
autoload :Metric, 'metric'
|
28
|
+
autoload :MetricCollection, 'metric_collection'
|
29
|
+
autoload :MetricAlarmCollection, 'metric_alarm_collection'
|
30
|
+
autoload :MetricStatistics, 'metric_statistics'
|
31
|
+
autoload :Request, 'request'
|
32
|
+
end
|
33
|
+
|
34
|
+
include Core::ServiceInterface
|
35
|
+
|
36
|
+
# Puts data for a metric. The metric is created if it does not already
|
37
|
+
# exist.
|
38
|
+
#
|
39
|
+
# cw.put_metric_data(
|
40
|
+
# :namespace => 'test/cli',
|
41
|
+
# :metric_data => [
|
42
|
+
# { :metric_name => 'sample', :value => 1 },
|
43
|
+
# { :metric_name => 'sample', :value => 2 },
|
44
|
+
# { :metric_name => 'sample', :value => 3 },
|
45
|
+
# { :metric_name => 'sample', :value => 4 },
|
46
|
+
# { :metric_name => 'sample', :value => 5 },
|
47
|
+
# ]
|
48
|
+
# )
|
49
|
+
#
|
50
|
+
# @param [Hash] options
|
51
|
+
# @see Client#put_metric_data
|
52
|
+
# @return [nil]
|
53
|
+
#
|
54
|
+
def put_metric_data options = {}
|
55
|
+
client.put_metric_data(options)
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [AlarmCollection]
|
60
|
+
def alarms
|
61
|
+
AlarmCollection.new(:config => config)
|
62
|
+
end
|
63
|
+
|
64
|
+
# @return [AlarmHistoryItemCollection]
|
65
|
+
def alarm_history_items
|
66
|
+
AlarmHistoryItemCollection.new(:config => config)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [MetricCollection]
|
70
|
+
def metrics options = {}
|
71
|
+
MetricCollection.new(options.merge(:config => config))
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,272 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class CloudWatch
|
16
|
+
|
17
|
+
# @attr_reader [String] metric_name
|
18
|
+
#
|
19
|
+
# @attr_reader [String] namespace
|
20
|
+
#
|
21
|
+
# @attr_reader [Array<Hash>] dimensions
|
22
|
+
#
|
23
|
+
# @attr_reader [Boolean] enabled Indicates whether actions
|
24
|
+
# should be executed during any changes to the alarm's state.
|
25
|
+
#
|
26
|
+
# @attr_reader [Array<String>] actions The list of actions to execute
|
27
|
+
# when this alarm transitions into an ALARM state from any other
|
28
|
+
# state.
|
29
|
+
#
|
30
|
+
# @attr_reader [String] arn The Amazon Resource Name (ARN) of the alarm.
|
31
|
+
#
|
32
|
+
# @attr_reader [Time] configuration_updated_timestamp
|
33
|
+
# The time stamp of the last update to the alarm configuration.
|
34
|
+
#
|
35
|
+
# @attr_reader [String] description The description for the alarm.
|
36
|
+
#
|
37
|
+
# @attr_reader [String] comparison_operator The arithmetic operation to
|
38
|
+
# use when comparing the specified Statistic and Threshold. The
|
39
|
+
# specified Statistic value is used as the first operand.
|
40
|
+
#
|
41
|
+
# @attr_reader [Integer] evaluation_periods The number of periods over
|
42
|
+
# which data is compared to the specified threshold.
|
43
|
+
#
|
44
|
+
# @attr_reader [Array<Hash>] insufficient_data_actions The list of
|
45
|
+
# actions to execute when this alarm transitions into an
|
46
|
+
# INSUFFICIENT_DATA state
|
47
|
+
#
|
48
|
+
# @attr_reader [Array<Hash>] ok_actions The list of actions to execute
|
49
|
+
# when this alarm transitions into an OK state.
|
50
|
+
#
|
51
|
+
# @attr_reader [Integer] period The period in seconds over which the
|
52
|
+
# statistic is applied.
|
53
|
+
#
|
54
|
+
# @attr_reader [String] state_reason A human-readable explanation for
|
55
|
+
# the alarm's state.
|
56
|
+
#
|
57
|
+
# @attr_reader [String] state_reason_data An explanation for the alarm's
|
58
|
+
# state in machine-readable JSON format.
|
59
|
+
#
|
60
|
+
# @attr_reader [Time] state_updated_timestamp When the alarm's state
|
61
|
+
# last updated.
|
62
|
+
#
|
63
|
+
# @attr_reader [String] state_value The state value for the alarm.
|
64
|
+
#
|
65
|
+
# @attr_reader [Float] threshold The value against which the specified
|
66
|
+
# statistic is compared.
|
67
|
+
#
|
68
|
+
# @attr_reader [String] unit The unit of the alarm's associated metric.
|
69
|
+
#
|
70
|
+
class Alarm < Core::Resource
|
71
|
+
|
72
|
+
# @private
|
73
|
+
def initialize alarm_name, options = {}
|
74
|
+
@alarm_name = alarm_name
|
75
|
+
super
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String]
|
79
|
+
attr_reader :alarm_name
|
80
|
+
|
81
|
+
alias_method :name, :alarm_name
|
82
|
+
|
83
|
+
attribute :namespace, :static => true
|
84
|
+
|
85
|
+
attribute :metric_name, :static => true
|
86
|
+
|
87
|
+
attribute :dimensions, :static => true
|
88
|
+
|
89
|
+
attribute :actions_enabled
|
90
|
+
|
91
|
+
alias_method :enabled, :actions_enabled
|
92
|
+
|
93
|
+
alias_method :enabled?, :enabled
|
94
|
+
|
95
|
+
attribute :alarm_actions
|
96
|
+
|
97
|
+
alias_method :actions, :alarm_actions
|
98
|
+
|
99
|
+
attribute :alarm_arn, :static => true
|
100
|
+
|
101
|
+
alias_method :arn, :alarm_arn
|
102
|
+
|
103
|
+
attribute :alarm_configuration_updated_timestamp
|
104
|
+
|
105
|
+
alias_method :configuration_updated_timestamp,
|
106
|
+
:alarm_configuration_updated_timestamp
|
107
|
+
|
108
|
+
attribute :alarm_description
|
109
|
+
|
110
|
+
alias_method :description, :alarm_description
|
111
|
+
|
112
|
+
attribute :comparison_operator
|
113
|
+
|
114
|
+
attribute :evaluation_periods
|
115
|
+
|
116
|
+
attribute :insufficient_data_actions
|
117
|
+
|
118
|
+
attribute :ok_actions
|
119
|
+
|
120
|
+
attribute :period
|
121
|
+
|
122
|
+
attribute :state_reason
|
123
|
+
|
124
|
+
attribute :state_reason_data
|
125
|
+
|
126
|
+
attribute :state_updated_timestamp
|
127
|
+
|
128
|
+
attribute :state_value
|
129
|
+
|
130
|
+
attribute :statistic
|
131
|
+
|
132
|
+
attribute :threshold
|
133
|
+
|
134
|
+
attribute :unit
|
135
|
+
|
136
|
+
populates_from :describe_alarms do |resp|
|
137
|
+
resp.data[:metric_alarms].find{|a| a[:alarm_name] == alarm_name }
|
138
|
+
end
|
139
|
+
|
140
|
+
populates_from :describe_alarms_for_metric do |resp|
|
141
|
+
resp.data[:metric_alarms].find{|a| a[:alarm_name] == alarm_name }
|
142
|
+
end
|
143
|
+
|
144
|
+
# @return [Metric]
|
145
|
+
def metric
|
146
|
+
options = {}
|
147
|
+
options[:dimensions] = dimensions unless dimensions.empty?
|
148
|
+
options[:config] = config
|
149
|
+
Metric.new(namespace, metric_name, options)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Updates the metric alarm.
|
153
|
+
#
|
154
|
+
# @option options [String,required] :comparison_operator The arithmetic
|
155
|
+
# operation to use when comparing the specified Statistic and
|
156
|
+
# Threshold. The specified Statistic value is used as the first
|
157
|
+
# operand. Valid values inlucde:
|
158
|
+
# * 'GreaterThanOrEqualToThreshold'
|
159
|
+
# * 'GreaterThanThreshold'
|
160
|
+
# * 'LessThanThreshold'
|
161
|
+
# * 'LessThanOrEqualToThreshold'
|
162
|
+
# @option options [Integer,required] :evaluation_periods The number
|
163
|
+
# of periods over which data is compared to the specified threshold.
|
164
|
+
# @option options [Integer,required] :period The period in seconds
|
165
|
+
# over which the specified statistic is applied.
|
166
|
+
# @option options [String,required] :statistic The statistic to apply
|
167
|
+
# to the alarm's associated metric. Valid values include:
|
168
|
+
# * 'SampleCount'
|
169
|
+
# * 'Average'
|
170
|
+
# * 'Sum'
|
171
|
+
# * 'Minimum'
|
172
|
+
# * 'Maximum'
|
173
|
+
# @option options [Number,required] :threshold The value against which
|
174
|
+
# the specified statistic is compared.
|
175
|
+
# @option options [Array<String>] :insufficient_data_actions
|
176
|
+
# The list of actions to execute when this alarm transitions into an
|
177
|
+
# INSUFFICIENT_DATA state from any other state. Each action is
|
178
|
+
# specified as an Amazon Resource Number (ARN). Currently the only
|
179
|
+
# action supported is publishing to an Amazon SNS topic or an
|
180
|
+
# Amazon Auto Scaling policy.
|
181
|
+
# @option options [Array<String>] :ok_actions The list of actions to
|
182
|
+
# execute when this alarm transitions into an OK state from any
|
183
|
+
# other state. Each action is specified as an Amazon Resource
|
184
|
+
# Number (ARN). Currently the only action supported is publishing to
|
185
|
+
# an Amazon SNS topic or an Amazon Auto Scaling policy.
|
186
|
+
# @option options [Boolean] :actions_enabled Indicates whether or not
|
187
|
+
# actions should be executed during any changes to the alarm's
|
188
|
+
# state.
|
189
|
+
# @option options [Array<String>] :alarm_actions The list of actions
|
190
|
+
# to execute when this alarm transitions into an ALARM state from
|
191
|
+
# any other state. Each action is specified as an Amazon Resource
|
192
|
+
# Number (ARN). Currently the only action supported is publishing
|
193
|
+
# to an Amazon SNS topic or an Amazon Auto Scaling policy.
|
194
|
+
# Maximum of 5 alarm actions.
|
195
|
+
# @option options [String] :alarm_description The description for
|
196
|
+
# the alarm.
|
197
|
+
# @option options [String] :unit The unit for the alarm's associated
|
198
|
+
# metric.
|
199
|
+
# @return [nil]
|
200
|
+
def update options = {}
|
201
|
+
options[:alarm_name] = alarm_name
|
202
|
+
client.put_metric_alarm(options)
|
203
|
+
nil
|
204
|
+
end
|
205
|
+
|
206
|
+
# Deletes the current alarm.
|
207
|
+
# @return [nil]
|
208
|
+
def delete
|
209
|
+
client.delete_alarms(:alarm_names => [ alarm_name ])
|
210
|
+
nil
|
211
|
+
end
|
212
|
+
|
213
|
+
# Disable the current alarm actions.
|
214
|
+
# @return [nil]
|
215
|
+
def disable
|
216
|
+
client.disable_alarm_actions(:alarm_names => [ alarm_name ])
|
217
|
+
nil
|
218
|
+
end
|
219
|
+
|
220
|
+
# Enable the current alarm actions.
|
221
|
+
# @return [nil]
|
222
|
+
def enable
|
223
|
+
client.enable_alarm_actions(:alarm_names => [ alarm_name ])
|
224
|
+
nil
|
225
|
+
end
|
226
|
+
|
227
|
+
# @return [Boolean] Returns true if this alarm exists.
|
228
|
+
def exists?
|
229
|
+
!get_resource.data[:metric_alarms].empty?
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns a collection of the history items for current alarm.
|
233
|
+
# @return [AlarmHistoryItemCollection]
|
234
|
+
def history_items options = {}
|
235
|
+
AlarmHistoryItemCollection.new(:config => config).with_alarm_name(name)
|
236
|
+
end
|
237
|
+
alias_method :history, :history_items
|
238
|
+
alias_method :histories, :history_items
|
239
|
+
|
240
|
+
# Temporarily sets the state of current alarm.
|
241
|
+
# @param [String] reason The reason that this alarm is set to this
|
242
|
+
# specific state (in human-readable text format).
|
243
|
+
# @param [String] value Valid values include:
|
244
|
+
# * 'OK'
|
245
|
+
# * 'ALARM'
|
246
|
+
# * 'INSUFFICIENT_DATA'
|
247
|
+
# @param [Hash] options
|
248
|
+
# @option options [String] :state_reason_data The reason that this
|
249
|
+
# alarm is set to this specific state (in machine-readable JSON
|
250
|
+
# format)
|
251
|
+
# @return [nil]
|
252
|
+
def set_state reason, value, options = {}
|
253
|
+
options[:alarm_name] = alarm_name
|
254
|
+
options[:state_reason] = reason
|
255
|
+
options[:state_value] = value
|
256
|
+
client.set_alarm_state(options)
|
257
|
+
nil
|
258
|
+
end
|
259
|
+
|
260
|
+
protected
|
261
|
+
|
262
|
+
def resource_identifiers
|
263
|
+
[[:alarm_name, alarm_name]]
|
264
|
+
end
|
265
|
+
|
266
|
+
def get_resource attr_name = nil
|
267
|
+
client.describe_alarms(:alarm_names => [ alarm_name ])
|
268
|
+
end
|
269
|
+
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License"). You
|
4
|
+
# may not use this file except in compliance with the License. A copy of
|
5
|
+
# the License is located at
|
6
|
+
#
|
7
|
+
# http://aws.amazon.com/apache2.0/
|
8
|
+
#
|
9
|
+
# or in the "license" file accompanying this file. This file is
|
10
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
11
|
+
# ANY KIND, either express or implied. See the License for the specific
|
12
|
+
# language governing permissions and limitations under the License.
|
13
|
+
|
14
|
+
module AWS
|
15
|
+
class CloudWatch
|
16
|
+
|
17
|
+
# = AlarmCollection
|
18
|
+
#
|
19
|
+
# Represents alarms for an AWS account.
|
20
|
+
#
|
21
|
+
# == Getting an alarm by name
|
22
|
+
#
|
23
|
+
# If you know the name of the alarm, you can get a reference using
|
24
|
+
# the {#[]} method.
|
25
|
+
#
|
26
|
+
# cw = AWS::CloudWatch.new
|
27
|
+
# alarm = cw.alarms['alarm-name']
|
28
|
+
#
|
29
|
+
# == Enumerating Alarms
|
30
|
+
#
|
31
|
+
# You can enumerate all alarms using each (or any of the
|
32
|
+
# methods defined in {Core::Collection}).
|
33
|
+
#
|
34
|
+
# cw.alarms.each do |alarm|
|
35
|
+
# puts alarm.name
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# == Filtering Alarms
|
39
|
+
#
|
40
|
+
# Use one of the filtering methods to reduce the number of alarms
|
41
|
+
# returned.
|
42
|
+
#
|
43
|
+
# cw.alarms.with_name_prefix('some-prefix-').each {|alarm| ... }
|
44
|
+
#
|
45
|
+
class AlarmCollection
|
46
|
+
|
47
|
+
include Core::Collection::WithLimitAndNextToken
|
48
|
+
|
49
|
+
def initialize options = {}
|
50
|
+
@filters = options[:filters] || {}
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [String] alarm_name
|
55
|
+
# @return [Alarm]
|
56
|
+
def [] alarm_name
|
57
|
+
Alarm.new(alarm_name, :config => config)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Creates an alarm and associates it with the specified metric.
|
61
|
+
#
|
62
|
+
# @param [String] alarm_name The descriptive name for the alarm.
|
63
|
+
# This name must be unique within the user's AWS account.
|
64
|
+
# @param [Hash] options
|
65
|
+
# @option options [String,required] :namespace The namespace for the
|
66
|
+
# alarm's associated metric.
|
67
|
+
# @option options [String,required] :metric_name The name for the
|
68
|
+
# alarm's associated metric.
|
69
|
+
# @option options [Array<Hash>] :dimensions The dimensions for the
|
70
|
+
# alarm's associated metric. Each dimension must specify a
|
71
|
+
# +:name+ and a +:value+.
|
72
|
+
# @option (see Alarm#update)
|
73
|
+
# @return [Alarm]
|
74
|
+
def create alarm_name, options = {}
|
75
|
+
options[:alarm_name] = alarm_name
|
76
|
+
client.put_metric_alarm(options)
|
77
|
+
self[alarm_name]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Delete one or more alarms by name.
|
81
|
+
#
|
82
|
+
# cloud_watch.alarms.delete('alarm1', 'alarm2')
|
83
|
+
#
|
84
|
+
# @param [String,Array<String>] alarm_names
|
85
|
+
# @return [nil]
|
86
|
+
def delete *alarm_names
|
87
|
+
client.delete_alarms(:alarm_names => alarm_names.flatten)
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns a new collection with the given filter.
|
92
|
+
# @param [String,Symbol] name
|
93
|
+
# @param [String,Integer] value
|
94
|
+
# @return [Alarm]
|
95
|
+
def filter name, value
|
96
|
+
filters = @filters.merge(name.to_s.to_sym => value)
|
97
|
+
AlarmCollection.new(:filters => filters, :config => config)
|
98
|
+
end
|
99
|
+
|
100
|
+
# @param [String] prefix
|
101
|
+
# @return [MetricAlarmCollection]
|
102
|
+
def with_action_prefix prefix
|
103
|
+
filter(:action_prefix, prefix)
|
104
|
+
end
|
105
|
+
|
106
|
+
# @param [String] prefix The alarm name prefix.
|
107
|
+
# @return [MetricAlarmCollection]
|
108
|
+
def with_name_prefix prefix
|
109
|
+
filter(:alarm_name_prefix, prefix)
|
110
|
+
end
|
111
|
+
|
112
|
+
# @param [String,Array<String>] names A list of alarm names to
|
113
|
+
# retrieve information for.
|
114
|
+
# @return [MetricAlarmCollection]
|
115
|
+
def with_name *names
|
116
|
+
filter(:alarm_names, names.flatten)
|
117
|
+
end
|
118
|
+
|
119
|
+
# @param [String] state The state value to be used in matching alarms.
|
120
|
+
# @return [MetricAlarmCollection]
|
121
|
+
def with_state_value state
|
122
|
+
filter(:state_value, state)
|
123
|
+
end
|
124
|
+
|
125
|
+
protected
|
126
|
+
|
127
|
+
def _each_item next_token, limit, options = {}, &block
|
128
|
+
|
129
|
+
options = @filters.merge(options)
|
130
|
+
|
131
|
+
options[:next_token] = next_token if next_token
|
132
|
+
options[:max_records] = limit if limit
|
133
|
+
|
134
|
+
resp = client.describe_alarms(options)
|
135
|
+
resp.data[:metric_alarms].each do |details|
|
136
|
+
|
137
|
+
alarm = Alarm.new_from(
|
138
|
+
:describe_alarms,
|
139
|
+
details,
|
140
|
+
details[:alarm_name],
|
141
|
+
:config => config)
|
142
|
+
|
143
|
+
yield(alarm)
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
resp.data[:next_token]
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|