aws-sdk 1.5.6 → 1.5.7
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.
- 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
@@ -0,0 +1,69 @@
|
|
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
|
+
# Statistics for a metric.
|
18
|
+
#
|
19
|
+
# This class is an enumerable collection of data points.
|
20
|
+
#
|
21
|
+
# == Enumerating Statistics
|
22
|
+
#
|
23
|
+
# metric = CloudWatch::Metric.new('my/namepace', 'metric-name')
|
24
|
+
#
|
25
|
+
# stats = metric.statistics(
|
26
|
+
# :start_time => Time.now - 3600,
|
27
|
+
# :end_time => Time.now,
|
28
|
+
# :statistics => ['Average'])
|
29
|
+
#
|
30
|
+
# stats.label #=> 'some-label'
|
31
|
+
# stats.each do |datapoint|
|
32
|
+
# # datapoint is a hash
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# @see Core::Collection
|
36
|
+
#
|
37
|
+
class MetricStatistics
|
38
|
+
|
39
|
+
include Core::Collection::Simple
|
40
|
+
|
41
|
+
# @param [Metric] metric
|
42
|
+
# @param [String] label
|
43
|
+
# @param [Array<Hash>] datapoints
|
44
|
+
def initialize metric, label, datapoints
|
45
|
+
@metric = metric
|
46
|
+
@label = label
|
47
|
+
@datapoints = datapoints
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Metric]
|
51
|
+
attr_reader :metric
|
52
|
+
|
53
|
+
# @return [String]
|
54
|
+
attr_reader :label
|
55
|
+
|
56
|
+
# @return [Array<Hash>]
|
57
|
+
attr_reader :datapoints
|
58
|
+
|
59
|
+
protected
|
60
|
+
|
61
|
+
def _each_item options = {}
|
62
|
+
datapoints.each do |point|
|
63
|
+
yield(point)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
# @private
|
18
|
+
class Request < Core::Http::Request
|
19
|
+
include Core::Signature::Version2
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/aws/core.rb
CHANGED
data/lib/aws/core/client.rb
CHANGED
@@ -11,10 +11,10 @@
|
|
11
11
|
# ANY KIND, either express or implied. See the License for the specific
|
12
12
|
# language governing permissions and limitations under the License.
|
13
13
|
|
14
|
-
require 'set'
|
15
14
|
require 'aws/core/client/query_xml'
|
16
15
|
require 'aws/core/client/query_json'
|
17
|
-
require '
|
16
|
+
require 'set'
|
17
|
+
require 'yaml'
|
18
18
|
|
19
19
|
module AWS
|
20
20
|
module Core
|
data/lib/aws/core/collection.rb
CHANGED
@@ -13,28 +13,13 @@
|
|
13
13
|
module AWS
|
14
14
|
module Core
|
15
15
|
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# The Collection module acts as a namespace and base implementation for
|
19
|
-
# the primary collection types in AWS:
|
20
|
-
#
|
21
|
-
# * {AWS::Core::Collection::Simple}
|
22
|
-
# * {AWS::Core::Collection::Limitable}
|
23
|
-
#
|
24
|
-
# Each AWS service allows provides a method to enumerate resources.
|
25
|
-
#
|
26
|
-
# * Services that return all results in a single response use
|
27
|
-
# {AWS::Core::Collection::Simple}.
|
28
|
-
#
|
29
|
-
# * Services that truncate large results sets *AND* allow you to provide
|
30
|
-
# a perfered maximum number of results use
|
31
|
-
# {AWS::Core::Collection::Limitable}.
|
32
|
-
#
|
16
|
+
# Provides useful methods for enumerating items in a collection.
|
33
17
|
module Collection
|
34
18
|
|
35
19
|
AWS.register_autoloads(self) do
|
36
|
-
autoload :Simple,
|
37
|
-
autoload :
|
20
|
+
autoload :Simple, 'simple'
|
21
|
+
autoload :WithNextToken, 'with_next_token'
|
22
|
+
autoload :WithLimitAndNextToken, 'with_limit_and_next_token'
|
38
23
|
end
|
39
24
|
|
40
25
|
include Enumerable
|
@@ -89,16 +74,12 @@ module AWS
|
|
89
74
|
# a single collection. Each batch represents all of the items returned
|
90
75
|
# in a single resopnse.
|
91
76
|
#
|
92
|
-
# @note If you require fixed
|
93
|
-
#
|
77
|
+
# @note If you require fixed batch sizes, see {#in_groups_of}.
|
94
78
|
# @param (see #each)
|
95
|
-
#
|
96
79
|
# @option (see #each)
|
97
|
-
#
|
98
80
|
# @return (see #each)
|
99
|
-
#
|
100
81
|
def each_batch options = {}, &block
|
101
|
-
|
82
|
+
_each_batch(options.dup, &block)
|
102
83
|
end
|
103
84
|
|
104
85
|
# Use this method when you want to call a method provided by
|
@@ -228,7 +209,59 @@ module AWS
|
|
228
209
|
Core::PageResult.new(self, items, per_page, next_token)
|
229
210
|
|
230
211
|
end
|
212
|
+
|
213
|
+
protected
|
214
|
+
|
215
|
+
def _each_batch options, &block
|
216
|
+
# should be defined in the collection modules
|
217
|
+
raise NotImplementedError
|
218
|
+
end
|
219
|
+
|
220
|
+
def _each_item next_token, options = {}, &block
|
221
|
+
# should be defined in classes included the collection modules
|
222
|
+
raise NotImplementedError
|
223
|
+
end
|
224
|
+
|
225
|
+
def _extract_next_token options
|
226
|
+
next_token = options.delete(:next_token)
|
227
|
+
next_token = nil if next_token == ''
|
228
|
+
next_token
|
229
|
+
end
|
230
|
+
|
231
|
+
def _extract_batch_size options
|
232
|
+
batch_size = options.delete(:batch_size)
|
233
|
+
batch_size = nil if batch_size == ''
|
234
|
+
batch_size = batch_size.to_i if batch_size
|
235
|
+
batch_size
|
236
|
+
end
|
237
|
+
|
238
|
+
def _extract_limit options
|
239
|
+
limit = options.delete(:limit) || _limit
|
240
|
+
limit = nil if limit == ''
|
241
|
+
limit = limit.to_i if limit
|
242
|
+
limit
|
243
|
+
end
|
231
244
|
|
245
|
+
# Override this method in collection classes that provide
|
246
|
+
# an alternative way to provide the limit than passinging
|
247
|
+
# it to the enumerable method as :limit.
|
248
|
+
#
|
249
|
+
# An example of when this would be useful:
|
250
|
+
#
|
251
|
+
# collection.limit(10).each {|item| ... }
|
252
|
+
#
|
253
|
+
# The collection class including this module should define _limit
|
254
|
+
# and return the cached limit value (of 10 from this example).
|
255
|
+
# This value may still be overridden by a locally passed
|
256
|
+
# +:limit+ option:
|
257
|
+
#
|
258
|
+
# # limit 5 wins out
|
259
|
+
# collection.limit(10).each(:limit => 5) {|item| ... }
|
260
|
+
#
|
261
|
+
def _limit
|
262
|
+
nil
|
263
|
+
end
|
264
|
+
|
232
265
|
end
|
233
266
|
end
|
234
267
|
end
|
@@ -15,7 +15,7 @@ module AWS
|
|
15
15
|
module Core
|
16
16
|
module Collection
|
17
17
|
|
18
|
-
# AWS::Core::Collection::Simple is used by collections that always
|
18
|
+
# AWS::Core::Collection::Simple is used by collections that always
|
19
19
|
# recieve every matching items in a single response.
|
20
20
|
#
|
21
21
|
# This means:
|
@@ -25,7 +25,7 @@ module AWS
|
|
25
25
|
# * Next tokens are artificial (guessable numeric offsets)
|
26
26
|
#
|
27
27
|
# AWS services generally return all items only for requests with a
|
28
|
-
# small maximum number of results.
|
28
|
+
# small maximum number of results.
|
29
29
|
#
|
30
30
|
# See {AWS::Core::Collection} for documentation on the available
|
31
31
|
# collection methods.
|
@@ -35,37 +35,36 @@ module AWS
|
|
35
35
|
include Enumerable
|
36
36
|
include Collection
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
protected
|
39
|
+
|
40
|
+
def _each_batch options = {}, &block
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
next_token = each_opts.delete(:next_token)
|
45
|
-
offset = next_token ? next_token.to_i - 1 : 0
|
46
|
-
total = 0
|
42
|
+
limit = _extract_limit(options)
|
43
|
+
next_token = _extract_next_token(options)
|
44
|
+
offset = next_token ? next_token.to_i - 1 : 0
|
47
45
|
|
48
|
-
|
46
|
+
total = 0
|
47
|
+
skipped = 0
|
48
|
+
simulated_next_token = nil
|
49
49
|
|
50
50
|
batch = []
|
51
|
-
_each_item(
|
51
|
+
_each_item(options.dup) do |item|
|
52
52
|
|
53
53
|
total += 1
|
54
54
|
|
55
55
|
# skip until we reach our offset (derived from the "next token")
|
56
|
-
|
56
|
+
if skipped < offset
|
57
|
+
skipped += 1
|
58
|
+
next
|
59
|
+
end
|
57
60
|
|
58
61
|
if limit
|
59
|
-
|
60
62
|
if batch.size < limit
|
61
63
|
batch << item
|
62
64
|
else
|
63
|
-
|
64
|
-
# so we can determine if we should return a "next token"
|
65
|
-
nil_or_next_token = total
|
65
|
+
simulated_next_token = total
|
66
66
|
break
|
67
67
|
end
|
68
|
-
|
69
68
|
else
|
70
69
|
batch << item
|
71
70
|
end
|
@@ -74,17 +73,10 @@ module AWS
|
|
74
73
|
|
75
74
|
yield(batch)
|
76
75
|
|
77
|
-
|
76
|
+
simulated_next_token
|
78
77
|
|
79
78
|
end
|
80
|
-
|
81
|
-
protected
|
82
|
-
def _each_item options = {}, &block
|
83
|
-
raise NotImplementedError
|
84
|
-
end
|
85
|
-
|
86
79
|
end
|
87
|
-
|
88
80
|
end
|
89
81
|
end
|
90
82
|
end
|
@@ -0,0 +1,71 @@
|
|
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
|
+
module Core
|
16
|
+
module Collection
|
17
|
+
|
18
|
+
# = Collection::WithLimitAndNextToken
|
19
|
+
#
|
20
|
+
# This module is used by collections where the service may truncate
|
21
|
+
# responses but that also accept a upper limit of results to
|
22
|
+
# return in a single request.
|
23
|
+
#
|
24
|
+
# See {AWS::Core::Collection} for documentation on the available
|
25
|
+
# methods.
|
26
|
+
#
|
27
|
+
module WithLimitAndNextToken
|
28
|
+
|
29
|
+
include Model
|
30
|
+
include Collection
|
31
|
+
include Enumerable
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def _each_batch options = {}, &block
|
36
|
+
|
37
|
+
limit = _extract_limit(options)
|
38
|
+
batch_size = _extract_batch_size(options)
|
39
|
+
next_token = _extract_next_token(options)
|
40
|
+
|
41
|
+
total = 0 # count of items yeilded across all batches
|
42
|
+
|
43
|
+
begin
|
44
|
+
|
45
|
+
max = nil
|
46
|
+
if limit or batch_size
|
47
|
+
max = []
|
48
|
+
max << (limit - total) if limit
|
49
|
+
max << batch_size if batch_size
|
50
|
+
max = max.min
|
51
|
+
end
|
52
|
+
|
53
|
+
batch = []
|
54
|
+
next_token = _each_item(next_token, max, options.dup) do |item|
|
55
|
+
|
56
|
+
total += 1
|
57
|
+
batch << item
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
yield(batch)
|
62
|
+
|
63
|
+
end until next_token.nil? or (limit and limit == total)
|
64
|
+
|
65
|
+
next_token
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,97 @@
|
|
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
|
+
module Core
|
16
|
+
module Collection
|
17
|
+
|
18
|
+
# = Collection::WithNextToken
|
19
|
+
#
|
20
|
+
# When making a request to list elements from one of these
|
21
|
+
# collections, the response may return a next token. This indicates
|
22
|
+
# there are more results than were returned. You can not control
|
23
|
+
# the number of elements returned with each response.
|
24
|
+
#
|
25
|
+
# See {AWS::Core::Collection} for documentation on the available
|
26
|
+
# collection methods.
|
27
|
+
#
|
28
|
+
module WithNextToken
|
29
|
+
|
30
|
+
include Model
|
31
|
+
include Enumerable
|
32
|
+
include Collection
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def _each_batch options = {}, &block
|
37
|
+
|
38
|
+
limit = _extract_limit(options)
|
39
|
+
|
40
|
+
next_token, skip_count = _extract_next_token(options)
|
41
|
+
|
42
|
+
skipped = 0
|
43
|
+
collected = 0
|
44
|
+
|
45
|
+
begin
|
46
|
+
|
47
|
+
offset = 0
|
48
|
+
batch = []
|
49
|
+
|
50
|
+
next_token = _each_item(next_token, options.dup) do |item|
|
51
|
+
|
52
|
+
if skipped < skip_count
|
53
|
+
skipped += 1
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
if limit
|
58
|
+
if collected < limit
|
59
|
+
batch << item
|
60
|
+
collected += 1
|
61
|
+
else
|
62
|
+
yield(batch)
|
63
|
+
simulated_next_token = {}
|
64
|
+
simulated_next_token[:token] = next_token if next_token
|
65
|
+
simulated_next_token[:offset] = offset + skipped
|
66
|
+
return simulated_next_token
|
67
|
+
end
|
68
|
+
else
|
69
|
+
batch << item
|
70
|
+
collected += 1
|
71
|
+
end
|
72
|
+
|
73
|
+
offset += 1
|
74
|
+
|
75
|
+
end # _each_item
|
76
|
+
|
77
|
+
yield(batch)
|
78
|
+
|
79
|
+
end until next_token.nil? or (limit and limit == collected)
|
80
|
+
|
81
|
+
next_token.nil? ? nil : { :token => next_token }
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def _extract_next_token options
|
86
|
+
next_token = super
|
87
|
+
case next_token
|
88
|
+
when nil then [nil, 0]
|
89
|
+
when Hash then [next_token[:token], next_token[:offset] || 0]
|
90
|
+
else [next_token, 0]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|