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.
Files changed (55) hide show
  1. data/lib/aws.rb +2 -0
  2. data/lib/aws/api_config/CloudWatch-2010-08-01.yml +424 -0
  3. data/lib/aws/api_config/STS-2011-06-15.yml +4 -0
  4. data/lib/aws/auto_scaling/activity.rb +2 -2
  5. data/lib/aws/auto_scaling/activity_collection.rb +1 -1
  6. data/lib/aws/auto_scaling/group_collection.rb +1 -1
  7. data/lib/aws/auto_scaling/instance_collection.rb +1 -1
  8. data/lib/aws/auto_scaling/launch_configuration_collection.rb +1 -1
  9. data/lib/aws/auto_scaling/notification_configuration_collection.rb +1 -1
  10. data/lib/aws/auto_scaling/scaling_policy_collection.rb +1 -1
  11. data/lib/aws/auto_scaling/scheduled_action_collection.rb +1 -1
  12. data/lib/aws/auto_scaling/tag_collection.rb +1 -1
  13. data/lib/aws/cloud_watch.rb +75 -0
  14. data/lib/aws/cloud_watch/alarm.rb +272 -0
  15. data/lib/aws/cloud_watch/alarm_collection.rb +153 -0
  16. data/lib/aws/cloud_watch/alarm_history_item.rb +50 -0
  17. data/lib/aws/cloud_watch/alarm_history_item_collection.rb +84 -0
  18. data/lib/aws/cloud_watch/client.rb +333 -0
  19. data/lib/aws/cloud_watch/config.rb +18 -0
  20. data/lib/aws/cloud_watch/errors.rb +22 -0
  21. data/lib/aws/cloud_watch/metric.rb +135 -0
  22. data/lib/aws/cloud_watch/metric_alarm_collection.rb +160 -0
  23. data/lib/aws/cloud_watch/metric_collection.rb +131 -0
  24. data/lib/aws/cloud_watch/metric_statistics.rb +69 -0
  25. data/lib/aws/cloud_watch/request.rb +23 -0
  26. data/lib/aws/core.rb +1 -1
  27. data/lib/aws/core/client.rb +2 -2
  28. data/lib/aws/core/client/query_json.rb +2 -0
  29. data/lib/aws/core/collection.rb +58 -25
  30. data/lib/aws/core/collection/simple.rb +18 -26
  31. data/lib/aws/core/collection/with_limit_and_next_token.rb +71 -0
  32. data/lib/aws/core/collection/with_next_token.rb +97 -0
  33. data/lib/aws/core/credential_providers.rb +36 -0
  34. data/lib/aws/core/option_grammar.rb +19 -0
  35. data/lib/aws/core/page_result.rb +5 -3
  36. data/lib/aws/dynamo_db/client.rb +0 -16
  37. data/lib/aws/dynamo_db/item_collection.rb +1 -1
  38. data/lib/aws/dynamo_db/request.rb +5 -1
  39. data/lib/aws/dynamo_db/table_collection.rb +1 -1
  40. data/lib/aws/iam/collection.rb +1 -1
  41. data/lib/aws/s3/client.rb +1 -1
  42. data/lib/aws/s3/paginated_collection.rb +1 -1
  43. data/lib/aws/simple_db/domain_collection.rb +14 -41
  44. data/lib/aws/simple_db/item_collection.rb +2 -2
  45. data/lib/aws/simple_email_service/identity_collection.rb +1 -1
  46. data/lib/aws/simple_workflow/domain_collection.rb +1 -1
  47. data/lib/aws/simple_workflow/history_event_collection.rb +1 -1
  48. data/lib/aws/simple_workflow/type_collection.rb +1 -1
  49. data/lib/aws/simple_workflow/workflow_execution_collection.rb +1 -1
  50. data/lib/aws/sns/topic.rb +1 -1
  51. data/lib/aws/sts.rb +9 -1
  52. data/lib/aws/sts/client.rb +31 -14
  53. data/lib/net/http/connection_pool.rb +11 -5
  54. metadata +19 -4
  55. data/lib/aws/core/collection/limitable.rb +0 -99
@@ -390,6 +390,42 @@ module AWS
390
390
 
391
391
  end
392
392
 
