aws-sdk-core 2.1.0 → 2.1.4

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/apis/autoscaling/2011-01-01/api-2.json +41 -4
  3. data/apis/cloudfront/{2014-11-06 → 2015-04-17}/api-2.json +92 -52
  4. data/apis/cloudfront/{2014-11-06 → 2015-04-17}/paginators-1.json +0 -0
  5. data/apis/cloudfront/{2014-11-06 → 2015-04-17}/waiters-2.json +0 -0
  6. data/apis/codecommit/2015-04-13/api-2.json +885 -0
  7. data/apis/codecommit/2015-04-13/paginators-1.json +14 -0
  8. data/apis/codepipeline/2015-07-09/api-2.json +1640 -0
  9. data/apis/cognito-identity/2014-06-30/api-2.json +18 -0
  10. data/apis/cognito-sync/2014-06-30/api-2.json +22 -0
  11. data/apis/config/2014-11-12/api-2.json +24 -1
  12. data/apis/ec2/2015-04-15/api-2.json +34 -3
  13. data/apis/ec2/2015-04-15/resources-1.json +66 -17
  14. data/apis/ecs/2014-11-13/api-2.json +22 -3
  15. data/apis/email/2010-12-01/api-2.json +163 -2
  16. data/apis/glacier/2012-06-01/api-2.json +174 -0
  17. data/apis/iam/2010-05-08/api-2.json +346 -17
  18. data/apis/iam/2010-05-08/paginators-1.json +32 -0
  19. data/apis/iam/2010-05-08/resources-1.json +8 -0
  20. data/apis/iam/2010-05-08/waiters-2.json +22 -0
  21. data/apis/lambda/2015-03-31/api-2.json +4 -1
  22. data/apis/opsworks/2013-02-18/api-2.json +88 -34
  23. data/apis/redshift/2012-12-01/api-2.json +423 -5
  24. data/apis/redshift/2012-12-01/waiters-2.json +33 -23
  25. data/apis/sts/2011-06-15/api-2.json +2 -2
  26. data/bin/aws.rb +6 -0
  27. data/lib/aws-sdk-core/api/builder.rb +8 -0
  28. data/lib/aws-sdk-core/api/docs/builder.rb +4 -4
  29. data/lib/aws-sdk-core/api/docs/operation_documenter.rb +1 -1
  30. data/lib/aws-sdk-core/api/shape_map.rb +10 -8
  31. data/lib/aws-sdk-core/client_stubs.rb +6 -2
  32. data/lib/aws-sdk-core/cloudfront.rb +4 -4
  33. data/lib/aws-sdk-core/codecommit.rb +5 -0
  34. data/lib/aws-sdk-core/codepipeline.rb +4 -0
  35. data/lib/aws-sdk-core/credential_provider.rb +5 -7
  36. data/lib/aws-sdk-core/dynamodb/attribute_value.rb +2 -2
  37. data/lib/aws-sdk-core/dynamodb.rb +14 -0
  38. data/lib/aws-sdk-core/eager_loader.rb +5 -6
  39. data/lib/aws-sdk-core/iam.rb +1 -0
  40. data/lib/aws-sdk-core/instance_profile_credentials.rb +1 -1
  41. data/lib/aws-sdk-core/json/handler.rb +4 -4
  42. data/lib/aws-sdk-core/pageable_response.rb +44 -34
  43. data/lib/aws-sdk-core/pager.rb +2 -3
  44. data/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb +4 -0
  45. data/lib/aws-sdk-core/plugins/ec2_copy_encrypted_snapshot.rb +2 -1
  46. data/lib/aws-sdk-core/plugins/regional_endpoint.rb +2 -2
  47. data/lib/aws-sdk-core/plugins/response_paging.rb +1 -0
  48. data/lib/aws-sdk-core/shared_credentials.rb +2 -2
  49. data/lib/aws-sdk-core/signers/s3.rb +31 -3
  50. data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +3 -5
  51. data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +0 -1
  52. data/lib/aws-sdk-core/type_builder.rb +14 -0
  53. data/lib/aws-sdk-core/version.rb +1 -1
  54. data/lib/aws-sdk-core/xml/parser/engines/oga.rb +39 -0
  55. data/lib/aws-sdk-core/xml/parser.rb +4 -1
  56. data/lib/aws-sdk-core.rb +19 -15
  57. data/lib/seahorse/client/http/request.rb +1 -1
  58. data/lib/seahorse/client/http/response.rb +5 -3
  59. data/lib/seahorse/client/net_http/connection_pool.rb +2 -2
  60. metadata +13 -15
  61. data/apis/config/2014-10-17/api-2.json +0 -694
  62. data/apis/config/2014-10-17/paginators-1.json +0 -10
  63. data/apis/ec2/2014-10-01/api-2.json +0 -10267
  64. data/apis/ec2/2014-10-01/paginators-1.json +0 -125
  65. data/apis/ec2/2014-10-01/resources-1.json +0 -2289
  66. data/apis/ec2/2014-10-01/waiters-2.json +0 -453
  67. data/apis/ec2/2015-03-01/api-2.json +0 -11245
  68. data/apis/ec2/2015-03-01/paginators-1.json +0 -125
  69. data/apis/ec2/2015-03-01/resources-1.json +0 -2479
  70. data/apis/ec2/2015-03-01/waiters-2.json +0 -458
