aws-sdk-core 2.0.0.rc1 → 2.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/README.md +6 -3
  4. data/Rakefile +2 -0
  5. data/apis/AutoScaling-2011-01-01.json +1 -0
  6. data/apis/CloudFormation-2010-05-15.json +75 -0
  7. data/apis/CloudFront-2012-05-05.json +1 -0
  8. data/apis/CloudFront-2013-05-12.json +1 -0
  9. data/apis/CloudFront-2013-08-26.json +1 -0
  10. data/apis/CloudSearch-2011-02-01.json +1 -0
  11. data/apis/CloudWatch-2010-08-01.json +1 -0
  12. data/apis/DataPipeline-2012-10-29.json +1 -0
  13. data/apis/DirectConnect-2012-10-25.json +1 -0
  14. data/apis/DynamoDB-2011-12-05.json +1 -0
  15. data/apis/DynamoDB-2012-08-10.json +1 -0
  16. data/apis/EC2-2013-06-15.json +1 -0
  17. data/apis/EC2-2013-10-01.json +1 -0
  18. data/apis/EMR-2009-03-31.json +1 -0
  19. data/apis/ElastiCache-2012-11-15.json +1 -0
  20. data/apis/ElastiCache-2013-06-15.json +1 -0
  21. data/apis/ElasticBeanstalk-2010-12-01.json +1 -0
  22. data/apis/ElasticLoadBalancing-2012-06-01.json +73 -0
  23. data/apis/ElasticTranscoder-2012-09-25.json +231 -0
  24. data/apis/Glacier-2012-06-01.json +2 -0
  25. data/apis/IAM-2010-05-08.json +1 -0
  26. data/apis/ImportExport-2010-06-01.json +1 -0
  27. data/apis/OpsWorks-2013-02-18.json +1 -0
  28. data/apis/RDS-2013-01-10.json +1 -0
  29. data/apis/RDS-2013-02-12.json +1 -0
  30. data/apis/RDS-2013-05-15.json +1 -0
  31. data/apis/Redshift-2012-12-01.json +1 -0
  32. data/apis/Route53-2012-12-12.json +1 -0
  33. data/apis/S3-2006-03-01.json +5 -0
  34. data/apis/SDB-2009-04-15.json +1 -0
  35. data/apis/SES-2010-12-01.json +1 -0
  36. data/apis/SNS-2010-03-31.json +1 -0
  37. data/apis/SQS-2012-11-05.json +1 -0
  38. data/apis/STS-2011-06-15.json +1 -0
  39. data/apis/SWF-2012-01-25.json +1 -0
  40. data/apis/StorageGateway-2012-06-30.json +1 -0
  41. data/apis/StorageGateway-2013-06-30.json +2018 -0
  42. data/apis/Support-2013-04-15.json +1 -0
  43. data/apis/source/cloudformation-2010-05-15.json +118 -12
  44. data/apis/source/elasticloadbalancing-2012-06-01.json +347 -220
  45. data/apis/source/elastictranscoder-2012-09-25.json +315 -5
  46. data/apis/source/s3-2006-03-01.json +3 -0
  47. data/apis/source/storagegateway-2013-06-30.json +12560 -0
  48. data/apis/source/storagegateway-2013-06-30.paginators.json +28 -0
  49. data/doc-src/plugins/apis.rb +44 -1
  50. data/doc-src/templates/default/fulldoc/html/setup.rb +1 -1
  51. data/features/common/step_definitions.rb +3 -5
  52. data/features/env.rb +2 -0
  53. data/features/glacier/client.feature +8 -0
  54. data/features/glacier/step_definitions.rb +7 -7
  55. data/features/s3/step_definitions.rb +2 -3
  56. data/lib/aws.rb +75 -69
  57. data/lib/aws/api/service_translators/glacier.rb +1 -0
  58. data/lib/aws/api/translator.rb +13 -8
  59. data/lib/aws/credentials.rb +5 -5
  60. data/lib/aws/instance_profile_credentials.rb +113 -0
  61. data/lib/aws/plugins/credentials.rb +2 -1
  62. data/lib/aws/plugins/glacier_account_id.rb +11 -0
  63. data/lib/aws/plugins/glacier_checksums.rb +7 -3
  64. data/lib/aws/plugins/instance_profile_credentials.rb +14 -0
  65. data/lib/aws/plugins/s3_bucket_dns.rb +17 -14
  66. data/lib/aws/plugins/s3_md5s.rb +3 -3
  67. data/lib/aws/service.rb +10 -9
  68. data/lib/aws/signers/s3.rb +2 -2
  69. data/lib/aws/signers/v2.rb +1 -1
  70. data/lib/aws/signers/v4.rb +2 -2
  71. data/lib/aws/version.rb +1 -1
  72. data/lib/aws/xml/serializer.rb +1 -1
  73. data/spec/aws/instance_profile_credentials_spec.rb +94 -0
  74. data/spec/aws/operations_spec.rb +1 -1
  75. data/spec/aws/plugins/credentials_spec.rb +2 -2
  76. data/spec/fixtures/operations/glacier/account_id_param.yml +13 -0
  77. data/spec/fixtures/operations/glacier/custom_account_id.yml +11 -0
  78. data/spec/fixtures/operations/glacier/default_account_id.yml +10 -0
  79. data/spec/fixtures/operations/s3/content_type_header.yml +12 -0
  80. data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +1 -1
  81. data/tasks/apis.rake +2 -2
  82. data/tasks/docs.rake +2 -1
  83. data/tasks/handlers.rake +30 -0
  84. data/vendor/seahorse/lib/seahorse/client.rb +1 -0
  85. data/vendor/seahorse/lib/seahorse/client/base.rb +0 -18
  86. data/vendor/seahorse/lib/seahorse/client/block_io.rb +0 -7
  87. data/vendor/seahorse/lib/seahorse/client/configuration.rb +57 -37
  88. data/vendor/seahorse/lib/seahorse/client/handler_list.rb +115 -78
  89. data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +19 -15
  90. data/vendor/seahorse/lib/seahorse/client/http/request.rb +0 -15
  91. data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +0 -7
  92. data/vendor/seahorse/lib/seahorse/client/managed_file.rb +14 -0
  93. data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +1 -3
  94. data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +1 -1
  95. data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +81 -10
  96. data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +1 -71
  97. data/vendor/seahorse/lib/seahorse/client/request.rb +26 -3
  98. data/vendor/seahorse/spec/seahorse/client/base_spec.rb +1 -5
  99. data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +1 -10
  100. data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +10 -10
  101. data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +46 -14
  102. data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +1 -42
  103. data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +1 -6
  104. data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +1 -1
  105. data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +5 -4
  106. data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +1 -0
  107. data/vendor/seahorse/spec/seahorse/client/plugins/{restful_bindings/uri_path_builder_spec.rb → endpoint/request_uri_builder_spec.rb} +3 -3
  108. data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +1 -11
  109. data/vendor/seahorse/spec/seahorse/client/request_spec.rb +63 -13
  110. metadata +21 -3