393
+ # Returns a set of fake credentials, should only be used for testing.
394
+ class FakeProvider < StaticProvider
395
+
396
+ # @param [Hash] options
397
+ # @option options [Boolean] :with_session_token (false) When +true+ a
398
+ # fake session token will also be provided.
399
+ def initialize options = {}
400
+ options[:access_key_id] ||= fake_access_key_id
401
+ options[:secret_access_key] ||= fake_secret_access_key
402
+ if options.delete(:with_session_token)
403
+ options[:session_token] ||= fake_session_token
404
+ end
405
+ super
406
+ end
407
+
408
+ protected
409
+
410
+ def fake_access_key_id
411
+ "AKIA" + random_chars(16).upcase
412
+ end
413
+
414
+ def fake_secret_access_key
415
+ random_chars(40)
416
+ end
417
+
418
+ def fake_session_token
419
+ random_chars(260)
420
+ end
421
+
422
+ def random_chars count
423
+ chars = ('0'..'9').to_a + ('a'..'z').to_a + ('A'..'Z').to_a
424
+ (1..count).map{ chars[rand(chars.size)] }.join
425
+ end
426
+
427
+ end
428
+
393
429
  end
394
430
  end
395
431
  end
@@ -157,6 +157,25 @@ module AWS
157
157
  def required?; true; end
158
158
  end
159
159
 
160
+ # @private
161
+ module Float
162
+
163
+ extend NoArgs
164
+
165
+ def validate(value, context = nil)
166
+ raise format_error("float value", context) unless
167
+ value.kind_of?(Numeric) or
168
+ value.respond_to? :to_f
169
+ end
170
+
171
+ def encode_value(value)
172
+ value.to_f.to_s
173
+ end
174
+
175
+ end
176
+
177
+ Double = Float
178
+
160
179
  # @private
161
180
  module Rename
162
181
  def self.apply(option, new_name)
@@ -13,7 +13,6 @@
13
13
 
14
14
  module AWS
15
15
  module Core
16
-
17
16
  class PageResult < Array
18
17
 
19
18
  # @return [Collection] Returns the collection that was used to
@@ -51,6 +50,9 @@ module AWS
51
50
  super(items)
52
51
  end
53
52
 
53
+ # @return [PageResult]
54
+ # @raise [RuntimeError] Raises a runtime error when called against
55
+ # a collection that has no more results (i.e. #last_page? == true).
54
56
  def next_page
55
57
  if last_page?
56
58
  raise 'unable to get the next page, already at the last page'
@@ -58,12 +60,12 @@ module AWS
58
60
  collection.page(:per_page => per_page, :next_token => next_token)
59
61
  end
60
62
 
61
- # @return [Boolean] Returns true if this is the last page of results.
63
+ # @return [Boolean] Returns +true+ if this is the last page of results.
62
64
  def last_page?
63
65
  next_token.nil?
64
66
  end
65
67
 
66
- # @return [Boolean] Returns true if there are more pages of results.
68
+ # @return [Boolean] Returns +true+ if there are more pages of results.
67
69
  def more?
68
70
  !!next_token
69
71
  end
@@ -30,22 +30,6 @@ module AWS
30
30
  # @private
31
31
  CACHEABLE_REQUESTS = Set[:list_tables, :describe_table]
32
32
 
33
- # @private
34
- def initialize *args
35
-
36
- super
37
-
38
- # Replaces the current credential provider with a SessionProvider
39
- # that provides refreshable STS session credentials. DynamoDB
40
- # requires session credentials.
41
- if credential_provider.session_token.nil?
42
- long_term_credentials = credential_provider.credentials
43
- @credential_provider = Core::CredentialProviders::SessionProvider.for(
44
- long_term_credentials)
45
- end
46
-
47
- end
48
-
49
33
  ## client methods ##
50
34
 
51
35
  # Calls the BatchGetItem API operation.
@@ -88,7 +88,7 @@ module AWS
88
88
  #
89
89
  class ItemCollection
90
90
 
91
- include Core::Collection::Limitable
91
+ include Core::Collection::WithLimitAndNextToken
92
92
  include Types
93
93
  include Expectations
94
94
 
@@ -17,7 +17,11 @@ module AWS
17
17
  # @private
18
18
  class Request < Core::Http::Request
19
19
 
20
- include Core::Signature::Version3
20
+ include Core::Signature::Version4
21
+
22
+ def service
23
+ 'dynamodb'
24
+ end
21
25
 
22
26
  # @return [String,nil]
23
27
  attr_accessor :body
@@ -37,7 +37,7 @@ module AWS
37
37
  #
38
38
  class TableCollection
39
39
 