@@ -2,45 +2,50 @@
2
2
  "version": 2,
3
3
  "waiters": {
4
4
  "ClusterAvailable": {
5
+ "delay": 60,
5
6
  "operation": "DescribeClusters",
6
7
  "maxAttempts": 30,
7
- "delay": 60,
8
8
  "acceptors": [
9
9
  {
10
- "state": "success",
10
+ "expected": "available",
11
11
  "matcher": "pathAll",
12
- "argument": "Clusters[].ClusterStatus",
13
- "expected": "available"
12
+ "state": "success",
13
+ "argument": "Clusters[].ClusterStatus"
14
14
  },
15
15
  {
16
- "state": "failure",
16
+ "expected": "deleting",
17
17
  "matcher": "pathAny",
18
- "argument": "Clusters[].ClusterStatus",
19
- "expected": "deleting"
18
+ "state": "failure",
19
+ "argument": "Clusters[].ClusterStatus"
20
+ },
21
+ {
22
+ "expected": "ClusterNotFound",
23
+ "matcher": "error",
24
+ "state": "retry"
20
25
  }
21
26
  ]
22
27
  },
23
28
  "ClusterDeleted": {
29
+ "delay": 60,
24
30
  "operation": "DescribeClusters",
25
31
  "maxAttempts": 30,
26
- "delay": 60,
27
32
  "acceptors": [
28
33
  {
29
- "state": "success",
34
+ "expected": "ClusterNotFound",
30
35
  "matcher": "error",
31
- "expected": "ClusterNotFound"
36
+ "state": "success"
32
37
  },
33
38
  {
34
- "state": "failure",
39
+ "expected": "creating",
35
40
  "matcher": "pathAny",
36
- "argument": "Clusters[].ClusterStatus",
37
- "expected": "creating"
41
+ "state": "failure",
42
+ "argument": "Clusters[].ClusterStatus"
38
43
  },
39
44
  {
45
+ "expected": "pathAny",
46
+ "matcher": "pathList",
40
47
  "state": "failure",
41
- "matcher": "pathAny",
42
- "argument": "Clusters[].ClusterStatus",
43
- "expected": "rebooting"
48
+ "argument": "Clusters[].ClusterStatus"
44
49
  }
45
50
  ]
46
51
  },
@@ -64,22 +69,27 @@
64
69
  ]
65
70
  },