@@ -0,0 +1,28 @@
1
+ {
2
+ "pagination": {
3
+ "DescribeCachediSCSIVolumes": {
4
+ "result_key": "CachediSCSIVolumes"
5
+ },
6
+ "DescribeStorediSCSIVolumes": {
7
+ "result_key": "StorediSCSIVolumes"
8
+ },
9
+ "ListGateways": {
10
+ "input_token": "Marker",
11
+ "output_token": "Marker",
12
+ "limit_key": "Limit",
13
+ "result_key": "Gateways"
14
+ },
15
+ "ListLocalDisks": {
16
+ "result_key": "Disks"
17
+ },
18
+ "ListVolumeRecoveryPoints": {
19
+ "result_key": "VolumeRecoveryPointInfos"
20
+ },
21
+ "ListVolumes": {
22
+ "input_token": "Marker",
23
+ "output_token": "Marker",
24
+ "limit_key": "Limit",
25
+ "result_key": "VolumeInfos"
26
+ }
27
+ }
28
+ }
@@ -56,10 +56,53 @@ Returns a new instance of {#{svc_name}}.
56
56
  end
57
57
 
58
58
  def document_svc_class(svc_name, apis)
59
+
60
+ oldest_api = apis.sort_by(&:version).first
61
+ default_api = apis.sort_by(&:version).last
62
+ full_name = default_api.metadata['service_full_name']
63
+
59
64
  namespace = YARD::Registry['Aws']
60
65
  klass = YARD::CodeObjects::ClassObject.new(namespace, svc_name)
61
66
  klass.superclass = YARD::Registry['Aws::Service']
62
- klass.docstring = 'A service constructor.'
67
+ klass.docstring = <<-DOCSTRING
68
+ A service client builder for #{full_name}.
69
+
70
+ ## Configuration
71
+
72
+ You can specify global default configuration options via `Aws.config`. Values
73
+ in `Aws.config` are used as default options for all services.
74
+
75
+ Aws.config[:region] = 'us-west-2'
76
+
77
+ You can specify service specific defaults as well:
78
+
79
+ Aws.config[:#{svc_name.downcase}] = { region: 'us-west-1' }
80
+
81
+ This has a higher precendence that values at the root of `Aws.config` and will
82
+ only applied to objects constructed by {new}.
83
+
84
+ ## Regions & Endpoints
85
+
86
+ You must configure a default region with `Aws.config` or provide a `:region`
87
+ when creating a service client. The regions listed below will connect
88
+ to the following endpoints:
89
+
90
+ #{default_api.metadata['regional_endpoints'].map { |r,e| "* `#{r}` - #{e}"}.join("\n")}
91
+
92
+ ## API Versions
93
+
94
+ Calling {new} will construct and return a versioned service client. The client
95
+ will default to the most recent API version. You can also specify an API version:
96
+
97
+ #{svc_name.downcase} = Aws::#{svc_name}.new # Aws::#{svc_name}::V#{default_api.version.gsub(/-/, '')}
98
+ #{svc_name.downcase} = Aws::#{svc_name}.new(api_version: '#{oldest_api.version}') # Aws::#{svc_name}::V#{oldest_api.version.gsub(/-/, '')}
99
+
100
+ The following API versions are available for Aws::#{svc_name}:
101
+
102
+ #{apis.map{ |a| "* {V#{a.version.gsub(/-/, '')} #{a.version}}" }.join("\n")}
103
+
104
+ You can specify the API version for the client by passing `:api_version` to {new}.
105
+ DOCSTRING
63
106
  klass.docstring.add_tag(YARD::Tags::Tag.new(:service, svc_name))
64
107
 
65
108
  svc = Aws.const_get(svc_name)
@@ -35,7 +35,7 @@ def class_list(root = Registry.root)
35
35
 
36
36
  services = Registry.at('Aws').children.select { |c| c.has_tag?(:service) }
37
37
 
38
- services.each do |svc|
38
+ services.sort_by(&:name).each do |svc|
39
39
  out << "<li><a class='toggle'></a>"
40
40
  out << linkify(svc, svc.name)
41
41
  out << " &lt; Service"
@@ -1,10 +1,8 @@
1
1
  def call_request(service, operation_name, params = {})
2
2
  service = instance_variable_get("@#{service}")
3
- begin
4
- @response = service.build_request(operation_name, params).send_request
5
- rescue Aws::Errors::ServiceError => error
6
- @error = error
7
- end
3
+ @response = service.build_request(operation_name, params).send_request
4
+ @error = @response.error
5
+ @response
8
6
  end
9
7
 
10
8
  def eventually(seconds = 15, &block)
@@ -21,3 +21,5 @@ else
21
21
  puts msg
22
22
  exit(0)
23
23
  end
24
+
25
+ Aws.config[:raise_response_errors] = false
@@ -20,6 +20,14 @@ Feature: Amazon Glacier
20
20
  When I upload an archive from a 5.5MB large file
21
21
  Then I should be able to delete the archive
22
22
 
23
+ # There was an issue where the client would fail attempting to compute
24
+ # a checksum of an empty body, this step ensures that the checksum
25
+ # computation does not hang.
26
+ @upload
27
+ Scenario: Attempting to upload an empty archive
28
+ When I upload an archive with the contents ""
29
+ Then a "InvalidParameterValueException" error should be raised
30
+
23
31
  Scenario: Error handling
24
32
  When I call "list_vaults" on "glacier" with:
25
33
  """
@@ -1,9 +1,9 @@
1
1
  def upload_glacier_archive(contents)
2
- @response = @glacier.upload_archive(
2
+ resp = call_request('glacier', 'upload_archive', {
3
3
  vault_name: @vault_name,
4
- account_id: '-',
5
- body: contents)
6
- @archive_id = @response.archive_id
4
+ body: contents,
5
+ })
6
+ @archive_id = resp.data.archive_id if resp.data
7
7
  end
8
8
 
9
9
  When(/^I upload an archive with the contents "(.*?)"$/) do |contents|
@@ -18,8 +18,8 @@ When(/^I upload an archive from a (\d+\.\d+)MB large file$/) do |size|
18
18
  end
19
19
 
20
20
  Then(/^I should be able to delete the archive$/) do
21
- @glacier.delete_archive(
21
+ call_request('glacier', 'delete_archive', {
22
22
  vault_name: @vault_name,
23
- account_id: '-',
24
- archive_id: @archive_id)
23
+ archive_id: @archive_id,
24
+ })
25
25
  end
@@ -40,9 +40,8 @@ end
40
40
 
41
41
  Then(/^the bucket should not exist$/) do
42
42
  eventually do
43
- expect {
44
- @s3.get_bucket_location(bucket: @bucket_name)
45
- }.to raise_error(Aws::S3::Errors::NoSuchBucket)
43
+ resp = @s3.get_bucket_location(bucket: @bucket_name)
44
+ expect(resp.error).to be_kind_of(Aws::S3::Errors::NoSuchBucket)
46
45
  end
47
46
  end
48
47
 
data/lib/aws.rb CHANGED
@@ -3,103 +3,109 @@ module Aws
3
3
  # @api private
4
4
  GEM_ROOT = File.dirname(File.dirname(__FILE__))
5
5
 
6
+ # @api private
7
+ SRC = GEM_ROOT + '/lib/aws'
8
+
6
9
  @config = {}
7
10
 
8
- autoload :Credentials, 'aws/credentials'
9
- autoload :Errors, 'aws/errors'
10
- autoload :ErrorHandler, 'aws/error_handler'
11
- autoload :RequestHandler, 'aws/request_handler'
12
- autoload :ResponseHandler, 'aws/response_handler'
13
- autoload :Service, 'aws/service'
14
- autoload :Structure, 'aws/structure'
15
- autoload :TimestampFormatter, 'aws/timestamp_formatter'
16
- autoload :Util, 'aws/util'
17
- autoload :VERSION, 'aws/version'
11
+ autoload :Credentials, "#{SRC}/credentials"
12
+ autoload :Errors, "#{SRC}/errors"
13
+ autoload :ErrorHandler, "#{SRC}/error_handler"
14
+ autoload :InstanceProfileCredentials, "#{SRC}/instance_profile_credentials"
15
+ autoload :RequestHandler, "#{SRC}/request_handler"
16
+ autoload :ResponseHandler, "#{SRC}/response_handler"
17
+ autoload :Service, "#{SRC}/service"
18
+ autoload :Structure, "#{SRC}/structure"
19
+ autoload :TimestampFormatter, "#{SRC}/timestamp_formatter"
20
+ autoload :Util, "#{SRC}/util"
21
+ autoload :VERSION, "#{SRC}/version"
18
22
 
19
23
  # @api private
20
24
  module Api
21
- autoload :BaseTranslator, 'aws/api/base_translator'
22
- autoload :Documentor, 'aws/api/documentor'
23
- autoload :DocExample, 'aws/api/doc_example'
24
- autoload :InputShapeTranslator, 'aws/api/shape_translator'
25
- autoload :OperationTranslator, 'aws/api/operation_translator'
26
- autoload :OutputShapeTranslator, 'aws/api/shape_translator'
27
- autoload :ServiceNamer, 'aws/api/service_namer'
28
- autoload :ShapeTranslator, 'aws/api/shape_translator'
29
- autoload :Translator, 'aws/api/translator'
30
- autoload :Visitor, 'aws/api/visitor'
25
+ autoload :BaseTranslator, "#{SRC}/api/base_translator"
26
+ autoload :Documentor, "#{SRC}/api/documentor"
27
+ autoload :DocExample, "#{SRC}/api/doc_example"
28
+ autoload :InputShapeTranslator, "#{SRC}/api/shape_translator"
29
+ autoload :OperationTranslator, "#{SRC}/api/operation_translator"
30
+ autoload :OutputShapeTranslator, "#{SRC}/api/shape_translator"
31
+ autoload :ServiceNamer, "#{SRC}/api/service_namer"
32
+ autoload :ShapeTranslator, "#{SRC}/api/shape_translator"
33
+ autoload :Translator, "#{SRC}/api/translator"
34
+ autoload :Visitor, "#{SRC}/api/visitor"
31
35
 
32
36
  module ServiceTranslators
33
- autoload :CloudFront, 'aws/api/service_translators/cloud_front'
34
- autoload :DynamoDB, 'aws/api/service_translators/dynamo_db'
35
- autoload :Glacier, 'aws/api/service_translators/glacier'
36
- autoload :ImportExport, 'aws/api/service_translators/import_export'
37
- autoload :Route53, 'aws/api/service_translators/route53'
38
- autoload :S3, 'aws/api/service_translators/s3'
39
- autoload :SQS, 'aws/api/service_translators/sqs'
40
- autoload :SWF, 'aws/api/service_translators/swf'
37
+ autoload :CloudFront, "#{SRC}/api/service_translators/cloud_front"
38
+ autoload :DynamoDB, "#{SRC}/api/service_translators/dynamo_db"
39
+ autoload :Glacier, "#{SRC}/api/service_translators/glacier"
40
+ autoload :ImportExport, "#{SRC}/api/service_translators/import_export"
41
+ autoload :Route53, "#{SRC}/api/service_translators/route53"
42
+ autoload :S3, "#{SRC}/api/service_translators/s3"
43
+ autoload :SQS, "#{SRC}/api/service_translators/sqs"
44
+ autoload :SWF, "#{SRC}/api/service_translators/swf"
41
45
  end
42
46
 
43
47
  end
44
48
 
45
49
  # @api private
46
50
  module Json
47
- autoload :Builder, 'aws/json/builder'
48
- autoload :ErrorParser, 'aws/json/error_parser'
49
- autoload :Parser, 'aws/json/parser'
50
- autoload :Serializer, 'aws/json/serializer'
51
+ autoload :Builder, "#{SRC}/json/builder"
52
+ autoload :ErrorParser, "#{SRC}/json/error_parser"
53
+ autoload :Parser, "#{SRC}/json/parser"
54
+ autoload :Serializer, "#{SRC}/json/serializer"
51
55
  end
52
56
 
53
57
  module Plugins
54
- autoload :Credentials, 'aws/plugins/credentials'
55
- autoload :DynamoDBExtendedRetries, 'aws/plugins/dynamodb_extended_retries'
56
- autoload :GlacierApiVersion, 'aws/plugins/glacier_api_version'
57
- autoload :GlacierChecksums, 'aws/plugins/glacier_checksums'
58
- autoload :GlobalConfiguration, 'aws/plugins/global_configuration'
59
- autoload :JsonProtocol, 'aws/plugins/json_protocol'
60
- autoload :JsonRpcHeaders, 'aws/plugins/json_rpc_headers'
61
- autoload :QueryProtocol, 'aws/plugins/query_protocol'
62
- autoload :RegionalEndpoint, 'aws/plugins/regional_endpoint'
63
- autoload :RetryErrors, 'aws/plugins/retry_errors'
64
- autoload :S3BucketDns, 'aws/plugins/s3_bucket_dns'
65
- autoload :S3CompleteMultipartUploadFix, 'aws/plugins/s3_complete_multipart_upload_fix'
66
- autoload :S3GetBucketLocationFix, 'aws/plugins/s3_get_bucket_location_fix'
67
- autoload :S3Md5s, 'aws/plugins/s3_md5s'
68
- autoload :S3Redirects, 'aws/plugins/s3_redirects'
69
- autoload :S3Signer, 'aws/plugins/s3_signer'
70
- autoload :SignatureV2, 'aws/plugins/signature_v2'
71
- autoload :SignatureV3, 'aws/plugins/signature_v3'
72
- autoload :SignatureV4, 'aws/plugins/signature_v4'
73
- autoload :SQSQueueUrls, 'aws/plugins/sqs_queue_urls'
74
- autoload :SWFReadTimeouts, 'aws/plugins/swf_read_timeouts'
75
- autoload :UserAgent, 'aws/plugins/user_agent'
76
- autoload :XmlProtocol, 'aws/plugins/xml_protocol'
58
+ autoload :Credentials, "#{SRC}/plugins/credentials"
59
+ autoload :DynamoDBExtendedRetries, "#{SRC}/plugins/dynamodb_extended_retries"
60
+ autoload :GlacierAccountId, "#{SRC}/plugins/glacier_account_id"
61
+ autoload :GlacierApiVersion, "#{SRC}/plugins/glacier_api_version"
62
+ autoload :GlacierChecksums, "#{SRC}/plugins/glacier_checksums"
63
+ autoload :GlobalConfiguration, "#{SRC}/plugins/global_configuration"
64
+ autoload :InstanceProfileCredentials, "#{SRC}/plugins/instance_profile_credentials"
65
+ autoload :JsonProtocol, "#{SRC}/plugins/json_protocol"
66
+ autoload :JsonRpcHeaders, "#{SRC}/plugins/json_rpc_headers"
67
+ autoload :QueryProtocol, "#{SRC}/plugins/query_protocol"
68
+ autoload :RegionalEndpoint, "#{SRC}/plugins/regional_endpoint"
69
+ autoload :RetryErrors, "#{SRC}/plugins/retry_errors"
70
+ autoload :S3BucketDns, "#{SRC}/plugins/s3_bucket_dns"
71
+ autoload :S3CompleteMultipartUploadFix, "#{SRC}/plugins/s3_complete_multipart_upload_fix"
72
+ autoload :S3GetBucketLocationFix, "#{SRC}/plugins/s3_get_bucket_location_fix"
73
+ autoload :S3Md5s, "#{SRC}/plugins/s3_md5s"
74
+ autoload :S3Redirects, "#{SRC}/plugins/s3_redirects"
75
+ autoload :S3Signer, "#{SRC}/plugins/s3_signer"
76
+ autoload :SignatureV2, "#{SRC}/plugins/signature_v2"
77
+ autoload :SignatureV3, "#{SRC}/plugins/signature_v3"
78
+ autoload :SignatureV4, "#{SRC}/plugins/signature_v4"
79
+ autoload :SQSQueueUrls, "#{SRC}/plugins/sqs_queue_urls"
80
+ autoload :SWFReadTimeouts, "#{SRC}/plugins/swf_read_timeouts"
81
+ autoload :UserAgent, "#{SRC}/plugins/user_agent"
82
+ autoload :XmlProtocol, "#{SRC}/plugins/xml_protocol"
77
83
  end
78
84
 
79
85
  # @api private
80
86
  module Query
81
- autoload :Builder, 'aws/query/builder'
82
- autoload :Param, 'aws/query/param'
83
- autoload :ParamList, 'aws/query/param_list'
84
- autoload :Serializer, 'aws/query/serializer'
87
+ autoload :Builder, "#{SRC}/query/builder"
88
+ autoload :Param, "#{SRC}/query/param"
89
+ autoload :ParamList, "#{SRC}/query/param_list"
90
+ autoload :Serializer, "#{SRC}/query/serializer"
85
91
  end
86
92
 
87
93
  # @api private
88
94
  module Signers
89
- autoload :Base, 'aws/signers/base'
90
- autoload :Handler, 'aws/signers/handler'
91
- autoload :S3, 'aws/signers/s3'
92
- autoload :V2, 'aws/signers/v2'
93
- autoload :V3, 'aws/signers/v3'
94
- autoload :V4, 'aws/signers/v4'
95
+ autoload :Base, "#{SRC}/signers/base"
96
+ autoload :Handler, "#{SRC}/signers/handler"
97
+ autoload :S3, "#{SRC}/signers/s3"
98
+ autoload :V2, "#{SRC}/signers/v2"
99
+ autoload :V3, "#{SRC}/signers/v3"
100
+ autoload :V4, "#{SRC}/signers/v4"
95
101
  end
96
102
 
97
103
  # @api private
98
104
  module Xml
99
- autoload :Builder, 'aws/xml/builder'
100
- autoload :ErrorParser, 'aws/xml/error_parser'
101
- autoload :Parser, 'aws/xml/parser'
102
- autoload :Serializer, 'aws/xml/serializer'
105
+ autoload :Builder, "#{SRC}/xml/builder"
106
+ autoload :ErrorParser, "#{SRC}/xml/error_parser"
107
+ autoload :Parser, "#{SRC}/xml/parser"
108
+ autoload :Serializer, "#{SRC}/xml/serializer"
103
109
  end
104
110
 
105
111
  class << self
@@ -11,6 +11,7 @@ module Aws::Api::ServiceTranslators::Glacier
11
11
  end
12
12
 
13
13
  def apply_plugins(api)
14
+ api.plugins << "Aws::Plugins::GlacierAccountId"
14
15
  api.plugins << "Aws::Plugins::GlacierApiVersion"
15
16
  api.plugins << "Aws::Plugins::GlacierChecksums"
16
17
  end
@@ -4,6 +4,18 @@ module Aws
4
4
  module Api
5
5
  class Translator < BaseTranslator
6
6
 
7
+ DEFAULT_PLUGINS = %w(
8
+ Seahorse::Client::Plugins::Logging
9
+ Seahorse::Client::Plugins::RestfulBindings
10
+ Seahorse::Client::Plugins::ContentLength
11
+ Aws::Plugins::UserAgent
12
+ Aws::Plugins::RetryErrors
13
+ Aws::Plugins::GlobalConfiguration
14
+ Aws::Plugins::RegionalEndpoint
15
+ Aws::Plugins::InstanceProfileCredentials
16
+ Aws::Plugins::Credentials
17
+ )
18
+
7
19
  def self.translate(src, options = {})
8
20
  super(src, options)
9
21
  end
@@ -91,14 +103,7 @@ module Aws
91
103
 
92
104
  def set_type(type)
93
105
  plugins = @properties['plugins'] ||= []
94
- plugins << 'Seahorse::Client::Plugins::Logging'
95
- plugins << 'Seahorse::Client::Plugins::RestfulBindings'
96
- plugins << 'Seahorse::Client::Plugins::ContentLength'
97
- plugins << 'Aws::Plugins::UserAgent'
98
- plugins << 'Aws::Plugins::RetryErrors'
99
- plugins << 'Aws::Plugins::GlobalConfiguration'
100
- plugins << 'Aws::Plugins::RegionalEndpoint'
101
- plugins << 'Aws::Plugins::Credentials'
106
+ plugins.concat(DEFAULT_PLUGINS)
102
107
  plugins.push(*case type
103
108
  when 'query' then ['Aws::Plugins::QueryProtocol']
104
109
  when 'json' then [
@@ -11,24 +11,24 @@ module Aws
11
11
  end
12
12
 
13
13
  # @return [String, nil]
14
- attr_accessor :access_key_id
14
+ attr_reader :access_key_id
15
15
 
16
16
  # @return [String, nil]
17
- attr_accessor :secret_access_key
17
+ attr_reader :secret_access_key
18
18
 
19
19
  # @return [String, nil]
20
- attr_accessor :session_token
20
+ attr_reader :session_token
21
21
 
22
22
  # @return [Boolean] Returns `true` if the access key id and secret
23
23
  # access key are both set.
24
24
  def set?
25
- !!(@access_key_id && @secret_access_key)
25
+ !!(access_key_id && secret_access_key)
26
26
  end
27
27
 
28
28
  # Removing the secret access key from the default inspect string.
29
29
  # @api private
30
30
  def inspect
31
- "#<#{self.class.name} access_key_id=#{access_key_id}>"
31
+ "#<#{self.class.name} access_key_id=#{access_key_id.inspect}>"
32
32
  end
33
33
 
34
34
  end
@@ -0,0 +1,113 @@
1
+ require 'time'
2
+ require 'net/http'
3
+
4
+ module Aws
5
+ class InstanceProfileCredentials < Credentials
6
+
7
+ # @api private
8
+ class Non200Response < RuntimeError; end
9
+
10
+ # These are the errors we trap when attempting to talk to the
11
+ # instance metadata service. Any of these imply the service
12
+ # is not present, no responding or some other non-recoverable
13
+ # error.
14
+ # @api private
15
+ FAILURES = [
16
+ Errno::EHOSTUNREACH,
17
+ Errno::ECONNREFUSED,
18
+ SocketError,
19
+ Timeout::Error,
20
+ Non200Response,
21
+ ]
22
+
23
+ # @param [Hash] options
24
+ # @option options [String] :ip_address ('169.254.169.254')
25
+ # @option options [Integer] :port (80)
26
+ # @option options [Float] :http_open_timeout (1)
27
+ # @option options [Float] :http_read_timeout (1)
28
+ # @option options [IO] :http_debug_output (nil) HTTP wire
29
+ # traces are sent to this object. You can specify something
30
+ # like $stdout.
31
+ def initialize options = {}
32
+ @ip_address = options[:ip_address] || '169.254.169.254'
33
+ @port = options[:port] || 80
34
+ @http_open_timeout = options[:http_open_timeout] || 1
35
+ @http_read_timeout = options[:http_read_timeout] || 1
36
+ @http_debug_output = options[:http_debug_output]
37
+ refresh!
38
+ end
39
+
40
+ # @return [String,nil]
41
+ def access_key_id
42
+ refresh_if_stale
43
+ @access_key_id
44
+ end
45
+
46
+ # @return [String,nil]
47
+ def secret_access_key
48
+ refresh_if_stale
49
+ @secret_access_key
50
+ end
51
+
52
+ # @return [String,nil]
53
+ def session_token
54
+ refresh_if_stale
55
+ @session_token
56
+ end
57
+
58
+ # @return [Time,nil]
59
+ def expiration
60
+ refresh_if_stale
61
+ @expiration
62
+ end
63
+
64
+ def refresh!
65
+ credentials = MultiJson.load(get_credentials)
66
+ @access_key_id = credentials['AccessKeyId']
67
+ @secret_access_key = credentials['SecretAccessKey']
68
+ @session_token = credentials['Token']
69
+ if expires = credentials['Expiration']
70
+ @expiration = Time.parse(expires)
71
+ else
72
+ @expiration = nil
73
+ end
74
+ end
75
+
76
+ private
77
+
78
+ # Refreshes instance metadata credentials if they are within
79
+ # 5 minutes of expiration.
80
+ def refresh_if_stale
81
+ refresh! if @expiration && @expiration.utc <= Time.now.utc + 5 * 60
82
+ end
83
+
84
+ def get_credentials
85
+ open_connection do |conn|
86
+ path = '/latest/meta-data/iam/security-credentials/'
87
+ profile_name = http_get(conn, path).lines.first.strip
88
+ http_get(conn, path + profile_name)
89
+ end
90
+ rescue *FAILURES => e
91
+ '{}'
92
+ end
93
+
94
+ def open_connection
95
+ http = Net::HTTP.new(@ip_address, @port)
96
+ http.open_timeout = @http_open_timeout
97
+ http.read_timeout = @http_read_timeout
98
+ http.set_debug_output(@http_debug_output) if @http_debug_output
99
+ http.start
100
+ yield(http).tap { http.finish }
101
+ end
102
+
103
+ def http_get(connection, path)
104
+ response = connection.request(Net::HTTP::Get.new(path))
105
+ if response.code.to_i == 200
106
+ response.body
107
+ else
108
+ raise Non200Response
109
+ end
110
+ end
111
+
112
+ end
113
+ end