40
- include Core::Collection::Limitable
40
+ include Core::Collection::WithLimitAndNextToken
41
41
 
42
42
  # Creates a new table.
43
43
  #
@@ -14,7 +14,7 @@ module AWS
14
14
  class IAM
15
15
  module Collection
16
16
 
17
- include Core::Collection::Limitable
17
+ include Core::Collection::WithLimitAndNextToken
18
18
 
19
19
  # Common methods for collection classes that can be filtered by
20
20
  # a path prefix.
@@ -1169,7 +1169,7 @@ module AWS
1169
1169
  end
1170
1170
 
1171
1171
  # @param [String] possible_xml
1172
- # @reutrn [Boolean] Returns +true+ if the given string is a valid xml
1172
+ # @return [Boolean] Returns +true+ if the given string is a valid xml
1173
1173
  # document.
1174
1174
  def is_xml? possible_xml
1175
1175
  begin
@@ -17,7 +17,7 @@ module AWS
17
17
  # @private
18
18
  module PaginatedCollection
19
19
 
20
- include Core::Collection::Limitable
20
+ include Core::Collection::WithLimitAndNextToken
21
21
 
22
22
  protected
23
23
  def _each_item markers, limit, options = {}, &block
@@ -34,10 +34,11 @@ module AWS
34
34
  # puts domain.name
35
35
  # end
36
36
  #
37
+ # @see Core::Collection
38
+ #
37
39
  class DomainCollection
38
40
 
39
- include Core::Model
40
- include Enumerable
41
+ include Core::Collection::WithLimitAndNextToken
41
42
 
42
43
  # Creates a domain in SimpleDB and returns a domain object.
43
44
  #
@@ -50,7 +51,7 @@ module AWS
50
51
  # @return [Domain] Returns a new domain with the given name.
51
52
  def create(domain_name)
52
53
  client.create_domain(:domain_name => domain_name)
53
- domain_named(domain_name)
54
+ self[domain_name]
54
55
  end
55
56
 
56
57
  # Returns a domain object with the given name.
@@ -61,51 +62,23 @@ module AWS
61
62
  # @param [String] domain_name The name of the domain to return.
62
63
  # @return [Domain] Returns the domain with the given name.
63
64
  def [] domain_name
64
- domain_named(domain_name)
65
+ Domain.new(domain_name.to_s, :config => config)
65
66
  end
66
67
 
67
- # @note Normally your account has a limit of 100 SimpleDB domains. You can {request more here}[http://aws.amazon.com/contact-us/simpledb-limit-request/]
68
- # @yield [domain] Yields once for every domain in your account.
69
- # @yieldparam [Domain] domain
70
- # @param [Hash] options
71
- # @option options [Integer] :limit (nil) The maximum number of
72
- # domains to yield.
73
- # @option options [Integer] :batch_size (100) The number of domains to
74
- # fetch each request to SimpleDB. Maximum is 100.
75
- # @return [nil]
76
- def each options = {}, &block
77
-
78
- total_limit = options[:limit]
79
- batch_size = options[:batch_size] || 100
80
- received = 0
81
- next_token = nil
82
-
83
- begin
68
+ protected
84
69
 
85
- limit = total_limit ?
86
- [total_limit - received, batch_size].min :
87
- batch_size
70
+ def _each_item next_token, limit, options = {}
88
71
 
89
- list_options = { :max_number_of_domains => limit }
90
- list_options[:next_token] = next_token if next_token
91
- list = client.list_domains(list_options)
72
+ options[:next_token] = next_token if next_token
73
+ options[:max_number_of_domains] = limit if limit
92
74
 
93
- next_token = list[:next_token]
94
- received += list[:domain_names].size
75
+ resp = client.list_domains(options)
76
+ resp.data[:domain_names].each do |name|
77
+ yield(self[name])
78
+ end
95
79
 
96
- list[:domain_names].each do |name|
97
- yield(domain_named(name))
98
- end
99
-
100
- end while next_token and (total_limit.nil? or received < total_limit)
101
- nil
102
- end
80
+ resp.data[:next_token]
103
81
 
104
- # @return [Domain] Returns a domain with the given name.
105
- # @private
106
- protected
107
- def domain_named name
108
- Domain.new(name.to_s, :config => config)
109
82
  end
110
83
 
111
84
  end
@@ -30,7 +30,7 @@ module AWS
30
30
 
31
31
  include ConsistentReadOption
32
32
 