66
71
  "SnapshotAvailable": {
72
+ "delay": 15,
67
73
  "operation": "DescribeClusterSnapshots",
68
74
  "maxAttempts": 20,
69
- "delay": 15,
70
75
  "acceptors": [
71
76
  {
72
- "state": "success",
77
+ "expected": "available",
73
78
  "matcher": "pathAll",
74
- "argument": "Snapshots[].Status",
75
- "expected": "available"
79
+ "state": "success",
80
+ "argument": "Snapshots[].Status"
76
81
  },
77
82
  {
83
+ "expected": "failed",
84
+ "matcher": "pathAny",
78
85
  "state": "failure",
86
+ "argument": "Snapshots[].Status"
87
+ },
88
+ {
89
+ "expected": "deleted",
79
90
  "matcher": "pathAny",
80
- "argument": "Snapshots[].Status",
81
- "expected": "failed",
82
- "expected": "deleted"
91
+ "state": "failure",
92
+ "argument": "Snapshots[].Status"
83
93
  }
84
94
  ]
85
95
  }
@@ -275,7 +275,7 @@
275
275
  "PrincipalArn":{"shape":"arnType"},
276
276
  "SAMLAssertion":{"shape":"SAMLAssertionType"},
277
277
  "Policy":{"shape":"sessionPolicyDocumentType"},
278
- "DurationSeconds":{"shape":"durationSecondsType"}
278
+ "DurationSeconds":{"shape":"roleDurationSecondsType"}
279
279
  }
280
280
  },
281
281
  "AssumeRoleWithSAMLResponse":{
@@ -304,7 +304,7 @@
304
304
  "WebIdentityToken":{"shape":"clientTokenType"},
305
305
  "ProviderId":{"shape":"urlType"},
306
306
  "Policy":{"shape":"sessionPolicyDocumentType"},
307
- "DurationSeconds":{"shape":"durationSecondsType"}
307
+ "DurationSeconds":{"shape":"roleDurationSecondsType"}
308
308
  }
309
309
  },
