aws-sdk-cloudwatch 0.0.6 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/aws-sdk-cloudwatch.rb +50 -0
- data/lib/aws-sdk-cloudwatch/alarm.rb +451 -0
- data/lib/aws-sdk-cloudwatch/client.rb +986 -0
- data/lib/aws-sdk-cloudwatch/client_api.rb +421 -0
- data/lib/aws-sdk-cloudwatch/customizations.rb +7 -0
- data/lib/aws-sdk-cloudwatch/errors.rb +23 -0
- data/lib/aws-sdk-cloudwatch/metric.rb +424 -0
- data/lib/aws-sdk-cloudwatch/resource.rb +123 -0
- data/lib/aws-sdk-cloudwatch/types.rb +1024 -0
- data/lib/aws-sdk-cloudwatch/waiters.rb +50 -0
- metadata +35 -106
- data/.gitignore +0 -4
- data/CHANGELOG +0 -6
- data/Gemfile +0 -18
- data/LICENSE.txt +0 -202
- data/NOTICE.txt +0 -2
- data/README.rdoc +0 -41
- data/Rakefile +0 -23
- data/aws-sdk-cloudwatch.gemspec +0 -36
- data/lib/aws/api_config/CloudWatch-2010-08-01.yml +0 -359
- data/lib/aws/cloud_watch.rb +0 -31
- data/lib/aws/cloud_watch/client.rb +0 -57
- data/lib/aws/cloud_watch/config.rb +0 -19
- data/lib/aws/cloud_watch/ec2.rb +0 -58
- data/lib/aws/cloud_watch/errors.rb +0 -23
- data/lib/aws/cloud_watch/metric.rb +0 -97
- data/lib/aws/cloud_watch/metric_base.rb +0 -100
- data/lib/aws/cloud_watch/metric_collection.rb +0 -48
- data/lib/aws/cloud_watch/request.rb +0 -30
- data/lib/aws/core/option_grammar/double.rb +0 -29
- data/licence.rb +0 -14
- data/spec/cloud_watch_client_spec.rb +0 -27
- data/spec/cloud_watch_ec2_spec.rb +0 -70
- data/spec/metric_base_spec.rb +0 -50
- data/spec/metric_collection_spec.rb +0 -46
- data/spec/metric_spec.rb +0 -159
@@ -0,0 +1,424 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module CloudWatch
|
10
|
+
class Metric
|
11
|
+
|
12
|
+
extend Aws::Deprecations
|
13
|
+
|
14
|
+
# @overload def initialize(namespace, name, options = {})
|
15
|
+
# @param [String] namespace
|
16
|
+
# @param [String] name
|
17
|
+
# @option options [Client] :client
|
18
|
+
# @overload def initialize(options = {})
|
19
|
+
# @option options [required, String] :namespace
|
20
|
+
# @option options [required, String] :name
|
21
|
+
# @option options [Client] :client
|
22
|
+
def initialize(*args)
|
23
|
+
options = Hash === args.last ? args.pop.dup : {}
|
24
|
+
@namespace = extract_namespace(args, options)
|
25
|
+
@name = extract_name(args, options)
|
26
|
+
@data = options.delete(:data)
|
27
|
+
@client = options.delete(:client) || Client.new(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @!group Read-Only Attributes
|
31
|
+
|
32
|
+
# @return [String]
|
33
|
+
def namespace
|
34
|
+
@namespace
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String]
|
38
|
+
def name
|
39
|
+
@name
|
40
|
+
end
|
41
|
+
alias :metric_name :name
|
42
|
+
|
43
|
+
# The dimensions for the metric.
|
44
|
+
# @return [Array<Types::Dimension>]
|
45
|
+
def dimensions
|
46
|
+
data.dimensions
|
47
|
+
end
|
48
|
+
|
49
|
+
# @!endgroup
|
50
|
+
|
51
|
+
# @return [Client]
|
52
|
+
def client
|
53
|
+
@client
|
54
|
+
end
|
55
|
+
|
56
|
+
# Loads, or reloads {#data} for the current {Metric}.
|
57
|
+
# Returns `self` making it possible to chain methods.
|
58
|
+
#
|
59
|
+
# metric.reload.data
|
60
|
+
#
|
61
|
+
# @return [self]
|
62
|
+
def load
|
63
|
+
resp = @client.list_metrics(
|
64
|
+
metric_name: @name,
|
65
|
+
namespace: @namespace
|
66
|
+
)
|
67
|
+
@data = resp.metrics[0]
|
68
|
+
self
|
69
|
+
end
|
70
|
+
alias :reload :load
|
71
|
+
|
72
|
+
# @return [Types::Metric]
|
73
|
+
# Returns the data for this {Metric}. Calls
|
74
|
+
# {Client#list_metrics} if {#data_loaded?} is `false`.
|
75
|
+
def data
|
76
|
+
load unless @data
|
77
|
+
@data
|
78
|
+
end
|
79
|
+
|
80
|
+
# @return [Boolean]
|
81
|
+
# Returns `true` if this resource is loaded. Accessing attributes or
|
82
|
+
# {#data} on an unloaded resource will trigger a call to {#load}.
|
83
|
+
def data_loaded?
|
84
|
+
!!@data
|
85
|
+
end
|
86
|
+
|
87
|
+
# @!group Actions
|
88
|
+
|
89
|
+
# @example Request syntax with placeholder values
|
90
|
+
#
|
91
|
+
# metric.get_statistics({
|
92
|
+
# dimensions: [
|
93
|
+
# {
|
94
|
+
# name: "DimensionName", # required
|
95
|
+
# value: "DimensionValue", # required
|
96
|
+
# },
|
97
|
+
# ],
|
98
|
+
# start_time: Time.now, # required
|
99
|
+
# end_time: Time.now, # required
|
100
|
+
# period: 1, # required
|
101
|
+
# statistics: ["SampleCount"], # accepts SampleCount, Average, Sum, Minimum, Maximum
|
102
|
+
# extended_statistics: ["ExtendedStatistic"],
|
103
|
+
# unit: "Seconds", # accepts 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
|
104
|
+
# })
|
105
|
+
# @param [Hash] options ({})
|
106
|
+
# @option options [Array<Types::Dimension>] :dimensions
|
107
|
+
# The dimensions. CloudWatch treats each unique combination of
|
108
|
+
# dimensions as a separate metric. You can't retrieve statistics using
|
109
|
+
# combinations of dimensions that were not specially published. You must
|
110
|
+
# specify the same dimensions that were used when the metrics were
|
111
|
+
# created. For an example, see [Dimension Combinations][1] in the
|
112
|
+
# *Amazon CloudWatch User Guide*.
|
113
|
+
#
|
114
|
+
#
|
115
|
+
#
|
116
|
+
# [1]: http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#dimension-combinations
|
117
|
+
# @option options [required, Time,DateTime,Date,Integer,String] :start_time
|
118
|
+
# The time stamp that determines the first data point to return. Note
|
119
|
+
# that start times are evaluated relative to the time that CloudWatch
|
120
|
+
# receives the request.
|
121
|
+
#
|
122
|
+
# The value specified is inclusive; results include data points with the
|
123
|
+
# specified time stamp. The time stamp must be in ISO 8601 UTC format
|
124
|
+
# (for example, 2016-10-03T23:00:00Z).
|
125
|
+
#
|
126
|
+
# CloudWatch rounds the specified time stamp as follows:
|
127
|
+
#
|
128
|
+
# * Start time less than 15 days ago - Round down to the nearest whole
|
129
|
+
# minute. For example, 12:32:34 is rounded down to 12:32:00.
|
130
|
+
#
|
131
|
+
# * Start time between 15 and 63 days ago - Round down to the nearest
|
132
|
+
# 5-minute clock interval. For example, 12:32:34 is rounded down to
|
133
|
+
# 12:30:00.
|
134
|
+
#
|
135
|
+
# * Start time greater than 63 days ago - Round down to the nearest
|
136
|
+
# 1-hour clock interval. For example, 12:32:34 is rounded down to
|
137
|
+
# 12:00:00.
|
138
|
+
# @option options [required, Time,DateTime,Date,Integer,String] :end_time
|
139
|
+
# The time stamp that determines the last data point to return.
|
140
|
+
#
|
141
|
+
# The value specified is exclusive; results will include data points up
|
142
|
+
# to the specified time stamp. The time stamp must be in ISO 8601 UTC
|
143
|
+
# format (for example, 2016-10-10T23:00:00Z).
|
144
|
+
# @option options [required, Integer] :period
|
145
|
+
# The granularity, in seconds, of the returned data points. A period can
|
146
|
+
# be as short as one minute (60 seconds) and must be a multiple of 60.
|
147
|
+
# The default value is 60.
|
148
|
+
#
|
149
|
+
# If the `StartTime` parameter specifies a time stamp that is greater
|
150
|
+
# than 15 days ago, you must specify the period as follows or no data
|
151
|
+
# points in that time range is returned:
|
152
|
+
#
|
153
|
+
# * Start time between 15 and 63 days ago - Use a multiple of 300
|
154
|
+
# seconds (5 minutes).
|
155
|
+
#
|
156
|
+
# * Start time greater than 63 days ago - Use a multiple of 3600 seconds
|
157
|
+
# (1 hour).
|
158
|
+
# @option options [Array<String>] :statistics
|
159
|
+
# The metric statistics, other than percentile. For percentile
|
160
|
+
# statistics, use `ExtendedStatistic`.
|
161
|
+
# @option options [Array<String>] :extended_statistics
|
162
|
+
# The percentile statistics. Specify values between p0.0 and p100.
|
163
|
+
# @option options [String] :unit
|
164
|
+
# The unit for a given metric. Metrics may be reported in multiple
|
165
|
+
# units. Not supplying a unit results in all units being returned. If
|
166
|
+
# the metric only ever reports one unit, specifying a unit has no
|
167
|
+
# effect.
|
168
|
+
# @return [Types::GetMetricStatisticsOutput]
|
169
|
+
def get_statistics(options = {})
|
170
|
+
options = options.merge(
|
171
|
+
namespace: @namespace,
|
172
|
+
metric_name: @name
|
173
|
+
)
|
174
|
+
resp = @client.get_metric_statistics(options)
|
175
|
+
resp.data
|
176
|
+
end
|
177
|
+
|
178
|
+
# @example Request syntax with placeholder values
|
179
|
+
#
|
180
|
+
# alarm = metric.put_alarm({
|
181
|
+
# alarm_name: "AlarmName", # required
|
182
|
+
# alarm_description: "AlarmDescription",
|
183
|
+
# actions_enabled: false,
|
184
|
+
# ok_actions: ["ResourceName"],
|
185
|
+
# alarm_actions: ["ResourceName"],
|
186
|
+
# insufficient_data_actions: ["ResourceName"],
|
187
|
+
# statistic: "SampleCount", # accepts SampleCount, Average, Sum, Minimum, Maximum
|
188
|
+
# extended_statistic: "ExtendedStatistic",
|
189
|
+
# dimensions: [
|
190
|
+
# {
|
191
|
+
# name: "DimensionName", # required
|
192
|
+
# value: "DimensionValue", # required
|
193
|
+
# },
|
194
|
+
# ],
|
195
|
+
# period: 1, # required
|
196
|
+
# unit: "Seconds", # accepts 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
|
197
|
+
# evaluation_periods: 1, # required
|
198
|
+
# threshold: 1.0, # required
|
199
|
+
# comparison_operator: "GreaterThanOrEqualToThreshold", # required, accepts GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold
|
200
|
+
# })
|
201
|
+
# @param [Hash] options ({})
|
202
|
+
# @option options [required, String] :alarm_name
|
203
|
+
# The name for the alarm. This name must be unique within the AWS
|
204
|
+
# account.
|
205
|
+
# @option options [String] :alarm_description
|
206
|
+
# The description for the alarm.
|
207
|
+
# @option options [Boolean] :actions_enabled
|
208
|
+
# Indicates whether actions should be executed during any changes to the
|
209
|
+
# alarm state.
|
210
|
+
# @option options [Array<String>] :ok_actions
|
211
|
+
# The actions to execute when this alarm transitions to an `OK` state
|
212
|
+
# from any other state. Each action is specified as an Amazon Resource
|
213
|
+
# Name (ARN).
|
214
|
+
#
|
215
|
+
# Valid Values: arn:aws:automate:*region*\:ec2:stop \|
|
216
|
+
# arn:aws:automate:*region*\:ec2:terminate \|
|
217
|
+
# arn:aws:automate:*region*\:ec2:recover
|
218
|
+
#
|
219
|
+
# Valid Values (for use with IAM roles):
|
220
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Stop/1.0
|
221
|
+
# \|
|
222
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Terminate/1.0
|
223
|
+
# \|
|
224
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Reboot/1.0
|
225
|
+
# @option options [Array<String>] :alarm_actions
|
226
|
+
# The actions to execute when this alarm transitions to the `ALARM`
|
227
|
+
# state from any other state. Each action is specified as an Amazon
|
228
|
+
# Resource Name (ARN).
|
229
|
+
#
|
230
|
+
# Valid Values: arn:aws:automate:*region*\:ec2:stop \|
|
231
|
+
# arn:aws:automate:*region*\:ec2:terminate \|
|
232
|
+
# arn:aws:automate:*region*\:ec2:recover
|
233
|
+
#
|
234
|
+
# Valid Values (for use with IAM roles):
|
235
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Stop/1.0
|
236
|
+
# \|
|
237
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Terminate/1.0
|
238
|
+
# \|
|
239
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Reboot/1.0
|
240
|
+
# @option options [Array<String>] :insufficient_data_actions
|
241
|
+
# The actions to execute when this alarm transitions to the
|
242
|
+
# `INSUFFICIENT_DATA` state from any other state. Each action is
|
243
|
+
# specified as an Amazon Resource Name (ARN).
|
244
|
+
#
|
245
|
+
# Valid Values: arn:aws:automate:*region*\:ec2:stop \|
|
246
|
+
# arn:aws:automate:*region*\:ec2:terminate \|
|
247
|
+
# arn:aws:automate:*region*\:ec2:recover
|
248
|
+
#
|
249
|
+
# Valid Values (for use with IAM roles):
|
250
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Stop/1.0
|
251
|
+
# \|
|
252
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Terminate/1.0
|
253
|
+
# \|
|
254
|
+
# arn:aws:swf:us-east-1:\\\{*customer-account*\\}:action/actions/AWS\_EC2.InstanceId.Reboot/1.0
|
255
|
+
# @option options [String] :statistic
|
256
|
+
# The statistic for the metric associated with the alarm, other than
|
257
|
+
# percentile. For percentile statistics, use `ExtendedStatistic`.
|
258
|
+
# @option options [String] :extended_statistic
|
259
|
+
# The percentile statistic for the metric associated with the alarm.
|
260
|
+
# Specify a value between p0.0 and p100.
|
261
|
+
# @option options [Array<Types::Dimension>] :dimensions
|
262
|
+
# The dimensions for the metric associated with the alarm.
|
263
|
+
# @option options [required, Integer] :period
|
264
|
+
# The period, in seconds, over which the specified statistic is applied.
|
265
|
+
# @option options [String] :unit
|
266
|
+
# The unit of measure for the statistic. For example, the units for the
|
267
|
+
# Amazon EC2 NetworkIn metric are Bytes because NetworkIn tracks the
|
268
|
+
# number of bytes that an instance receives on all network interfaces.
|
269
|
+
# You can also specify a unit when you create a custom metric. Units
|
270
|
+
# help provide conceptual meaning to your data. Metric data points that
|
271
|
+
# specify a unit of measure, such as Percent, are aggregated separately.
|
272
|
+
#
|
273
|
+
# If you specify a unit, you must use a unit that is appropriate for the
|
274
|
+
# metric. Otherwise, the Amazon CloudWatch alarm can get stuck in the
|
275
|
+
# `INSUFFICIENT DATA` state.
|
276
|
+
# @option options [required, Integer] :evaluation_periods
|
277
|
+
# The number of periods over which data is compared to the specified
|
278
|
+
# threshold.
|
279
|
+
# @option options [required, Float] :threshold
|
280
|
+
# The value against which the specified statistic is compared.
|
281
|
+
# @option options [required, String] :comparison_operator
|
282
|
+
# The arithmetic operation to use when comparing the specified statistic
|
283
|
+
# and threshold. The specified statistic value is used as the first
|
284
|
+
# operand.
|
285
|
+
# @return [Alarm]
|
286
|
+
def put_alarm(options = {})
|
287
|
+
options = options.merge(
|
288
|
+
namespace: @namespace,
|
289
|
+
metric_name: @name
|
290
|
+
)
|
291
|
+
resp = @client.put_metric_alarm(options)
|
292
|
+
Alarm.new(
|
293
|
+
name: options[:alarm_name],
|
294
|
+
client: @client
|
295
|
+
)
|
296
|
+
end
|
297
|
+
|
298
|
+
# @example Request syntax with placeholder values
|
299
|
+
#
|
300
|
+
# metric.put_data({
|
301
|
+
# metric_data: [ # required
|
302
|
+
# {
|
303
|
+
# metric_name: "MetricName", # required
|
304
|
+
# dimensions: [
|
305
|
+
# {
|
306
|
+
# name: "DimensionName", # required
|
307
|
+
# value: "DimensionValue", # required
|
308
|
+
# },
|
309
|
+
# ],
|
310
|
+
# timestamp: Time.now,
|
311
|
+
# value: 1.0,
|
312
|
+
# statistic_values: {
|
313
|
+
# sample_count: 1.0, # required
|
314
|
+
# sum: 1.0, # required
|
315
|
+
# minimum: 1.0, # required
|
316
|
+
# maximum: 1.0, # required
|
317
|
+
# },
|
318
|
+
# unit: "Seconds", # accepts 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
|
319
|
+
# },
|
320
|
+
# ],
|
321
|
+
# })
|
322
|
+
# @param [Hash] options ({})
|
323
|
+
# @option options [required, Array<Types::MetricDatum>] :metric_data
|
324
|
+
# The data for the metric.
|
325
|
+
# @return [EmptyStructure]
|
326
|
+
def put_data(options = {})
|
327
|
+
options = Aws::Util.deep_merge(options,
|
328
|
+
namespace: @namespace,
|
329
|
+
metric_data: [{ metric_name: @name }]
|
330
|
+
)
|
331
|
+
resp = @client.put_metric_data(options)
|
332
|
+
resp.data
|
333
|
+
end
|
334
|
+
|
335
|
+
# @!group Associations
|
336
|
+
|
337
|
+
# @example Request syntax with placeholder values
|
338
|
+
#
|
339
|
+
# alarms = metric.alarms({
|
340
|
+
# statistic: "SampleCount", # accepts SampleCount, Average, Sum, Minimum, Maximum
|
341
|
+
# extended_statistic: "ExtendedStatistic",
|
342
|
+
# dimensions: [
|
343
|
+
# {
|
344
|
+
# name: "DimensionName", # required
|
345
|
+
# value: "DimensionValue", # required
|
346
|
+
# },
|
347
|
+
# ],
|
348
|
+
# period: 1,
|
349
|
+
# unit: "Seconds", # accepts 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
|
350
|
+
# })
|
351
|
+
# @param [Hash] options ({})
|
352
|
+
# @option options [String] :statistic
|
353
|
+
# The statistic for the metric, other than percentiles. For percentile
|
354
|
+
# statistics, use `ExtendedStatistics`.
|
355
|
+
# @option options [String] :extended_statistic
|
356
|
+
# The percentile statistic for the metric. Specify a value between p0.0
|
357
|
+
# and p100.
|
358
|
+
# @option options [Array<Types::Dimension>] :dimensions
|
359
|
+
# The dimensions associated with the metric. If the metric has any
|
360
|
+
# associated dimensions, you must specify them in order for the call to
|
361
|
+
# succeed.
|
362
|
+
# @option options [Integer] :period
|
363
|
+
# The period, in seconds, over which the statistic is applied.
|
364
|
+
# @option options [String] :unit
|
365
|
+
# The unit for the metric.
|
366
|
+
# @return [Alarm::Collection]
|
367
|
+
def alarms(options = {})
|
368
|
+
batches = Enumerator.new do |y|
|
369
|
+
batch = []
|
370
|
+
options = options.merge(
|
371
|
+
namespace: @namespace,
|
372
|
+
metric_name: @name
|
373
|
+
)
|
374
|
+
resp = @client.describe_alarms_for_metric(options)
|
375
|
+
resp.data.metric_alarms.each do |m|
|
376
|
+
batch << Alarm.new(
|
377
|
+
name: m.alarm_name,
|
378
|
+
data: m,
|
379
|
+
client: @client
|
380
|
+
)
|
381
|
+
end
|
382
|
+
y.yield(batch)
|
383
|
+
end
|
384
|
+
Alarm::Collection.new(batches)
|
385
|
+
end
|
386
|
+
|
387
|
+
# @deprecated
|
388
|
+
# @api private
|
389
|
+
def identifiers
|
390
|
+
{
|
391
|
+
namespace: @namespace,
|
392
|
+
name: @name
|
393
|
+
}
|
394
|
+
end
|
395
|
+
deprecated(:identifiers)
|
396
|
+
|
397
|
+
private
|
398
|
+
|
399
|
+
def extract_namespace(args, options)
|
400
|
+
value = args[0] || options.delete(:namespace)
|
401
|
+
case value
|
402
|
+
when String then value
|
403
|
+
when nil then raise ArgumentError, "missing required option :namespace"
|
404
|
+
else
|
405
|
+
msg = "expected :namespace to be a String, got #{value.class}"
|
406
|
+
raise ArgumentError, msg
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def extract_name(args, options)
|
411
|
+
value = args[1] || options.delete(:name)
|
412
|
+
case value
|
413
|
+
when String then value
|
414
|
+
when nil then raise ArgumentError, "missing required option :name"
|
415
|
+
else
|
416
|
+
msg = "expected :name to be a String, got #{value.class}"
|
417
|
+
raise ArgumentError, msg
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
class Collection < Aws::Resources::Collection; end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# WARNING ABOUT GENERATED CODE
|
2
|
+
#
|
3
|
+
# This file is generated. See the contributing for info on making contributions:
|
4
|
+
# https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
|
5
|
+
#
|
6
|
+
# WARNING ABOUT GENERATED CODE
|
7
|
+
|
8
|
+
module Aws
|
9
|
+
module CloudWatch
|
10
|
+
class Resource
|
11
|
+
|
12
|
+
# @param options ({})
|
13
|
+
# @option options [Client] :client
|
14
|
+
def initialize(options = {})
|
15
|
+
@client = options[:client] || Client.new(options)
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Client]
|
19
|
+
def client
|
20
|
+
@client
|
21
|
+
end
|
22
|
+
|
23
|
+
# @!group Associations
|
24
|
+
|
25
|
+
# @param [String] name
|
26
|
+
# @return [Alarm]
|
27
|
+
def alarm(name)
|
28
|
+
Alarm.new(
|
29
|
+
name: name,
|
30
|
+
client: @client
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @example Request syntax with placeholder values
|
35
|
+
#
|
36
|
+
# alarms = cloud_watch.alarms({
|
37
|
+
# alarm_names: ["AlarmName"],
|
38
|
+
# alarm_name_prefix: "AlarmNamePrefix",
|
39
|
+
# state_value: "OK", # accepts OK, ALARM, INSUFFICIENT_DATA
|
40
|
+
# action_prefix: "ActionPrefix",
|
41
|
+
# })
|
42
|
+
# @param [Hash] options ({})
|
43
|
+
# @option options [Array<String>] :alarm_names
|
44
|
+
# The names of the alarms.
|
45
|
+
# @option options [String] :alarm_name_prefix
|
46
|
+
# The alarm name prefix. You cannot specify `AlarmNames` if this
|
47
|
+
# parameter is specified.
|
48
|
+
# @option options [String] :state_value
|
49
|
+
# The state value to be used in matching alarms.
|
50
|
+
# @option options [String] :action_prefix
|
51
|
+
# The action name prefix.
|
52
|
+
# @return [Alarm::Collection]
|
53
|
+
def alarms(options = {})
|
54
|
+
batches = Enumerator.new do |y|
|
55
|
+
resp = @client.describe_alarms(options)
|
56
|
+
resp.each_page do |page|
|
57
|
+
batch = []
|
58
|
+
page.data.metric_alarms.each do |m|
|
59
|
+
batch << Alarm.new(
|
60
|
+
name: m.alarm_name,
|
61
|
+
data: m,
|
62
|
+
client: @client
|
63
|
+
)
|
64
|
+
end
|
65
|
+
y.yield(batch)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
Alarm::Collection.new(batches)
|
69
|
+
end
|
70
|
+
|
71
|
+
# @param [String] namespace
|
72
|
+
# @param [String] name
|
73
|
+
# @return [Metric]
|
74
|
+
def metric(namespace, name)
|
75
|
+
Metric.new(
|
76
|
+
namespace: namespace,
|
77
|
+
name: name,
|
78
|
+
client: @client
|
79
|
+
)
|
80
|
+
end
|
81
|
+
|
82
|
+
# @example Request syntax with placeholder values
|
83
|
+
#
|
84
|
+
# metrics = cloud_watch.metrics({
|
85
|
+
# namespace: "Namespace",
|
86
|
+
# metric_name: "MetricName",
|
87
|
+
# dimensions: [
|
88
|
+
# {
|
89
|
+
# name: "DimensionName", # required
|
90
|
+
# value: "DimensionValue",
|
91
|
+
# },
|
92
|
+
# ],
|
93
|
+
# })
|
94
|
+
# @param [Hash] options ({})
|
95
|
+
# @option options [String] :namespace
|
96
|
+
# The namespace to filter against.
|
97
|
+
# @option options [String] :metric_name
|
98
|
+
# The name of the metric to filter against.
|
99
|
+
# @option options [Array<Types::DimensionFilter>] :dimensions
|
100
|
+
# The dimensions to filter against.
|
101
|
+
# @return [Metric::Collection]
|
102
|
+
def metrics(options = {})
|
103
|
+
batches = Enumerator.new do |y|
|
104
|
+
resp = @client.list_metrics(options)
|
105
|
+
resp.each_page do |page|
|
106
|
+
batch = []
|
107
|
+
page.data.metrics.each do |m|
|
108
|
+
batch << Metric.new(
|
109
|
+
namespace: m.namespace,
|
110
|
+
name: m.metric_name,
|
111
|
+
data: m,
|
112
|
+
client: @client
|
113
|
+
)
|
114
|
+
end
|
115
|
+
y.yield(batch)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
Metric::Collection.new(batches)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|