33
- include Core::Collection::Limitable
33
+ include Core::Collection::WithLimitAndNextToken
34
34
 
35
35
  # @return [Domain] The domain the items belong to.
36
36
  attr_reader :domain
@@ -447,7 +447,7 @@ module AWS
447
447
  return @limit if args.empty?
448
448
  collection_with(:limit => Integer(args.first))
449
449
  end
450
- alias_method :_limit, :limit # for Collection::Limitable
450
+ alias_method :_limit, :limit # for Collection::WithLimitAndNextToken
451
451
 
452
452
  # Applies standard scope options (e.g. :where => 'foo') and removes them from
453
453
  # the options hash by calling their method (e.g. by calling #where('foo')).
@@ -15,7 +15,7 @@ module AWS
15
15
  class SimpleEmailService
16
16
  class IdentityCollection
17
17
 
18
- include Core::Collection::Limitable
18
+ include Core::Collection::WithLimitAndNextToken
19
19
 
20
20
  # @private
21
21
  def initialize options = {}
@@ -50,7 +50,7 @@ module AWS
50
50
  class DomainCollection
51
51
 
52
52
  include OptionFormatters
53
- include Core::Collection::Limitable
53
+ include Core::Collection::WithLimitAndNextToken
54
54
 
55
55
  def initialize options = {}
56
56
 
@@ -22,7 +22,7 @@ module AWS
22
22
  #
23
23
  class HistoryEventCollection
24
24
 
25
- include Core::Collection::Limitable
25
+ include Core::Collection::WithLimitAndNextToken
26
26
 
27
27
  # @param [WorkflowExecution] workflow_execution The execution this
28
28
  # history event belongs to.
@@ -19,7 +19,7 @@ module AWS
19
19
  class TypeCollection
20
20
 
21
21
  include OptionFormatters
22
- include Core::Collection::Limitable
22
+ include Core::Collection::WithLimitAndNextToken
23
23
 
24
24
  # @param [Domain] domain The domain the (workflow or activity types
25
25
  # belong to.
@@ -40,7 +40,7 @@ module AWS
40
40
  :closed_after,
41
41
  ]
42
42
 
43
- include Core::Collection::Limitable
43
+ include Core::Collection::WithLimitAndNextToken
44
44
  include OptionFormatters
45
45
 
46
46
  # @private
@@ -126,7 +126,7 @@ module AWS
126
126
  # @param [Hash] options Additional options for confirming the
127
127
  # subscription.
128
128
  #
129
- # @option :options [Boolean] :authenticate_on_unsubscribe
129
+ # @option options [Boolean] :authenticate_on_unsubscribe
130
130
  # Indicates that you want to disable unauthenticated
131
131
  # unsubsciption of the subscription.
132
132
  #
@@ -67,6 +67,14 @@ module AWS
67
67
  # account owners are restricted to a maximum of 3600s (one
68
68
  # hour).
69
69
  #
70
+ # @option opts [String] :serial_nubmer The identification number of the
71
+ # Multi-Factor Authentication (MFA) device for the user.
72
+ #
73
+ # @option opts [String] :token_code The value provided by the MFA device.
74
+ # If the user has an access policy requiring an MFA code, provide the
75
+ # value here to get permission to resources as specified in the access
76
+ # policy.
77
+ #
70
78
  # @return [Session]
71
79
  def new_session(opts = {})
72
80
  get_session(:get_session_token, opts) do |resp, session_opts|
@@ -129,8 +137,8 @@ module AWS
129
137
  end
130
138
  end
131
139
 
132
- # @private
133
140
  protected
141
+
134
142
  def get_session(method, opts = {})
135
143
  opts[:duration_seconds] = opts.delete(:duration) if
136
144
  opts[:duration]
@@ -43,18 +43,19 @@ module AWS
43
43
  # === Options:
44
44
  #
45
45
  # * +:name+ - *required* - (String) The name of the federated user
46
- # associated with the session.
47
- # * +:policy+ - (String) A policy specifying the permissions associated
48
- # with the session. The caller can delegate their own permissions by
49
- # specifying a policy for the session, and both policies will be
50
- # checked when a service call is made. In other words, permissions of
51
- # the session credentials are the intersection of the policy specified
52
- # in the API and the policies associated with the user who issued the
53
- # session.
46
+ # associated with the credentials. For information about limitations on
47
+ # user names, go to Limitations on IAM Entities in Using AWS Identity
48
+ # and Access Management.
49
+ # * +:policy+ - (String) A policy specifying the permissions to associate
50
+ # with the credentials. The caller can delegate their own permissions
51
+ # by specifying a policy, and both policies will be checked when a
52
+ # service call is made. For more information about how permissions work
53
+ # in the context of temporary credentials, see Controlling Permissions
54
+ # in Temporary Credentials in Using AWS Identity and Access Management.
54
55
  # * +:duration_seconds+ - (Integer) The duration, in seconds, that the