310
310
  "AssumeRoleWithWebIdentityResponse":{
data/bin/aws.rb CHANGED
@@ -102,6 +102,12 @@ module Aws
102
102
  end
103
103
  end
104
104
  end
105
+ class Client
106
+ def resource
107
+ namespace = Aws.const_get(self.class.name.split('::')[1])
108
+ namespace::Resource.new(client: self)
109
+ end
110
+ end
105
111
  end
106
112
 
107
113
  begin
@@ -38,6 +38,7 @@ module Aws
38
38
  api = build_api(definition)
39
39
  shapes = build_shape_map(definition, api, docs)
40
40
  build_operations(definition, api, shapes, docs)
41
+ build_struct_classes(shapes, options)
41
42
  api
42
43
  end
43
44
 
@@ -86,6 +87,13 @@ module Aws
86
87
  op
87
88
  end
88
89
 
90
+ def build_struct_classes(shapes, options)
91
+ type_builder = options[:type_builder] || TypeBuilder.new(Module.new)
92
+ shapes.each_structure do |shape|
93
+ shape[:struct_class] = type_builder.build_type(shape, shapes)
94
+ end
95
+ end
96
+
89
97
  def underscore(str)
90
98
  Seahorse::Util.underscore(str).to_sym
91
99
  end
@@ -38,7 +38,7 @@ module Aws
38
38
 
39
39
  def service_docstring
40
40
  path = "doc-src/services/#{@svc_name}/service.md"
41
- path = 'doc-src/services/default/service.md' unless File.exists?(path)
41
+ path = 'doc-src/services/default/service.md' unless File.exist?(path)
42
42
  template = read(path)
43
43
  svc_name = @svc_name
44
44
  api = @api
@@ -62,7 +62,7 @@ module Aws
62
62
 
63
63
  def errors_docstring
64
64
  path = "doc-src/services/#{@svc_name}/errors.md"
65
- path = 'doc-src/services/default/errors.md' unless File.exists?(path)
65
+ path = 'doc-src/services/default/errors.md' unless File.exist?(path)
66
66
  template = read(path)
67
67
  svc_name = @svc_name
68
68
  api = @api
@@ -90,7 +90,7 @@ module Aws
90
90
 
91
91
  def client_docstring
92
92
  path = "doc-src/services/#{@svc_name}/client.md"
93
- path = 'doc-src/services/default/client.md' unless File.exists?(path)
93
+ path = 'doc-src/services/default/client.md' unless File.exist?(path)
94
94
  render(path)
95
95
  end
96
96
 
@@ -162,7 +162,7 @@ module Aws
162
162
  waiters and the client method they call:
163
163
  <table>
164
164
  <thead>
165
- <tr><th>Waiter Name</th><th>Client Method</th><th>Delay</th><th>Max Attempts</th></tr>
165
+ <tr><th>Waiter Name</th><th>Client Method</th><th>Default Delay:</th><th>Default Max Attempts:</th></tr>
166
166
  </thead>
167
167
  <tbody>
168
168
  #{waiters}
@@ -71,7 +71,7 @@ module Aws
71
71
  end
72
72
 
73
73
  def examples_from_disk(method_name, operation)
74
- dir = "examples/#{@service_name.downcase}/client/#{method_name}/*.md"
74
+ dir = "examples/#{@service_name.downcase}/client/#{method_name}/*.rb"
75
75
  Dir.glob(dir).map do |path|
76
76
  title = File.basename(path).split(/\./).first
77
77
  title = title.sub(/^\d+_/, '').gsub(/_/, ' ')
@@ -4,12 +4,6 @@ module Aws
4
4
 
5
5
  include Seahorse::Model::Shapes
6
6
 
7
- EMPTY_REF = begin
8
- shape = StructureShape.new
9
- shape[:struct_class] = Aws::EmptyStructure
10
- ShapeRef.new(shape: shape)
11
- end
12
-
13
7
  SHAPE_CLASSES = {
14
8
  'blob' => BlobShape,
15
9
  'byte' => StringShape,
@@ -70,7 +64,7 @@ module Aws
70
64
  documentation: documentation,
71
65
  metadata: meta)
72
66
  else
73
- EMPTY_REF
67
+ empty_ref
74
68
  end
75
69
  end
76
70
 
@@ -102,7 +96,6 @@ module Aws
102
96
  target: "#{shape.name}$#{member_name}",
103
97
  ))
104
98
  end
105
- shape[:struct_class] = Structure.new(*shape.member_names)
106
99
  when ListShape
