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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +6 -3
- data/Rakefile +2 -0
- data/apis/AutoScaling-2011-01-01.json +1 -0
- data/apis/CloudFormation-2010-05-15.json +75 -0
- data/apis/CloudFront-2012-05-05.json +1 -0
- data/apis/CloudFront-2013-05-12.json +1 -0
- data/apis/CloudFront-2013-08-26.json +1 -0
- data/apis/CloudSearch-2011-02-01.json +1 -0
- data/apis/CloudWatch-2010-08-01.json +1 -0
- data/apis/DataPipeline-2012-10-29.json +1 -0
- data/apis/DirectConnect-2012-10-25.json +1 -0
- data/apis/DynamoDB-2011-12-05.json +1 -0
- data/apis/DynamoDB-2012-08-10.json +1 -0
- data/apis/EC2-2013-06-15.json +1 -0
- data/apis/EC2-2013-10-01.json +1 -0
- data/apis/EMR-2009-03-31.json +1 -0
- data/apis/ElastiCache-2012-11-15.json +1 -0
- data/apis/ElastiCache-2013-06-15.json +1 -0
- data/apis/ElasticBeanstalk-2010-12-01.json +1 -0
- data/apis/ElasticLoadBalancing-2012-06-01.json +73 -0
- data/apis/ElasticTranscoder-2012-09-25.json +231 -0
- data/apis/Glacier-2012-06-01.json +2 -0
- data/apis/IAM-2010-05-08.json +1 -0
- data/apis/ImportExport-2010-06-01.json +1 -0
- data/apis/OpsWorks-2013-02-18.json +1 -0
- data/apis/RDS-2013-01-10.json +1 -0
- data/apis/RDS-2013-02-12.json +1 -0
- data/apis/RDS-2013-05-15.json +1 -0
- data/apis/Redshift-2012-12-01.json +1 -0
- data/apis/Route53-2012-12-12.json +1 -0
- data/apis/S3-2006-03-01.json +5 -0
- data/apis/SDB-2009-04-15.json +1 -0
- data/apis/SES-2010-12-01.json +1 -0
- data/apis/SNS-2010-03-31.json +1 -0
- data/apis/SQS-2012-11-05.json +1 -0
- data/apis/STS-2011-06-15.json +1 -0
- data/apis/SWF-2012-01-25.json +1 -0
- data/apis/StorageGateway-2012-06-30.json +1 -0
- data/apis/StorageGateway-2013-06-30.json +2018 -0
- data/apis/Support-2013-04-15.json +1 -0
- data/apis/source/cloudformation-2010-05-15.json +118 -12
- data/apis/source/elasticloadbalancing-2012-06-01.json +347 -220
- data/apis/source/elastictranscoder-2012-09-25.json +315 -5
- data/apis/source/s3-2006-03-01.json +3 -0
- data/apis/source/storagegateway-2013-06-30.json +12560 -0
- data/apis/source/storagegateway-2013-06-30.paginators.json +28 -0
- data/doc-src/plugins/apis.rb +44 -1
- data/doc-src/templates/default/fulldoc/html/setup.rb +1 -1
- data/features/common/step_definitions.rb +3 -5
- data/features/env.rb +2 -0
- data/features/glacier/client.feature +8 -0
- data/features/glacier/step_definitions.rb +7 -7
- data/features/s3/step_definitions.rb +2 -3
- data/lib/aws.rb +75 -69
- data/lib/aws/api/service_translators/glacier.rb +1 -0
- data/lib/aws/api/translator.rb +13 -8
- data/lib/aws/credentials.rb +5 -5
- data/lib/aws/instance_profile_credentials.rb +113 -0
- data/lib/aws/plugins/credentials.rb +2 -1
- data/lib/aws/plugins/glacier_account_id.rb +11 -0
- data/lib/aws/plugins/glacier_checksums.rb +7 -3
- data/lib/aws/plugins/instance_profile_credentials.rb +14 -0
- data/lib/aws/plugins/s3_bucket_dns.rb +17 -14
- data/lib/aws/plugins/s3_md5s.rb +3 -3
- data/lib/aws/service.rb +10 -9
- data/lib/aws/signers/s3.rb +2 -2
- data/lib/aws/signers/v2.rb +1 -1
- data/lib/aws/signers/v4.rb +2 -2
- data/lib/aws/version.rb +1 -1
- data/lib/aws/xml/serializer.rb +1 -1
- data/spec/aws/instance_profile_credentials_spec.rb +94 -0
- data/spec/aws/operations_spec.rb +1 -1
- data/spec/aws/plugins/credentials_spec.rb +2 -2
- data/spec/fixtures/operations/glacier/account_id_param.yml +13 -0
- data/spec/fixtures/operations/glacier/custom_account_id.yml +11 -0
- data/spec/fixtures/operations/glacier/default_account_id.yml +10 -0
- data/spec/fixtures/operations/s3/content_type_header.yml +12 -0
- data/spec/fixtures/operations/s3/md5_checksum_disabled.yml +1 -1
- data/tasks/apis.rake +2 -2
- data/tasks/docs.rake +2 -1
- data/tasks/handlers.rake +30 -0
- data/vendor/seahorse/lib/seahorse/client.rb +1 -0
- data/vendor/seahorse/lib/seahorse/client/base.rb +0 -18
- data/vendor/seahorse/lib/seahorse/client/block_io.rb +0 -7
- data/vendor/seahorse/lib/seahorse/client/configuration.rb +57 -37
- data/vendor/seahorse/lib/seahorse/client/handler_list.rb +115 -78
- data/vendor/seahorse/lib/seahorse/client/http/endpoint.rb +19 -15
- data/vendor/seahorse/lib/seahorse/client/http/request.rb +0 -15
- data/vendor/seahorse/lib/seahorse/client/logging/formatter.rb +0 -7
- data/vendor/seahorse/lib/seahorse/client/managed_file.rb +14 -0
- data/vendor/seahorse/lib/seahorse/client/net_http/handler.rb +1 -3
- data/vendor/seahorse/lib/seahorse/client/plugins/content_length.rb +1 -1
- data/vendor/seahorse/lib/seahorse/client/plugins/endpoint.rb +81 -10
- data/vendor/seahorse/lib/seahorse/client/plugins/restful_bindings.rb +1 -71
- data/vendor/seahorse/lib/seahorse/client/request.rb +26 -3
- data/vendor/seahorse/spec/seahorse/client/base_spec.rb +1 -5
- data/vendor/seahorse/spec/seahorse/client/configuration_spec.rb +1 -10
- data/vendor/seahorse/spec/seahorse/client/handler_list_spec.rb +10 -10
- data/vendor/seahorse/spec/seahorse/client/http/endpoint_spec.rb +46 -14
- data/vendor/seahorse/spec/seahorse/client/http/request_spec.rb +1 -42
- data/vendor/seahorse/spec/seahorse/client/logging/formatter_spec.rb +1 -6
- data/vendor/seahorse/spec/seahorse/client/logging/handler_spec.rb +1 -1
- data/vendor/seahorse/spec/seahorse/client/net_http/handler_spec.rb +5 -4
- data/vendor/seahorse/spec/seahorse/client/param_converter_spec.rb +1 -0
- data/vendor/seahorse/spec/seahorse/client/plugins/{restful_bindings/uri_path_builder_spec.rb → endpoint/request_uri_builder_spec.rb} +3 -3
- data/vendor/seahorse/spec/seahorse/client/plugins/endpoint_spec.rb +1 -11
- data/vendor/seahorse/spec/seahorse/client/request_spec.rb +63 -13
- 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
|
+
}
|
data/doc-src/plugins/apis.rb
CHANGED
@@ -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 =
|
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 << " < Service"
|
@@ -1,10 +1,8 @@
|
|
1
1
|
def call_request(service, operation_name, params = {})
|
2
2
|
service = instance_variable_get("@#{service}")
|
3
|
-
|
4
|
-
|
5
|
-
|
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)
|
data/features/env.rb
CHANGED
@@ -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
|
-
|
2
|
+
resp = call_request('glacier', 'upload_archive', {
|
3
3
|
vault_name: @vault_name,
|
4
|
-
|
5
|
-
|
6
|
-
@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
|
-
|
21
|
+
call_request('glacier', 'delete_archive', {
|
22
22
|
vault_name: @vault_name,
|
23
|
-
|
24
|
-
|
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
|
-
|
44
|
-
|
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,
|
9
|
-
autoload :Errors,
|
10
|
-
autoload :ErrorHandler,
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
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,
|
22
|
-
autoload :Documentor,
|
23
|
-
autoload :DocExample,
|
24
|
-
autoload :InputShapeTranslator,
|
25
|
-
autoload :OperationTranslator,
|
26
|
-
autoload :OutputShapeTranslator,
|
27
|
-
autoload :ServiceNamer,
|
28
|
-
autoload :ShapeTranslator,
|
29
|
-
autoload :Translator,
|
30
|
-
autoload :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,
|
34
|
-
autoload :DynamoDB,
|
35
|
-
autoload :Glacier,
|
36
|
-
autoload :ImportExport,
|
37
|
-
autoload :Route53,
|
38
|
-
autoload :S3,
|
39
|
-
autoload :SQS,
|
40
|
-
autoload :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,
|
48
|
-
autoload :ErrorParser,
|
49
|
-
autoload :Parser,
|
50
|
-
autoload :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,
|
55
|
-
autoload :DynamoDBExtendedRetries,
|
56
|
-
autoload :
|
57
|
-
autoload :
|
58
|
-
autoload :
|
59
|
-
autoload :
|
60
|
-
autoload :
|
61
|
-
autoload :
|
62
|
-
autoload :
|
63
|
-
autoload :
|
64
|
-
autoload :
|
65
|
-
autoload :
|
66
|
-
autoload :
|
67
|
-
autoload :
|
68
|
-
autoload :
|
69
|
-
autoload :
|
70
|
-
autoload :
|
71
|
-
autoload :
|
72
|
-
autoload :
|
73
|
-
autoload :
|
74
|
-
autoload :
|
75
|
-
autoload :
|
76
|
-
autoload :
|
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,
|
82
|
-
autoload :Param,
|
83
|
-
autoload :ParamList,
|
84
|
-
autoload :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,
|
90
|
-
autoload :Handler,
|
91
|
-
autoload :S3,
|
92
|
-
autoload :V2,
|
93
|
-
autoload :V3,
|
94
|
-
autoload :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,
|
100
|
-
autoload :ErrorParser,
|
101
|
-
autoload :Parser,
|
102
|
-
autoload :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
|
data/lib/aws/api/translator.rb
CHANGED
@@ -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
|
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 [
|
data/lib/aws/credentials.rb
CHANGED
@@ -11,24 +11,24 @@ module Aws
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# @return [String, nil]
|
14
|
-
|
14
|
+
attr_reader :access_key_id
|
15
15
|
|
16
16
|
# @return [String, nil]
|
17
|
-
|
17
|
+
attr_reader :secret_access_key
|
18
18
|
|
19
19
|
# @return [String, nil]
|
20
|
-
|
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
|
-
!!(
|
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
|