55
56
  # session should last. Acceptable durations for federation sessions
56
- # range from 3600s (1 hour) to 129600s (36 hours), with 43200 as the
57
- # default.
57
+ # range from 3600s (one hour) to 129600s (36 hours), with 43200s (12
58
+ # hours) as the default.
58
59
  #
59
60
  # === Response Structure:
60
61
  #
@@ -78,10 +79,26 @@ module AWS
78
79
  # === Options:
79
80
  #
80
81
  # * +:duration_seconds+ - (Integer) The duration, in seconds, that the
81
- # session should last. Acceptable durations for IAM user sessions range
82
- # from 3600s (1 hour) to 129600s (36 hours), with 43200 as the default.
83
- # Sessions started for AWS Account owners are restricted to a maximum
84
- # 3600s.
82
+ # credentials should remain valid. Acceptable durations for IAM user
83
+ # sessions range from 3600s (one hour) to 129600s (36 hours), with
84
+ # 43200s (12 hours) as the default. Sessions for AWS account owners are
85
+ # restricted to a maximum of 3600s (one hour).
86
+ # * +:serial_number+ - (String) The identification number of the
87
+ # Multi-Factor Authentication (MFA) device for the user. If the user
88
+ # has an access policy requiring MFA to access resources, provide the
89
+ # value here. The number is in the Security Credentials tab of the
90
+ # user's details pane in the IAM console. If the user has an active MFA
91
+ # device, the details pane displays a Multi-Factor Authentication
92
+ # Device value such as arn:aws:iam::123456789012:mfa/user for a virtual
93
+ # device or the device serial number for a hardware device.
94
+ # * +:token_code+ - (String) The value provided by the MFA device. If the
95
+ # user has an access policy requiring an MFA code, provide the value
96
+ # here to get permission to resources as specified in the access
97
+ # policy. If MFA is required, and a code not provided while requesting
98
+ # a set of temporary security credentials, the user will receive an
99
+ # "access denied" response when requesting resources that require MFA.
100
+ # For more information, see Using Multi-Factor Authentication (MFA)
101
+ # Devices with AWS in Using IAM.
85
102
  #
86
103
  # === Response Structure:
87
104
  #
@@ -48,8 +48,12 @@ class Net::HTTP::ConnectionPool
48
48
  @pool_mutex = Mutex.new
49
49
  @open_timeout = options[:http_open_timeout] || 15
50
50
  @idle_timeout = options[:http_idle_timeout] || 60
51
- @log_wire_trace = !!options[:http_wire_trace]
52
- @logger = options[:logger] || Logger.new($stdout)
51
+ @http_wire_trace = !!options[:http_wire_trace]
52
+ if logger = options[:logger]
53
+ @logger = logger
54
+ elsif http_wire_trace?
55
+ @logger = Logger.new($stdout)
56
+ end
53
57
  end
54
58
 
55
59
  # @return [Integer]
@@ -60,9 +64,11 @@ class Net::HTTP::ConnectionPool
60
64
 
61
65
  # @return [Boolean] Returns +true+ when HTTP debug output (wire traces)
62
66
  # will be logged.
63
- attr_reader :log_wire_trace
67
+ attr_reader :http_wire_trace
64
68
 
65
- alias_method :log_wire_trace?, :log_wire_trace
69
+ alias_method :http_wire_trace?, :http_wire_trace
70
+ alias_method :log_wire_trace?, :http_wire_trace
71
+ alias_method :log_wire_trace, :http_wire_trace
66
72
 
67
73
  # @return [Logger] Where debug output is sent.
68
74
  attr_reader :logger
@@ -208,7 +214,7 @@ class Net::HTTP::ConnectionPool
208
214
  end
209
215
 
210
216
  if session.nil?
211
- logger = log_wire_trace? ? self.logger : nil
217
+ logger = http_wire_trace? ? self.logger : nil
212
218
  session = Session.for(connection, open_timeout, logger)
213
219
  end
214
220