107
100
  shape.member = shape_ref(
108
101
  traits.delete('member'),
@@ -131,6 +124,15 @@ module Aws
131
124
  end
132
125
  end
133
126
 
127
+ def empty_ref
128
+ @empty_ref ||= begin
129
+ shape = StructureShape.new
130
+ shape.name = 'EmptyStructure'
131
+ @shapes['EmptyStructure'] = shape
132
+ ShapeRef.new(shape: shape)
133
+ end
134
+ end
135
+
134
136
  def underscore(str)
135
137
  Seahorse::Util.underscore(str).to_sym
136
138
  end
@@ -36,7 +36,7 @@ module Aws
36
36
  #
37
37
  # # stub data in the constructor
38
38
  # client = Aws::S3::Client.new(stub_responses: {
39
- # list_buckets: { bukets: [{name: 'my-bucket' }] },
39
+ # list_buckets: { buckets: [{name: 'my-bucket' }] },
40
40
  # get_object: { body: 'data' },
41
41
  # })
42
42
  #
@@ -46,7 +46,7 @@ module Aws
46
46
  # You can also specify the stub data using {#stub_responses}
47
47
  #
48
48
  # client = Aws::S3::Client.new(stub_responses: true)
49
- # client.stub_resposnes(:list_buckets, {
49
+ # client.stub_responses(:list_buckets, {
50
50
  # buckets: [{ name: 'my-bucket' }]
51
51
  # })
52
52
  #
@@ -70,14 +70,18 @@ module Aws
70
70
  # fake responses with placeholder values. You can override the data
71
71
  # returned. You can also specify errors it should raise.
72
72
  #
73
+ # # simulate service errors, give the error code
73
74
  # client.stub_responses(:get_object, 'NotFound')
74
75
  # client.get_object(bucket:'aws-sdk', key:'foo')
75
76
  # #=> raises Aws::S3::Errors::NotFound
76
77
  #
78
+ # # to simulate other errors, give the error class, you must
79
+ # # be able to construct an instance with `.new`
77
80
  # client.stub_responses(:get_object, Timeout::Error)
78
81
  # client.get_object(bucket:'aws-sdk', key:'foo')
79
82
  # #=> raises new Timeout::Error
80
83
  #
84
+ # # or you can give an instance of an error class
81
85
  # client.stub_responses(:get_object, RuntimeError.new('custom message'))
82
86
  # client.get_object(bucket:'aws-sdk', key:'foo')
83
87
  # #=> raises the given runtime error object
@@ -1,6 +1,6 @@
1
1
  Aws.add_service(:CloudFront, {
2
- api: "#{Aws::API_DIR}/cloudfront/2014-11-06/api-2.json",
3
- docs: "#{Aws::API_DIR}/cloudfront/2014-11-06/docs-2.json",
4
- paginators: "#{Aws::API_DIR}/cloudfront/2014-11-06/paginators-1.json",
5
- waiters: "#{Aws::API_DIR}/cloudfront/2014-11-06/waiters-2.json",
2
+ api: "#{Aws::API_DIR}/cloudfront/2015-04-17/api-2.json",
3
+ docs: "#{Aws::API_DIR}/cloudfront/2015-04-17/docs-2.json",
4
+ paginators: "#{Aws::API_DIR}/cloudfront/2015-04-17/paginators-1.json",
5
+ waiters: "#{Aws::API_DIR}/cloudfront/2015-04-17/waiters-2.json",
6
6
  })
@@ -0,0 +1,5 @@
1
+ Aws.add_service(:CodeCommit, {
2
+ api: "#{Aws::API_DIR}/codecommit/2015-04-13/api-2.json",
3
+ docs: "#{Aws::API_DIR}/codecommit/2015-04-13/docs-2.json",
4
+ paginators: "#{Aws::API_DIR}/codecommit/2015-04-13/paginators-1.json",
5
+ })
@@ -0,0 +1,4 @@
1
+ Aws.add_service(:CodePipeline, {
2
+ api: "#{Aws::API_DIR}/codepipeline/2015-07-09/api-2.json",
3
+ docs: "#{Aws::API_DIR}/codepipeline/2015-07-09/docs-2.json",
4
+ })
@@ -4,13 +4,11 @@ module Aws
4
4
  extend Deprecations
5
5
 
6
6
  # @return [Credentials]
7
- def credentials
8
- @credentials
9
- end
7
+ attr_reader :credentials
10
8
 
11
9
  # @return [Boolean]
12
10
  def set?
13
- !!@credentials && @credentials.set?
11
+ !!credentials && credentials.set?
14
12
  end
15
13
 
16
14
  # @deprecated Deprecated in 2.1.0. This method is subject to errors
@@ -18,7 +16,7 @@ module Aws
18
16
  # objects. Will be removed in 2.2.0.
19
17
  # @see #credentials
20
18
  def access_key_id
21
- @credentials ? @credentials.access_key_id : nil
19
+ credentials ? credentials.access_key_id : nil
22
20
  end
23
21
  deprecated(:access_key_id, use: '#credentials')
24
22
 
@@ -27,7 +25,7 @@ module Aws
27
25
  # objects. Will be removed in 2.2.0.
28
26
  # @see #credentials
29
27
  def secret_access_key
30
- @credentials ? @credentials.secret_access_key : nil
28
+ credentials ? credentials.secret_access_key : nil
31
29
  end
32
30
  deprecated(:secret_access_key, use: '#credentials')
33
31
 
@@ -36,7 +34,7 @@ module Aws
36
34
  # objects. Will be removed in 2.2.0.
37
35
  # @see #credentials
38
36
  def session_token
39
- @credentials ? @credentials.session_token : nil
37
+ credentials ? credentials.session_token : nil
40
38
  end
41
39
  deprecated(:session_token, use: '#credentials')
42
40
 
@@ -66,8 +66,8 @@ module Aws
66
66
  type, value = extract_type_and_value(obj)
67
67
  case type
68
68
  when :m
69
- value.each.with_object({}) do |(key, value), map|
70
- map[key] = format(value)
69
+ value.each.with_object({}) do |(k, v), map|
70
+ map[k] = format(v)
71
71
  end
72
72
  when :l then value.map { |v| format(v) }
73
73
  when :s then value
@@ -11,6 +11,7 @@ module Aws
11
11
  autoload :AttributeValue, 'aws-sdk-core/dynamodb/attribute_value'
12
12
 
13
13
  class Client
14
+
14
15
  def data_to_http_resp(operation_name, data)
15
16
  api = config.api
16
17
  operation = api.operation(operation_name)
@@ -20,6 +21,19 @@ module Aws
20
21
  ParamValidator.validate!(operation.output, data)
21
22
  protocol_helper.stub_data(api, operation, data)
22
23
  end
24
+
25
+ def stub_data(operation_name, data = {})
26
+ if config.simple_attributes
27
+ rules = config.api.operation(operation_name).output
28
+ translator = Plugins::DynamoDBSimpleAttributes::ValueTranslator
29
+ data = translator.apply(rules, :marshal, data)
30
+ data = super(operation_name, data)
31
+ translator.apply(rules, :unmarshal, data)
32
+ else
33
+ super
34
+ end
35
+ end
36
+
23
37
  end
24
38
  end
25
39
  end
@@ -17,12 +17,11 @@ module Aws
17
17
  @loaded << klass_or_module
18
18
  klass_or_module.constants.each do |const_name|
19
19
  path = klass_or_module.autoload?(const_name)
20
- require(path) if path
21
- const = klass_or_module.const_get(const_name)
22
- if const.is_a?(Module)
23
- unless @loaded.include?(const)
24
- load(const)
25
- end
20
+ begin
21
+ require(path) if path
22
+ const = klass_or_module.const_get(const_name)
23
+ self.load(const) if Module === const && !@loaded.include?(const)
24
+ rescue LoadError
26
25
  end
27
26
  end
28
27
  self
@@ -3,4 +3,5 @@ Aws.add_service(:IAM, {
3
3
  docs: "#{Aws::API_DIR}/iam/2010-05-08/docs-2.json",
4
4
  paginators: "#{Aws::API_DIR}/iam/2010-05-08/paginators-1.json",
5
5
  resources: "#{Aws::API_DIR}/iam/2010-05-08/resources-1.json",
6
+ waiters: "#{Aws::API_DIR}/iam/2010-05-08/waiters-2.json",
6
7
  })
@@ -82,7 +82,7 @@ module Aws
82
82
  profile_name = http_get(conn, path).lines.first.strip
83
83
  http_get(conn, path + profile_name)
84
84
  end
85
- rescue *FAILURES => e
85
+ rescue *FAILURES
86
86
  if failed_attempts < @retries
87
87
  @backoff.call(failed_attempts)
88
88
  failed_attempts += 1
@@ -8,10 +8,10 @@ module Aws
8
8
  # @return [Seahorse::Client::Response]
9
9
  def call(context)
10
10
  build_request(context)
11
- resp = @handler.call(context)
12
- resp.on(200..299) { |resp| parse_response(resp) }
13
- resp.on(200..599) { |resp| apply_request_id(context) }
14
- resp
11
+ response = @handler.call(context)
12
+ response.on(200..299) { |resp| parse_response(resp) }
13
+ response.on(200..599) { |resp| apply_request_id(context) }
14
+ response
15
15
  end
16
16
 
17
17
  private
@@ -2,38 +2,39 @@ module Aws
2
2
 
3
3
  # Decorates a {Seahorse::Client::Response} with paging methods:
4
4
  #
5
- # page = PageableResponse.new(response, pager)
6
- # page.last_page?
5
+ # resp = s3.list_objects(params)
6
+ # resp.last_page?
7
7
  # #=> false
8
8
  #
9
9
  # # sends a request to receive the next response page
10
- # page = page.next_page
11
- # page.last_page?
10
+ # resp = resp.next_page
11
+ # resp.last_page?
12
12
  # #=> true
13
13
  #
14
- # page.next_page
14
+ # resp.next_page
15
15
  # #=> raises PageableResponse::LastPageError
16
16
  #
17
17
  # You can enumerate all response pages with a block
18
18
  #
19
- # page = PageableResponse.new(response, pager)
20
- # page.each do |page|
19
+ # ec2.describe_instances(params).each do |page|
21
20
  # # yields once per page
21
+ # page.reservations.each do |r|
22
+ # # ...
23
+ # end
22
24
  # end
23
25
  #
24
26
  # Or using {#next_page} and {#last_page?}:
25
27
  #
26
- # page = PageableResponse.new(response, pager)
27
- # page = page.next_page until page.last_page?
28
- #
29
- # @note Normally you should not need to construct a {PageableResponse}
30
- # directly. The {Plugins::ResponsePaging} plugin automatically
31
- # decorates all responses with a {PageableResponse}.
28
+ # resp.last_page?
29
+ # resp = resp.next_page until resp.last_page?
32
30
  #
33
31
  module PageableResponse
34
32
 
35
- def self.included(base)
36
- base.send(:include, Enumerable)
33
+ def self.extended(base)
34
+ base.send(:extend, Enumerable)
35
+ base.send(:extend, UnsafeEnumerableMethods)
36
+ base.instance_variable_set("@last_page", nil)
37
+ base.instance_variable_set("@more_results", nil)
37
38
  end
38
39
 
39
40
  # @return [Paging::Pager]
@@ -79,24 +80,6 @@ module Aws
79
80
  end
80
81
  alias each_page each
81
82
 
82
- # @api private
83
- def count
84
- if respond_to?(:count)
85
- data.count
86
- else
87
- raise NotImplementedError
88
- end
89
- end
90
-
91
- # @api private
92
- def respond_to?(method_name, *args)
93
- if method_name == :count
94
- data.respond_to?(:count)
95
- else
96
- super
97
- end
98
- end
99
-
100
83
  private
101
84
 
102
85
  # @param [Hash] params A hash of additional request params to
@@ -114,7 +97,7 @@ module Aws
114
97
  # @return [Hash] Returns the hash of request parameters for the
115
98
  # next page, merging any given params.
116
99
  def next_page_params(params)
117
- context.params.merge(@pager.next_tokens(self).merge(params))
100
+ context[:original_params].merge(@pager.next_tokens(self).merge(params))
118
101
  end
119
102
 
120
103
  # Raised when calling {PageableResponse#next_page} on a pager that
@@ -133,5 +116,32 @@ module Aws
133
116
 
134
117
  end
135
118
 
119
+ # A handful of Enumerable methods, such as #count are not safe
120
+ # to call on a pageable response, as this would trigger n api calls
121
+ # simply to count the number of response pages, when likely what is
122
+ # wanted is to access count on the data. Same for #to_h.
123
+ module UnsafeEnumerableMethods
124
+
125
+ def count
126
+ if data.respond_to?(:count)
127
+ data.count
128
+ else
129
+ raise NoMethodError, "undefined method `count'"
130
+ end
131
+ end
132
+
133
+ def respond_to?(method_name, *args)
134
+ if method_name == :count
135
+ data.respond_to?(:count)
136
+ else
137
+ false
138
+ end
139
+ end
140
+
141
+ def to_h
142
+ data.to_h
143
+ end
144
+
145
+ end
136
146
  end
137
147
  end
@@ -3,9 +3,8 @@ module Aws
3
3
  class Pager
4
4
 
5
5
  def initialize(rules)
6
- if rules['more_results']
7
- @more_results = underscore(rules['more_results'])
8
- end
6
+ @more_results = rules['more_results']
7
+ @more_results = underscore(@more_results) if @more_results
9
8
  if rules['limit_key']
10
9
  @limit_key = underscore(rules['limit_key']).to_sym
11
10
  end
@@ -139,6 +139,10 @@ module Aws
139
139
 
140
140
  include Seahorse::Model::Shapes
141
141
 
142
+ def self.apply(rules, mode, data)
143
+ new(rules, mode).apply(data)
144
+ end
145
+
142
146
  def initialize(rules, mode)
143
147
  @rules = rules
144
148
  @mode = mode
@@ -64,6 +64,7 @@ module Aws
64
64
  context.http_request.http_method = 'GET'
65
65
  context.http_request.endpoint = new_endpoint(context)
66
66
  context.http_request.body = ''
67
+ context.http_request.headers.delete('Content-Type')
67
68
  end
68
69
 
69
70
  def new_endpoint(context)
@@ -74,7 +75,7 @@ module Aws
74
75
  end
75
76
 
76
77
  def presigned_url(http_request, config)
77
- signer = Signers::V4.new('ec2', config.credentials, config.region)
78
+ signer = Signers::V4.new(config.credentials, 'ec2', config.region)
78
79
  signer.presigned_url(http_request, expires_in: 3600)
79
80
  end
80
81
 
@@ -3,8 +3,8 @@ module Aws
3
3
 
4
4
  # @seahorse.client.option [required, String] :region
5
5
  # The AWS region to connect to. The region is used to construct
6
- # the client endpoint. Defaults to `ENV['AWS_DEFAULT_REGION']`.
7
- # Also checks `AWS_REGION` and `AMAZON_REGION`.
6
+ # the client endpoint. Defaults to `ENV['AWS_REGION']`.
7
+ # Also checks `AMAZON_REGION` and `AWS_DEFAULT_REGION`.
8
8
  #
9
9
  # @seahorse.client.option [String] :endpoint A default endpoint is
10
10
  # constructed from the `:region`.
@@ -22,6 +22,7 @@ module Aws
22
22
  class Handler < Seahorse::Client::Handler
23
23
 
24
24
  def call(context)
25
+ context[:original_params] = context.params
25
26
  resp = @handler.call(context)
26
27
  resp.extend(PageableResponse)
27
28
  resp.pager = context.operation[:pager]
@@ -53,7 +53,7 @@ module Aws
53
53
  # @note This method does not indicate if the file found at {#path}
54
54
  # will be parsable, only if it can be read.
55
55
  def loadable?
56
- !path.nil? && File.exists?(path) && File.readable?(path)
56
+ !path.nil? && File.exist?(path) && File.readable?(path)
57
57
  end
58
58
 
59
59
  private
@@ -92,7 +92,7 @@ module Aws
92
92
  map = {}
93
93
  file.lines.each do |line|
94
94
  line = line.split(/^|\s;/).first # remove comments
95
- section = line.match(/^\s*\[([^\[\]]+)\]\s*$/) unless line.nil?
95
+ section = line.match(/^\s*\[([^\[\]]+)\]\s*(#.+)?$/) unless line.nil?
96
96
  if section
97
97
  current_section = section[1]
98
98
  elsif current_section