aws-sdk-cloudwatch 0.0.6 → 1.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 768c8e2235c9fee3921c8ceca13c009e2c4e9d29
4
+ data.tar.gz: 7a901c263a474f34d52ea667bdc832ddc66efc69
5
+ SHA512:
6
+ metadata.gz: 3c5027e27ca59ddb602d745f7bb857196c358e43816d329456a00b15434c37174dd3e3b63d794e98a4eaa2964322a7eb8cd4f49a31e788297a5751c0e2f7d472
7
+ data.tar.gz: 7c0251b79e957a882637163509cb3fdcf610cb8b6dce1852a319dbaa2fea6bd91f969cfd4c3ba21da05eb715161c78f19260cd7dfa9f22a532b21f4a484710fb
@@ -0,0 +1,50 @@
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
+ require 'aws-sdk-core'
9
+ require 'aws-sigv4'
10
+
11
+ require_relative 'aws-sdk-cloudwatch/types'
12
+ require_relative 'aws-sdk-cloudwatch/client_api'
13
+ require_relative 'aws-sdk-cloudwatch/client'
14
+ require_relative 'aws-sdk-cloudwatch/errors'
15
+ require_relative 'aws-sdk-cloudwatch/waiters'
16
+ require_relative 'aws-sdk-cloudwatch/resource'
17
+ require_relative 'aws-sdk-cloudwatch/alarm'
18
+ require_relative 'aws-sdk-cloudwatch/metric'
19
+ require_relative 'aws-sdk-cloudwatch/customizations'
20
+
21
+ # This module provides support for Amazon CloudWatch. This module is available in the
22
+ # `aws-sdk-cloudwatch` gem.
23
+ #
24
+ # # Client
25
+ #
26
+ # The {Client} class provides one method for each API operation. Operation
27
+ # methods each accept a hash of request parameters and return a response
28
+ # structure.
29
+ #
30
+ # See {Client} for more information.
31
+ #
32
+ # # Errors
33
+ #
34
+ # Errors returned from Amazon CloudWatch all
35
+ # extend {Errors::ServiceError}.
36
+ #
37
+ # begin
38
+ # # do stuff
39
+ # rescue Aws::CloudWatch::Errors::ServiceError
40
+ # # rescues all service API errors
41
+ # end
42
+ #
43
+ # See {Errors} for more information.
44
+ #
45
+ # @service
46
+ module Aws::CloudWatch
47
+
48
+ GEM_VERSION = '1.0.0.rc1'
49
+
50
+ end
@@ -0,0 +1,451 @@
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 Alarm
11
+
12
+ extend Aws::Deprecations
13
+
14
+ # @overload def initialize(name, options = {})
15
+ # @param [String] name
16
+ # @option options [Client] :client
17
+ # @overload def initialize(options = {})
18
+ # @option options [required, String] :name
19
+ # @option options [Client] :client
20
+ def initialize(*args)
21
+ options = Hash === args.last ? args.pop.dup : {}
22
+ @name = extract_name(args, options)
23
+ @data = options.delete(:data)
24
+ @client = options.delete(:client) || Client.new(options)
25
+ end
26
+
27
+ # @!group Read-Only Attributes
28
+
29
+ # @return [String]
30
+ def name
31
+ @name
32
+ end
33
+ alias :alarm_name :name
34
+
35
+ # The Amazon Resource Name (ARN) of the alarm.
36
+ # @return [String]
37
+ def alarm_arn
38
+ data.alarm_arn
39
+ end
40
+
41
+ # The description of the alarm.
42
+ # @return [String]
43
+ def alarm_description
44
+ data.alarm_description
45
+ end
46
+
47
+ # The time stamp of the last update to the alarm configuration.
48
+ # @return [Time]
49
+ def alarm_configuration_updated_timestamp
50
+ data.alarm_configuration_updated_timestamp
51
+ end
52
+
53
+ # Indicates whether actions should be executed during any changes to the
54
+ # alarm state.
55
+ # @return [Boolean]
56
+ def actions_enabled
57
+ data.actions_enabled
58
+ end
59
+
60
+ # The actions to execute when this alarm transitions to the `OK` state
61
+ # from any other state. Each action is specified as an Amazon Resource
62
+ # Name (ARN).
63
+ # @return [Array<String>]
64
+ def ok_actions
65
+ data.ok_actions
66
+ end
67
+
68
+ # The actions to execute when this alarm transitions to the `ALARM`
69
+ # state from any other state. Each action is specified as an Amazon
70
+ # Resource Name (ARN).
71
+ # @return [Array<String>]
72
+ def alarm_actions
73
+ data.alarm_actions
74
+ end
75
+
76
+ # The actions to execute when this alarm transitions to the
77
+ # `INSUFFICIENT_DATA` state from any other state. Each action is
78
+ # specified as an Amazon Resource Name (ARN).
79
+ # @return [Array<String>]
80
+ def insufficient_data_actions
81
+ data.insufficient_data_actions
82
+ end
83
+
84
+ # The state value for the alarm.
85
+ # @return [String]
86
+ def state_value
87
+ data.state_value
88
+ end
89
+
90
+ # An explanation for the alarm state, in text format.
91
+ # @return [String]
92
+ def state_reason
93
+ data.state_reason
94
+ end
95
+
96
+ # An explanation for the alarm state, in JSON format.
97
+ # @return [String]
98
+ def state_reason_data
99
+ data.state_reason_data
100
+ end
101
+
102
+ # The time stamp of the last update to the alarm state.
103
+ # @return [Time]
104
+ def state_updated_timestamp
105
+ data.state_updated_timestamp
106
+ end
107
+
108
+ # The name of the metric associated with the alarm.
109
+ # @return [String]
110
+ def metric_name
111
+ data.metric_name
112
+ end
113
+
114
+ # The namespace of the metric associated with the alarm.
115
+ # @return [String]
116
+ def namespace
117
+ data.namespace
118
+ end
119
+
120
+ # The statistic for the metric associated with the alarm, other than
121
+ # percentile. For percentile statistics, use `ExtendedStatistic`.
122
+ # @return [String]
123
+ def statistic
124
+ data.statistic
125
+ end
126
+
127
+ # The percentile statistic for the metric associated with the alarm.
128
+ # Specify a value between p0.0 and p100.
129
+ # @return [String]
130
+ def extended_statistic
131
+ data.extended_statistic
132
+ end
133
+
134
+ # The dimensions for the metric associated with the alarm.
135
+ # @return [Array<Types::Dimension>]
136
+ def dimensions
137
+ data.dimensions
138
+ end
139
+
140
+ # The period, in seconds, over which the statistic is applied.
141
+ # @return [Integer]
142
+ def period
143
+ data.period
144
+ end
145
+
146
+ # The unit of the metric associated with the alarm.
147
+ # @return [String]
148
+ def unit
149
+ data.unit
150
+ end
151
+
152
+ # The number of periods over which data is compared to the specified
153
+ # threshold.
154
+ # @return [Integer]
155
+ def evaluation_periods
156
+ data.evaluation_periods
157
+ end
158
+
159
+ # The value to compare with the specified statistic.
160
+ # @return [Float]
161
+ def threshold
162
+ data.threshold
163
+ end
164
+
165
+ # The arithmetic operation to use when comparing the specified statistic
166
+ # and threshold. The specified statistic value is used as the first
167
+ # operand.
168
+ # @return [String]
169
+ def comparison_operator
170
+ data.comparison_operator
171
+ end
172
+
173
+ # @!endgroup
174
+
175
+ # @return [Client]
176
+ def client
177
+ @client
178
+ end
179
+
180
+ # Loads, or reloads {#data} for the current {Alarm}.
181
+ # Returns `self` making it possible to chain methods.
182
+ #
183
+ # alarm.reload.data
184
+ #
185
+ # @return [self]
186
+ def load
187
+ resp = @client.describe_alarms(alarm_names: [@name])
188
+ @data = resp.metricalarms[0]
189
+ self
190
+ end
191
+ alias :reload :load
192
+
193
+ # @return [Types::MetricAlarm]
194
+ # Returns the data for this {Alarm}. Calls
195
+ # {Client#describe_alarms} if {#data_loaded?} is `false`.
196
+ def data
197
+ load unless @data
198
+ @data
199
+ end
200
+
201
+ # @return [Boolean]
202
+ # Returns `true` if this resource is loaded. Accessing attributes or
203
+ # {#data} on an unloaded resource will trigger a call to {#load}.
204
+ def data_loaded?
205
+ !!@data
206
+ end
207
+
208
+ # @param [Hash] options ({})
209
+ # @return [Boolean]
210
+ # Returns `true` if the Alarm exists.
211
+ def exists?(options = {})
212
+ begin
213
+ wait_until_exists(options.merge(max_attempts: 1))
214
+ true
215
+ rescue Aws::Waiters::Errors::UnexpectedError => e
216
+ raise e.error
217
+ rescue Aws::Waiters::Errors::WaiterFailed
218
+ false
219
+ end
220
+ end
221
+
222
+ # @param [Hash] options ({})
223
+ # @option options [Integer] :max_attempts (40)
224
+ # @option options [Float] :delay (5)
225
+ # @option options [Proc] :before_attempt
226
+ # @option options [Proc] :before_wait
227
+ # @return [Alarm]
228
+ def wait_until_exists(options = {})
229
+ options, params = separate_params_and_options(options)
230
+ waiter = Waiters::AlarmExists.new(options)
231
+ yield_waiter_and_warn(waiter, &Proc.new) if block_given?
232
+ waiter.wait(params.merge(alarm_names: [@name]))
233
+ Alarm.new({
234
+ name: @name,
235
+ client: @client
236
+ })
237
+ end
238
+
239
+ # @!group Actions
240
+
241
+ # @example Request syntax with placeholder values
242
+ #
243
+ # alarm.delete()
244
+ # @param [Hash] options ({})
245
+ # @return [EmptyStructure]
246
+ def delete(options = {})
247
+ options = Aws::Util.deep_merge(options, alarm_names: [@name])
248
+ resp = @client.delete_alarms(options)
249
+ resp.data
250
+ end
251
+
252
+ # @example Request syntax with placeholder values
253
+ #
254
+ # alarm.describe_history({
255
+ # history_item_type: "ConfigurationUpdate", # accepts ConfigurationUpdate, StateUpdate, Action
256
+ # start_date: Time.now,
257
+ # end_date: Time.now,
258
+ # max_records: 1,
259
+ # next_token: "NextToken",
260
+ # })
261
+ # @param [Hash] options ({})
262
+ # @option options [String] :history_item_type
263
+ # The type of alarm histories to retrieve.
264
+ # @option options [Time,DateTime,Date,Integer,String] :start_date
265
+ # The starting date to retrieve alarm history.
266
+ # @option options [Time,DateTime,Date,Integer,String] :end_date
267
+ # The ending date to retrieve alarm history.
268
+ # @option options [Integer] :max_records
269
+ # The maximum number of alarm history records to retrieve.
270
+ # @option options [String] :next_token
271
+ # The token returned by a previous call to indicate that there is more
272
+ # data available.
273
+ # @return [Types::DescribeAlarmHistoryOutput]
274
+ def describe_history(options = {})
275
+ options = options.merge(alarm_name: @name)
276
+ resp = @client.describe_alarm_history(options)
277
+ resp.data
278
+ end
279
+
280
+ # @example Request syntax with placeholder values
281
+ #
282
+ # alarm.disable_actions()
283
+ # @param [Hash] options ({})
284
+ # @return [EmptyStructure]
285
+ def disable_actions(options = {})
286
+ options = Aws::Util.deep_merge(options, alarm_names: [@name])
287
+ resp = @client.disable_alarm_actions(options)
288
+ resp.data
289
+ end
290
+
291
+ # @example Request syntax with placeholder values
292
+ #
293
+ # alarm.enable_actions()
294
+ # @param [Hash] options ({})
295
+ # @return [EmptyStructure]
296
+ def enable_actions(options = {})
297
+ options = Aws::Util.deep_merge(options, alarm_names: [@name])
298
+ resp = @client.enable_alarm_actions(options)
299
+ resp.data
300
+ end
301
+
302
+ # @example Request syntax with placeholder values
303
+ #
304
+ # alarm.set_state({
305
+ # state_value: "OK", # required, accepts OK, ALARM, INSUFFICIENT_DATA
306
+ # state_reason: "StateReason", # required
307
+ # state_reason_data: "StateReasonData",
308
+ # })
309
+ # @param [Hash] options ({})
310
+ # @option options [required, String] :state_value
311
+ # The value of the state.
312
+ # @option options [required, String] :state_reason
313
+ # The reason that this alarm is set to this specific state, in text
314
+ # format.
315
+ # @option options [String] :state_reason_data
316
+ # The reason that this alarm is set to this specific state, in JSON
317
+ # format.
318
+ # @return [EmptyStructure]
319
+ def set_state(options = {})
320
+ options = options.merge(alarm_name: @name)
321
+ resp = @client.set_alarm_state(options)
322
+ resp.data
323
+ end
324
+
325
+ # @!group Associations
326
+
327
+ # @return [Metric, nil]
328
+ def metric
329
+ if data.namespace && data.metric_name
330
+ Metric.new(
331
+ namespace: data.namespace,
332
+ name: data.metric_name,
333
+ client: @client
334
+ )
335
+ else
336
+ nil
337
+ end
338
+ end
339
+
340
+ # @deprecated
341
+ # @api private
342
+ def identifiers
343
+ { name: @name }
344
+ end
345
+ deprecated(:identifiers)
346
+
347
+ private
348
+
349
+ def extract_name(args, options)
350
+ value = args[0] || options.delete(:name)
351
+ case value
352
+ when String then value
353
+ when nil then raise ArgumentError, "missing required option :name"
354
+ else
355
+ msg = "expected :name to be a String, got #{value.class}"
356
+ raise ArgumentError, msg
357
+ end
358
+ end
359
+
360
+ def yield_waiter_and_warn(waiter, &block)
361
+ if !@waiter_block_warned
362
+ msg = "pass options to configure the waiter; "
363
+ msg << "yielding the waiter is deprecated"
364
+ warn(msg)
365
+ @waiter_block_warned = true
366
+ end
367
+ yield(waiter.waiter)
368
+ end
369
+
370
+ def separate_params_and_options(options)
371
+ opts = Set.new([:client, :max_attempts, :delay, :before_attempt, :before_wait])
372
+ waiter_opts = {}
373
+ waiter_params = {}
374
+ options.each_pair do |key, value|
375
+ if opts.include?(key)
376
+ waiter_opts[key] = value
377
+ else
378
+ waiter_params[key] = value
379
+ end
380
+ end
381
+ waiter_opts[:client] ||= @client
382
+ [waiter_opts, waiter_params]
383
+ end
384
+
385
+ class Collection < Aws::Resources::Collection
386
+
387
+ # @!group Batch Actions
388
+
389
+ # @example Request syntax with placeholder values
390
+ #
391
+ # alarm.batch_delete!()
392
+ # @param options ({})
393
+ # @return [void]
394
+ def batch_delete!(options = {})
395
+ batch_enum.each do |batch|
396
+ params = Aws::Util.copy_hash(options)
397
+ params[:alarm_names] ||= []
398
+ batch.each do |item|
399
+ params[:alarm_names] << {
400
+ name: item.name
401
+ }
402
+ end
403
+ batch[0].client.delete_alarms(params)
404
+ end
405
+ nil
406
+ end
407
+
408
+ # @example Request syntax with placeholder values
409
+ #
410
+ # alarm.batch_disable_actions()
411
+ # @param options ({})
412
+ # @return [void]
413
+ def batch_disable_actions(options = {})
414
+ batch_enum.each do |batch|
415
+ params = Aws::Util.copy_hash(options)
416
+ params[:alarm_names] ||= []
417
+ batch.each do |item|
418
+ params[:alarm_names] << {
419
+ name: item.name
420
+ }
421
+ end
422
+ batch[0].client.disable_alarm_actions(params)
423
+ end
424
+ nil
425
+ end
426
+
427
+ # @example Request syntax with placeholder values
428
+ #
429
+ # alarm.batch_enable_actions()
430
+ # @param options ({})
431
+ # @return [void]
432
+ def batch_enable_actions(options = {})
433
+ batch_enum.each do |batch|
434
+ params = Aws::Util.copy_hash(options)
435
+ params[:alarm_names] ||= []
436
+ batch.each do |item|
437
+ params[:alarm_names] << {
438
+ name: item.name
439
+ }
440
+ end
441
+ batch[0].client.enable_alarm_actions(params)
442
+ end
443
+ nil
444
+ end
445
+
446
+ # @!endgroup
447
+
448
+ end
449
+ end
450
+ end
451
+ end