aws-sdk-core 2.0.48 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/apis/autoscaling/2011-01-01/api-2.json +636 -33
- data/apis/cloudhsm/2014-05-30/api-2.json +3 -6
- data/apis/ec2/2014-10-01/api-2.json +10267 -0
- data/apis/ec2/2014-10-01/paginators-1.json +125 -0
- data/apis/ec2/2014-10-01/resources-1.json +2289 -0
- data/apis/ec2/2014-10-01/waiters-2.json +453 -0
- data/apis/ec2/2015-03-01/api-2.json +11245 -0
- data/apis/ec2/2015-03-01/paginators-1.json +125 -0
- data/apis/ec2/2015-03-01/resources-1.json +2479 -0
- data/apis/ec2/2015-03-01/waiters-2.json +458 -0
- data/apis/ec2/2015-04-15/api-2.json +182 -2
- data/apis/ecs/2014-11-13/api-2.json +316 -7
- data/apis/ecs/2014-11-13/paginators-1.json +40 -0
- data/apis/ecs/2014-11-13/waiters-2.json +93 -0
- data/apis/redshift/2012-12-01/waiters-2.json +19 -0
- data/apis/s3/2006-03-01/api-2.json +1 -2
- data/apis/sqs/2012-11-05/api-2.json +5 -6
- data/ca-bundle.crt +3554 -0
- data/lib/aws-sdk-core.rb +127 -44
- data/lib/aws-sdk-core/api/builder.rb +95 -0
- data/lib/aws-sdk-core/api/customizations.rb +152 -0
- data/lib/aws-sdk-core/api/docs/builder.rb +220 -0
- data/lib/aws-sdk-core/api/docs/client_type_documenter.rb +109 -0
- data/lib/aws-sdk-core/api/docs/docstring_provider.rb +66 -0
- data/lib/aws-sdk-core/api/docs/operation_documenter.rb +107 -0
- data/lib/aws-sdk-core/api/docs/param_formatter.rb +163 -0
- data/lib/aws-sdk-core/api/docs/request_syntax_example.rb +22 -0
- data/lib/aws-sdk-core/api/docs/response_structure_example.rb +91 -0
- data/lib/aws-sdk-core/api/docs/utils.rb +133 -0
- data/lib/aws-sdk-core/api/shape_map.rb +140 -0
- data/lib/aws-sdk-core/assume_role_credentials.rb +9 -6
- data/lib/aws-sdk-core/client.rb +9 -6
- data/lib/aws-sdk-core/client_stubs.rb +127 -133
- data/lib/aws-sdk-core/client_waiters.rb +1 -1
- data/lib/aws-sdk-core/credential_provider.rb +44 -0
- data/lib/aws-sdk-core/credential_provider_chain.rb +3 -2
- data/lib/aws-sdk-core/credentials.rb +5 -0
- data/lib/aws-sdk-core/deprecations.rb +69 -0
- data/lib/aws-sdk-core/dynamodb.rb +12 -0
- data/lib/aws-sdk-core/eager_loader.rb +31 -0
- data/lib/aws-sdk-core/ecs.rb +2 -0
- data/lib/aws-sdk-core/empty_structure.rb +1 -82
- data/lib/aws-sdk-core/endpoint_provider.rb +1 -1
- data/lib/aws-sdk-core/instance_profile_credentials.rb +9 -10
- data/lib/aws-sdk-core/json.rb +56 -0
- data/lib/aws-sdk-core/json/builder.rb +33 -34
- data/lib/aws-sdk-core/json/error_handler.rb +2 -2
- data/lib/aws-sdk-core/json/handler.rb +67 -0
- data/lib/aws-sdk-core/json/json_engine.rb +15 -0
- data/lib/aws-sdk-core/json/oj_engine.rb +15 -0
- data/lib/aws-sdk-core/json/parser.rb +30 -38
- data/lib/aws-sdk-core/pageable_response.rb +9 -12
- data/lib/aws-sdk-core/pager.rb +69 -0
- data/lib/aws-sdk-core/param_converter.rb +203 -0
- data/lib/aws-sdk-core/param_validator.rb +148 -0
- data/lib/aws-sdk-core/plugins/dynamodb_simple_attributes.rb +21 -18
- data/lib/aws-sdk-core/plugins/glacier_account_id.rb +9 -1
- data/lib/aws-sdk-core/plugins/glacier_checksums.rb +2 -3
- data/lib/aws-sdk-core/plugins/param_converter.rb +27 -0
- data/lib/aws-sdk-core/plugins/param_validator.rb +28 -0
- data/lib/aws-sdk-core/plugins/protocols/json_rpc.rb +3 -7
- data/lib/aws-sdk-core/plugins/protocols/rest_json.rb +1 -2
- data/lib/aws-sdk-core/plugins/protocols/rest_xml.rb +1 -1
- data/lib/aws-sdk-core/plugins/regional_endpoint.rb +1 -1
- data/lib/aws-sdk-core/plugins/request_signer.rb +5 -5
- data/lib/aws-sdk-core/plugins/response_paging.rb +20 -11
- data/lib/aws-sdk-core/plugins/s3_get_bucket_location_fix.rb +1 -1
- data/lib/aws-sdk-core/plugins/s3_request_signer.rb +1 -2
- data/lib/aws-sdk-core/plugins/stub_responses.rb +25 -27
- data/lib/aws-sdk-core/query/ec2_param_builder.rb +29 -34
- data/lib/aws-sdk-core/query/handler.rb +32 -18
- data/lib/aws-sdk-core/query/param_builder.rb +45 -53
- data/lib/aws-sdk-core/refreshing_credentials.rb +3 -15
- data/lib/aws-sdk-core/rest/handler.rb +22 -0
- data/lib/aws-sdk-core/rest/request/body.rb +58 -0
- data/lib/aws-sdk-core/rest/request/builder.rb +50 -0
- data/lib/aws-sdk-core/rest/request/endpoint.rb +70 -0
- data/lib/aws-sdk-core/rest/request/headers.rb +48 -0
- data/lib/aws-sdk-core/rest/response/body.rb +43 -0
- data/lib/aws-sdk-core/rest/response/headers.rb +60 -0
- data/lib/aws-sdk-core/rest/response/parser.rb +47 -0
- data/lib/aws-sdk-core/rest/response/status_code.rb +24 -0
- data/lib/aws-sdk-core/shared_credentials.rb +11 -6
- data/lib/aws-sdk-core/signers/base.rb +1 -1
- data/lib/aws-sdk-core/signers/s3.rb +2 -3
- data/lib/aws-sdk-core/signers/v2.rb +7 -4
- data/lib/aws-sdk-core/signers/v4.rb +11 -22
- data/lib/aws-sdk-core/structure.rb +26 -145
- data/lib/aws-sdk-core/stubbing/data_applicator.rb +46 -0
- data/lib/aws-sdk-core/stubbing/empty_stub.rb +53 -0
- data/lib/aws-sdk-core/stubbing/protocols/ec2.rb +49 -0
- data/lib/aws-sdk-core/stubbing/protocols/json.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/query.rb +40 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest.rb +67 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_json.rb +25 -0
- data/lib/aws-sdk-core/stubbing/protocols/rest_xml.rb +38 -0
- data/lib/aws-sdk-core/stubbing/stub_data.rb +34 -0
- data/lib/aws-sdk-core/version.rb +1 -1
- data/lib/aws-sdk-core/xml/builder.rb +58 -52
- data/lib/aws-sdk-core/xml/default_map.rb +10 -0
- data/lib/aws-sdk-core/xml/doc_builder.rb +86 -0
- data/lib/aws-sdk-core/xml/error_handler.rb +7 -2
- data/lib/aws-sdk-core/xml/parser.rb +4 -4
- data/lib/aws-sdk-core/xml/parser/frame.rb +75 -70
- data/lib/aws-sdk-core/xml/parser/stack.rb +4 -4
- data/lib/seahorse.rb +0 -11
- data/lib/seahorse/client/base.rb +3 -12
- data/lib/seahorse/client/http/request.rb +9 -5
- data/lib/seahorse/client/plugins/endpoint.rb +5 -56
- data/lib/seahorse/client/plugins/restful_bindings.rb +38 -31
- data/lib/seahorse/client/request_context.rb +2 -2
- data/lib/seahorse/client/response.rb +6 -5
- data/lib/seahorse/model/api.rb +18 -61
- data/lib/seahorse/model/operation.rb +24 -54
- data/lib/seahorse/model/shapes.rb +120 -364
- data/lib/seahorse/util.rb +2 -6
- metadata +56 -109
- data/apis/autoscaling/2011-01-01/docs-2.json +0 -1246
- data/apis/cloudformation/2010-05-15/docs-2.json +0 -725
- data/apis/cloudfront/2014-11-06/docs-2.json +0 -1125
- data/apis/cloudhsm/2014-05-30/docs-2.json +0 -472
- data/apis/cloudsearch/2013-01-01/docs-2.json +0 -865
- data/apis/cloudsearchdomain/2013-01-01/docs-2.json +0 -311
- data/apis/cloudtrail/2013-11-01/docs-2.json +0 -328
- data/apis/codedeploy/2014-10-06/docs-2.json +0 -1261
- data/apis/cognito-identity/2014-06-30/docs-2.json +0 -506
- data/apis/cognito-sync/2014-06-30/docs-2.json +0 -582
- data/apis/config/2014-10-17/docs-2.json +0 -513
- data/apis/config/2014-11-12/docs-2.json +0 -514
- data/apis/datapipeline/2012-10-29/docs-2.json +0 -607
- data/apis/directconnect/2012-10-25/docs-2.json +0 -494
- data/apis/ds/2015-04-16/docs-2.json +0 -753
- data/apis/dynamodb/2011-12-05/api-2.json +0 -949
- data/apis/dynamodb/2011-12-05/docs-2.json +0 -606
- data/apis/dynamodb/2011-12-05/paginators-1.json +0 -26
- data/apis/dynamodb/2011-12-05/waiters-2.json +0 -35
- data/apis/dynamodb/2012-08-10/docs-2.json +0 -977
- data/apis/ec2/2015-04-15/docs-2.json +0 -5368
- data/apis/ecs/2014-11-13/docs-2.json +0 -791
- data/apis/elasticache/2015-02-02/docs-2.json +0 -1390
- data/apis/elasticbeanstalk/2010-12-01/docs-2.json +0 -1114
- data/apis/elasticfilesystem/2015-02-01/docs-2.json +0 -414
- data/apis/elasticloadbalancing/2012-06-01/docs-2.json +0 -1078
- data/apis/elasticmapreduce/2009-03-31/docs-2.json +0 -969
- data/apis/elastictranscoder/2012-09-25/docs-2.json +0 -1152
- data/apis/email/2010-12-01/docs-2.json +0 -441
- data/apis/glacier/2012-06-01/docs-2.json +0 -575
- data/apis/iam/2010-05-08/docs-2.json +0 -2138
- data/apis/importexport/2010-06-01/docs-2.json +0 -432
- data/apis/kinesis/2013-12-02/docs-2.json +0 -424
- data/apis/kms/2014-11-01/docs-2.json +0 -628
- data/apis/lambda/2014-11-11/docs-2.json +0 -303
- data/apis/lambda/2015-03-31/docs-2.json +0 -490
- data/apis/logs/2014-03-28/docs-2.json +0 -599
- data/apis/machinelearning/2014-12-12/docs-2.json +0 -1034
- data/apis/monitoring/2010-08-01/docs-2.json +0 -514
- data/apis/opsworks/2013-02-18/docs-2.json +0 -1592
- data/apis/rds/2014-10-31/docs-2.json +0 -2074
- data/apis/redshift/2012-12-01/docs-2.json +0 -1890
- data/apis/route53/2013-04-01/docs-2.json +0 -1159
- data/apis/route53domains/2014-05-15/docs-2.json +0 -620
- data/apis/s3/2006-03-01/docs-2.json +0 -2213
- data/apis/sdb/2009-04-15/docs-2.json +0 -339
- data/apis/sns/2010-03-31/docs-2.json +0 -564
- data/apis/sqs/2012-11-05/docs-2.json +0 -503
- data/apis/ssm/2014-11-06/docs-2.json +0 -440
- data/apis/storagegateway/2013-06-30/docs-2.json +0 -1331
- data/apis/sts/2011-06-15/docs-2.json +0 -351
- data/apis/support/2013-04-15/docs-2.json +0 -680
- data/apis/swf/2012-01-25/docs-2.json +0 -1569
- data/apis/workspaces/2015-04-08/docs-2.json +0 -457
- data/lib/aws-sdk-core/api/customizer.rb +0 -75
- data/lib/aws-sdk-core/api/docstrings.rb +0 -38
- data/lib/aws-sdk-core/api/documenter.rb +0 -241
- data/lib/aws-sdk-core/api/operation_documenter.rb +0 -173
- data/lib/aws-sdk-core/api/operation_example.rb +0 -133
- data/lib/aws-sdk-core/api/service_customizations.rb +0 -140
- data/lib/aws-sdk-core/client_paging.rb +0 -31
- data/lib/aws-sdk-core/json/rest_handler.rb +0 -20
- data/lib/aws-sdk-core/json/rpc_body_handler.rb +0 -38
- data/lib/aws-sdk-core/json/rpc_headers_handler.rb +0 -34
- data/lib/aws-sdk-core/json/simple_body_handler.rb +0 -34
- data/lib/aws-sdk-core/paging/null_pager.rb +0 -20
- data/lib/aws-sdk-core/paging/null_provider.rb +0 -13
- data/lib/aws-sdk-core/paging/pager.rb +0 -70
- data/lib/aws-sdk-core/paging/provider.rb +0 -22
- data/lib/aws-sdk-core/rest_body_handler.rb +0 -111
- data/lib/aws-sdk-core/signers/handler.rb +0 -18
- data/lib/aws-sdk-core/xml/rest_handler.rb +0 -20
- data/lib/seahorse/client/param_converter.rb +0 -207
- data/lib/seahorse/client/param_validator.rb +0 -139
- data/lib/seahorse/client/plugins/json_simple.rb +0 -33
- data/lib/seahorse/client/plugins/param_conversion.rb +0 -29
- data/lib/seahorse/client/plugins/param_validation.rb +0 -30
- data/lib/seahorse/client/xml/builder.rb +0 -91
- data/lib/seahorse/model/shape_map.rb +0 -47
@@ -3,11 +3,14 @@ require 'cgi'
|
|
3
3
|
module Seahorse
|
4
4
|
module Client
|
5
5
|
module Plugins
|
6
|
+
# @api private
|
6
7
|
class RestfulBindings < Plugin
|
7
8
|
|
8
9
|
# @api private
|
9
10
|
class Handler < Client::Handler
|
10
11
|
|
12
|
+
include Seahorse::Model::Shapes
|
13
|
+
|
11
14
|
def call(context)
|
12
15
|
build_request(context)
|
13
16
|
@handler.call(context).on(200..299) do |response|
|
@@ -30,31 +33,31 @@ module Seahorse
|
|
30
33
|
def populate_http_headers(context)
|
31
34
|
params = context.params
|
32
35
|
headers = context.http_request.headers
|
33
|
-
each_member(context.operation.input) do |member_name,
|
36
|
+
each_member(context.operation.input) do |member_name, member_ref|
|
34
37
|
value = params[member_name]
|
35
38
|
next if value.nil?
|
36
|
-
case
|
37
|
-
when 'header' then serialize_header(headers,
|
38
|
-
when 'headers' then serialize_header_map(headers,
|
39
|
+
case member_ref.location
|
40
|
+
when 'header' then serialize_header(headers, member_ref, value)
|
41
|
+
when 'headers' then serialize_header_map(headers, member_ref, value)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
43
|
-
def serialize_header(headers,
|
44
|
-
headers[
|
46
|
+
def serialize_header(headers, ref, value)
|
47
|
+
headers[ref.location_name] = serialize_header_value(ref, value)
|
45
48
|
end
|
46
49
|
|
47
|
-
def serialize_header_map(headers,
|
48
|
-
prefix =
|
50
|
+
def serialize_header_map(headers, ref, values)
|
51
|
+
prefix = ref.location_name || ''
|
49
52
|
values.each_pair do |name, value|
|
50
|
-
value = serialize_header_value(shape.value, value)
|
53
|
+
value = serialize_header_value(ref.shape.value, value)
|
51
54
|
headers["#{prefix}#{name}"] = value
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
|
-
def serialize_header_value(
|
56
|
-
if shape
|
57
|
-
|
58
|
+
def serialize_header_value(ref, value)
|
59
|
+
if TimestampShape === ref.shape
|
60
|
+
value.utc.httpdate
|
58
61
|
else
|
59
62
|
value.to_s
|
60
63
|
end
|
@@ -63,51 +66,55 @@ module Seahorse
|
|
63
66
|
# Extracts HTTP response headers and status code.
|
64
67
|
def parse_response(response)
|
65
68
|
headers = response.context.http_response.headers
|
66
|
-
each_member(response.context.operation.output) do |key,
|
67
|
-
case
|
69
|
+
each_member(response.context.operation.output) do |key, ref|
|
70
|
+
case ref.location
|
68
71
|
when 'statusCode'
|
69
72
|
status_code = response.context.http_response.status_code
|
70
73
|
response.data[key] = status_code
|
71
74
|
when 'header'
|
72
|
-
if headers.key?(
|
73
|
-
response.data[key] = extract_header(headers,
|
75
|
+
if headers.key?(ref.location_name)
|
76
|
+
response.data[key] = extract_header(headers, ref)
|
74
77
|
end
|
75
78
|
when 'headers'
|
76
|
-
response.data[key] = extract_header_map(headers,
|
79
|
+
response.data[key] = extract_header_map(headers, ref)
|
77
80
|
end
|
78
81
|
end
|
79
82
|
end
|
80
83
|
|
81
|
-
def extract_header(headers,
|
82
|
-
parse_header_value(
|
84
|
+
def extract_header(headers, ref)
|
85
|
+
parse_header_value(ref, headers[ref.location_name])
|
83
86
|
end
|
84
87
|
|
85
|
-
def extract_header_map(headers,
|
86
|
-
prefix =
|
88
|
+
def extract_header_map(headers, ref)
|
89
|
+
prefix = ref.location_name || ''
|
87
90
|
hash = {}
|
88
91
|
headers.each do |header, value|
|
89
92
|
if match = header.match(/^#{prefix}(.+)/i)
|
90
|
-
hash[match[1]] = parse_header_value(shape.value, value)
|
93
|
+
hash[match[1]] = parse_header_value(ref.shape.value, value)
|
91
94
|
end
|
92
95
|
end
|
93
96
|
hash
|
94
97
|
end
|
95
98
|
|
96
|
-
def parse_header_value(
|
99
|
+
def parse_header_value(ref, value)
|
97
100
|
if value
|
98
|
-
case shape
|
99
|
-
when
|
100
|
-
when
|
101
|
-
when
|
102
|
-
when
|
103
|
-
|
101
|
+
case ref.shape
|
102
|
+
when IntegerShape then value.to_i
|
103
|
+
when FloatShape then value.to_f
|
104
|
+
when BooleanShape then value == 'true'
|
105
|
+
when TimestampShape
|
106
|
+
if value =~ /\d+(\.\d*)/
|
107
|
+
Time.at(value.to_f)
|
108
|
+
else
|
109
|
+
Time.parse(value)
|
110
|
+
end
|
104
111
|
else value
|
105
112
|
end
|
106
113
|
end
|
107
114
|
end
|
108
115
|
|
109
|
-
def each_member(
|
110
|
-
shape.members.each(&block) if
|
116
|
+
def each_member(ref, &block)
|
117
|
+
ref.shape.members.each(&block) if ref
|
111
118
|
end
|
112
119
|
|
113
120
|
end
|
@@ -4,7 +4,7 @@ module Seahorse
|
|
4
4
|
module Client
|
5
5
|
class RequestContext
|
6
6
|
|
7
|
-
# @option options [required,
|
7
|
+
# @option options [required,Symbol] :operation_name (nil)
|
8
8
|
# @option options [required,Model::Operation] :operation (nil)
|
9
9
|
# @option options [Hash] :params ({})
|
10
10
|
# @option options [Configuration] :config (nil)
|
@@ -23,7 +23,7 @@ module Seahorse
|
|
23
23
|
@metadata = {}
|
24
24
|
end
|
25
25
|
|
26
|
-
# @return [
|
26
|
+
# @return [Symbol] Name of the API operation called.
|
27
27
|
attr_accessor :operation_name
|
28
28
|
|
29
29
|
# @return [Model::Operation]
|
@@ -59,11 +59,12 @@ module Seahorse
|
|
59
59
|
|
60
60
|
# @api private
|
61
61
|
def inspect
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
@data.inspect
|
63
|
+
end
|
64
|
+
|
65
|
+
# @api private
|
66
|
+
def pretty_print(q)
|
67
|
+
@data.pretty_print(q)
|
67
68
|
end
|
68
69
|
|
69
70
|
# @api private
|
data/lib/seahorse/model/api.rb
CHANGED
@@ -2,82 +2,39 @@ module Seahorse
|
|
2
2
|
module Model
|
3
3
|
class Api
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
@
|
8
|
-
@version = metadata('apiVersion')
|
9
|
-
@documentation = definition['documentation']
|
10
|
-
@definition = definition
|
11
|
-
@shape_map = ShapeMap.new(definition['shapes'] || {})
|
12
|
-
compute_operations
|
5
|
+
def initialize
|
6
|
+
@metadata = {}
|
7
|
+
@operations = {}
|
13
8
|
end
|
14
9
|
|
15
10
|
# @return [String, nil]
|
16
|
-
|
17
|
-
|
18
|
-
# @return [Array<Symbol>]
|
19
|
-
attr_reader :operation_names
|
20
|
-
|
21
|
-
# @return [String, nil]
|
22
|
-
attr_reader :documentation
|
23
|
-
|
24
|
-
# @return [ShapeMap]
|
25
|
-
attr_reader :shape_map
|
11
|
+
attr_accessor :version
|
26
12
|
|
27
13
|
# @return [Hash]
|
28
|
-
|
14
|
+
attr_accessor :metadata
|
29
15
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
16
|
+
def operations(&block)
|
17
|
+
if block_given?
|
18
|
+
@operations.each(&block)
|
19
|
+
else
|
20
|
+
@operations.enum_for(:each)
|
21
|
+
end
|
35
22
|
end
|
36
23
|
|
37
|
-
# @param [Symbol] name
|
38
|
-
# @return [Operation]
|
39
24
|
def operation(name)
|
40
|
-
|
41
|
-
|
42
|
-
@operations[name] ||= Operation.new(definition, shape_map: @shape_map)
|
25
|
+
if @operations.key?(name.to_sym)
|
26
|
+
@operations[name.to_sym]
|
43
27
|
else
|
44
|
-
raise ArgumentError, "unknown operation
|
28
|
+
raise ArgumentError, "unknown operation #{name.inspect}"
|
45
29
|
end
|
46
30
|
end
|
47
31
|
|
48
|
-
|
49
|
-
|
50
|
-
enum_for(:each_operation) { |*args| operation_names.size }
|
51
|
-
end
|
52
|
-
|
53
|
-
# @param [String] key
|
54
|
-
# @return [Object, nil]
|
55
|
-
def metadata(key)
|
56
|
-
@metadata[key]
|
32
|
+
def operation_names
|
33
|
+
@operations.keys
|
57
34
|
end
|
58
35
|
|
59
|
-
|
60
|
-
|
61
|
-
def inspect
|
62
|
-
"#<#{self.class.name} version=#{version.inspect}>"
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def each_operation(&block)
|
68
|
-
operation_names.each do |name|
|
69
|
-
yield(name, operation(name))
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def compute_operations
|
74
|
-
@operations = {}
|
75
|
-
@operation_defs = {}
|
76
|
-
(definition['operations'] || {}).each do |name,definition|
|
77
|
-
name = Util.underscore(name).to_sym
|
78
|
-
@operation_defs[name] = definition
|
79
|
-
end
|
80
|
-
@operation_names = @operation_defs.keys
|
36
|
+
def add_operation(name, operation)
|
37
|
+
@operations[name.to_sym] = operation
|
81
38
|
end
|
82
39
|
|
83
40
|
end
|
@@ -2,74 +2,44 @@ module Seahorse
|
|
2
2
|
module Model
|
3
3
|
class Operation
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
11
|
-
@input = shape_for(definition['input']) if definition['input']
|
12
|
-
@output = shape_for(definition['output']) if definition['output']
|
13
|
-
@deprecated = !!definition['deprecated']
|
14
|
-
@documentation = definition['documentation']
|
15
|
-
@paging = definition['paging'] || {}
|
5
|
+
def initialize
|
6
|
+
@http_method = 'POST'
|
7
|
+
@http_request_uri = '/'
|
8
|
+
@deprecated = false
|
9
|
+
@errors = []
|
10
|
+
@metadata = {}
|
16
11
|
end
|
17
12
|
|
18
|
-
# @return [String]
|
19
|
-
|
13
|
+
# @return [String, nil]
|
14
|
+
attr_accessor :name
|
20
15
|
|
21
16
|
# @return [String]
|
22
|
-
|
17
|
+
attr_accessor :http_method
|
23
18
|
|
24
19
|
# @return [String]
|
25
|
-
|
26
|
-
|
27
|
-
# @return [String<HTML>, nil]
|
28
|
-
attr_reader :documentation
|
29
|
-
|
30
|
-
# @return [Shape, nil]
|
31
|
-
attr_reader :input
|
20
|
+
attr_accessor :http_request_uri
|
32
21
|
|
33
|
-
# @return [
|
34
|
-
|
22
|
+
# @return [Boolean]
|
23
|
+
attr_accessor :deprecated
|
35
24
|
|
36
|
-
# @return [
|
37
|
-
|
25
|
+
# @return [String, nil]
|
26
|
+
attr_accessor :documentation
|
38
27
|
|
39
|
-
# @return [
|
40
|
-
|
41
|
-
|
42
|
-
# @return [String]
|
43
|
-
def http_method
|
44
|
-
(@definition['http'] || {})['method'] || 'POST'
|
45
|
-
end
|
28
|
+
# @return [ShapeRef, nil]
|
29
|
+
attr_accessor :input
|
46
30
|
|
47
|
-
# @return [
|
48
|
-
|
49
|
-
(@definition['http'] || {})['requestUri'] || '/'
|
50
|
-
end
|
31
|
+
# @return [ShapeRef, nil]
|
32
|
+
attr_accessor :output
|
51
33
|
|
52
|
-
# @return [
|
53
|
-
|
54
|
-
!!@definition['deprecated']
|
55
|
-
end
|
34
|
+
# @return [Array<ShapeRef>]
|
35
|
+
attr_accessor :errors
|
56
36
|
|
57
|
-
|
58
|
-
|
59
|
-
def errors
|
60
|
-
errors = (definition['errors'] || [])
|
61
|
-
errors = errors.map { |error| shape_for(error) }
|
62
|
-
errors.enum_for(:each)
|
37
|
+
def [](key)
|
38
|
+
@metadata[key.to_s]
|
63
39
|
end
|
64
40
|
|
65
|
-
|
66
|
-
|
67
|
-
def shape_for(definition)
|
68
|
-
if definition.key?('shape')
|
69
|
-
@shape_map.shape(definition)
|
70
|
-
else
|
71
|
-
Shapes::Shape.new(definition, shape_map: @shape_map)
|
72
|
-
end
|
41
|
+
def []=(key, value)
|
42
|
+
@metadata[key.to_s] = value
|
73
43
|
end
|
74
44
|
|
75
45
|
end
|
@@ -4,447 +4,203 @@ module Seahorse
|
|
4
4
|
module Model
|
5
5
|
module Shapes
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# @return [void]
|
21
|
-
# @raise [ArgumentError] Raises an error if the given type or
|
22
|
-
# shape class have already been registered.
|
23
|
-
def register(type, shape_class)
|
24
|
-
shape_class.type = type
|
25
|
-
@types[type] = shape_class
|
26
|
-
end
|
27
|
-
|
28
|
-
# Given a type, this method returned the registered shape class.
|
29
|
-
# @param [String] type
|
30
|
-
# @return [Class<Shape>]
|
31
|
-
# @raise [ArgumentError] Raises an ArgumentError if there is no
|
32
|
-
# shape class registered with the given `type`.
|
33
|
-
def shape_class(type)
|
34
|
-
if @types.key?(type)
|
35
|
-
@types[type]
|
36
|
-
else
|
37
|
-
raise ArgumentError, "unregistered type `#{type}'"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Returns an enumerator that yields registered type names and shape
|
42
|
-
# classes.
|
43
|
-
#
|
44
|
-
# Seahorse::Model::Shapes.types.each do |type, shape_class|
|
45
|
-
# puts "%s => %s" % [type, shape_class.name]
|
46
|
-
# end
|
47
|
-
#
|
48
|
-
# @return [Enumerator] Returns an enumerable object that yields
|
49
|
-
# registered type names and shape classes.
|
50
|
-
def types
|
51
|
-
Enumerator.new do |y|
|
52
|
-
@types.each do |name, shape_class|
|
53
|
-
y.yield(name, shape_class)
|
7
|
+
class ShapeRef
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@metadata = {}
|
11
|
+
@required = false
|
12
|
+
@deprecated = false
|
13
|
+
options.each do |key, value|
|
14
|
+
if key == :metadata
|
15
|
+
value.each do |k,v|
|
16
|
+
self[k] = v
|
17
|
+
end
|
18
|
+
else
|
19
|
+
send("#{key}=", value)
|
54
20
|
end
|
55
21
|
end
|
56
22
|
end
|
57
23
|
|
58
|
-
|
59
|
-
|
60
|
-
class Shape
|
61
|
-
|
62
|
-
# @param [Hash] definition
|
63
|
-
# @option options [ShapeMap] :shape_map (nil)
|
64
|
-
def initialize(definition, options = {})
|
65
|
-
definition['type'] ||= self.class.type
|
66
|
-
@name = definition['shape']
|
67
|
-
@definition = definition
|
68
|
-
@type = definition['type']
|
69
|
-
@location = definition['location'] || 'body'
|
70
|
-
@location_name = definition['locationName']
|
71
|
-
@shape_map = options[:shape_map] || ShapeMap.new
|
72
|
-
end
|
73
|
-
|
74
|
-
# @return [String]
|
75
|
-
attr_reader :name
|
76
|
-
|
77
|
-
# @return [Hash]
|
78
|
-
attr_reader :definition
|
79
|
-
|
80
|
-
# @return [String] The type name for this shape.
|
81
|
-
attr_reader :type
|
82
|
-
|
83
|
-
# @return [String] Returns one of 'body', 'uri', 'headers', 'status_code'
|
84
|
-
attr_reader :location
|
85
|
-
|
86
|
-
# @return [String, nil] Typically only set for shapes that are
|
87
|
-
# structure members. Serialized names are typically set on the
|
88
|
-
# shape references, not on the shape definition.
|
89
|
-
attr_reader :location_name
|
90
|
-
|
91
|
-
attr_reader :documentation
|
92
|
-
|
93
|
-
# @return [ShapeMap]
|
94
|
-
attr_reader :shape_map
|
24
|
+
# @return [Shape]
|
25
|
+
attr_accessor :shape
|
95
26
|
|
96
27
|
# @return [String, nil]
|
97
|
-
|
98
|
-
@definition['documentation']
|
99
|
-
end
|
100
|
-
|
101
|
-
# @param [String] key
|
102
|
-
# @return [Object, nil]
|
103
|
-
def metadata(key)
|
104
|
-
@definition[key.to_s]
|
105
|
-
end
|
28
|
+
attr_accessor :location
|
106
29
|
|
107
|
-
# @
|
108
|
-
|
109
|
-
def inspect
|
110
|
-
"#<#{self.class.name}>"
|
111
|
-
end
|
112
|
-
|
113
|
-
# @api private
|
114
|
-
def with(options)
|
115
|
-
self.class.new(@definition.merge(options), shape_map: shape_map)
|
116
|
-
end
|
30
|
+
# @return [String, nil]
|
31
|
+
attr_accessor :location_name
|
117
32
|
|
118
|
-
|
33
|
+
# @return [Boolean]
|
34
|
+
attr_accessor :required
|
119
35
|
|
120
|
-
|
121
|
-
|
122
|
-
end
|
36
|
+
# @return [String, nil]
|
37
|
+
attr_accessor :documentation
|
123
38
|
|
124
|
-
|
125
|
-
|
126
|
-
shape_for(@definition[key])
|
127
|
-
else
|
128
|
-
raise ArgumentError, "expected shape definition at #{key.inspect}"
|
129
|
-
end
|
130
|
-
end
|
39
|
+
# @return [Boolean]
|
40
|
+
attr_accessor :deprecated
|
131
41
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@shape_map.shape(reference)
|
42
|
+
# Gets metadata for the given `key`.
|
43
|
+
def [](key)
|
44
|
+
if @metadata.key?(key.to_s)
|
45
|
+
@metadata[key.to_s]
|
137
46
|
else
|
138
|
-
|
47
|
+
@shape[key.to_s]
|
139
48
|
end
|
140
49
|
end
|
141
50
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
attr_accessor :type
|
146
|
-
|
147
|
-
# Constructs and returns a new shape object. You must specify
|
148
|
-
# the shape type using the "type" option or you must construct
|
149
|
-
# the shape using the appropriate subclass of `Shape`.
|
150
|
-
#
|
151
|
-
# @example Constructing a new shape
|
152
|
-
#
|
153
|
-
# shape = Seahorse::Model::Shapes::Shape.new("type" => "structure")
|
154
|
-
#
|
155
|
-
# shape.class
|
156
|
-
# #=> Seahorse::Model::Shapes::Structure
|
157
|
-
#
|
158
|
-
# shape.definition
|
159
|
-
# #=> { "type" => "structure" }
|
160
|
-
#
|
161
|
-
# @example Constructing a new shape using the shape class
|
162
|
-
#
|
163
|
-
# shape = Seahorse::Model::Shapes::String.new
|
164
|
-
# shape.definition
|
165
|
-
# #=> { "type" => "string" }
|
166
|
-
#
|
167
|
-
# @param [Hash] definition
|
168
|
-
# @option options [ShapeMap] :shape_map
|
169
|
-
# @return [Shape]
|
170
|
-
def new(definition = {}, options = {})
|
171
|
-
if self == Shape
|
172
|
-
from_type(definition, options)
|
173
|
-
else
|
174
|
-
super(apply_type(definition), options)
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
private
|
179
|
-
|
180
|
-
def apply_type(definition)
|
181
|
-
case definition['type']
|
182
|
-
when type then definition
|
183
|
-
when nil then { 'type' => type }.merge(definition)
|
184
|
-
else raise ArgumentError, "expected 'type' to be `#{type}'"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def from_type(definition, options)
|
189
|
-
if type = definition['type']
|
190
|
-
Shapes.shape_class(type).new(definition, options)
|
191
|
-
else
|
192
|
-
raise ArgumentError, 'must specify "type" in the definition'
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
51
|
+
# Sets metadata for the given `key`.
|
52
|
+
def []=(key, value)
|
53
|
+
@metadata[key.to_s] = value
|
196
54
|
end
|
197
55
|
|
198
56
|
end
|
199
57
|
|
200
|
-
class
|
58
|
+
class Shape
|
201
59
|
|
202
|
-
def initialize
|
203
|
-
|
204
|
-
@members = {}
|
205
|
-
@member_refs = {}
|
206
|
-
@member_names = {}
|
207
|
-
compute_member_names
|
208
|
-
compute_required_member_names
|
209
|
-
@member_names = @member_names.values
|
60
|
+
def initialize
|
61
|
+
@metadata = {}
|
210
62
|
end
|
211
63
|
|
212
|
-
# @return [
|
213
|
-
|
214
|
-
|
215
|
-
# @return [Array<Symbol>] Returns a list of required members names.
|
216
|
-
attr_reader :required
|
217
|
-
|
218
|
-
# @return [String, nil] Returns the name of the payload member if set.
|
219
|
-
attr_reader :payload
|
220
|
-
|
221
|
-
# @return [Shape, nil]
|
222
|
-
def payload_member
|
223
|
-
if payload
|
224
|
-
@payload_member ||= member(payload)
|
225
|
-
else
|
226
|
-
nil
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
# @param [Symbol] name
|
231
|
-
# @return [Shape]
|
232
|
-
def member(name)
|
233
|
-
if ref = @member_refs[name.to_sym]
|
234
|
-
@members[name] ||= shape_for(ref)
|
235
|
-
else
|
236
|
-
raise ArgumentError, "no such member :#{name}"
|
237
|
-
end
|
238
|
-
end
|
64
|
+
# @return [String]
|
65
|
+
attr_accessor :name
|
239
66
|
|
240
|
-
# @
|
241
|
-
|
242
|
-
# the given name.
|
243
|
-
def member?(name)
|
244
|
-
@member_refs.key?(name.to_sym)
|
245
|
-
end
|
67
|
+
# @return [String, nil]
|
68
|
+
attr_accessor :documentation
|
246
69
|
|
247
|
-
#
|
248
|
-
|
249
|
-
|
250
|
-
Enumerator.new do |y|
|
251
|
-
member_names.map do |member_name|
|
252
|
-
y.yield(member_name, member(member_name))
|
253
|
-
end
|
254
|
-
end
|
70
|
+
# Gets metadata for the given `key`.
|
71
|
+
def [](key)
|
72
|
+
@metadata[key.to_s]
|
255
73
|
end
|
256
74
|
|
257
|
-
#
|
258
|
-
|
259
|
-
|
260
|
-
# If found, the shape will be returned with its symbolized member
|
261
|
-
# name.
|
262
|
-
#
|
263
|
-
# If no shape is found with the given serialized name, then
|
264
|
-
# nil is returned.
|
265
|
-
#
|
266
|
-
# @example
|
267
|
-
#
|
268
|
-
# name, shape = structure.member_by_location_name('SerializedName')
|
269
|
-
# name #=> :member_name
|
270
|
-
# shape #=> instance of Seahorse::Model::Shapes::Shape
|
271
|
-
#
|
272
|
-
# @param [String] location_name
|
273
|
-
# @return [Array<Symbol,Shape>, nil]
|
274
|
-
def member_by_location_name(location_name)
|
275
|
-
@by_location_name ||= index_members_by_location_name
|
276
|
-
@by_location_name[location_name]
|
75
|
+
# Sets metadata for the given `key`.
|
76
|
+
def []=(key, value)
|
77
|
+
@metadata[key.to_s] = value
|
277
78
|
end
|
278
79
|
|
279
|
-
|
80
|
+
end
|
280
81
|
|
281
|
-
|
282
|
-
members.each.with_object({}) do |(name, shape), hash|
|
283
|
-
hash[shape.location_name] = [name, shape]
|
284
|
-
end
|
285
|
-
end
|
82
|
+
class BlobShape < Shape
|
286
83
|
|
287
|
-
|
288
|
-
|
289
|
-
name = underscore(orig_name).to_sym
|
290
|
-
if ref['location'] == 'headers'
|
291
|
-
@member_refs[name] = ref
|
292
|
-
else
|
293
|
-
@member_refs[name] = { 'locationName' => orig_name }.merge(ref)
|
294
|
-
end
|
295
|
-
@member_names[orig_name] = name
|
296
|
-
end
|
297
|
-
@payload = @member_names[definition['payload']] if definition['payload']
|
298
|
-
end
|
84
|
+
# @return [Integer, nil]
|
85
|
+
attr_accessor :min
|
299
86
|
|
300
|
-
|
301
|
-
|
302
|
-
@member_names[orig_name]
|
303
|
-
end
|
304
|
-
end
|
87
|
+
# @return [Integer, nil]
|
88
|
+
attr_accessor :max
|
305
89
|
|
306
90
|
end
|
307
91
|
|
308
|
-
class
|
92
|
+
class BooleanShape < Shape; end
|
309
93
|
|
310
|
-
|
311
|
-
super
|
312
|
-
@min = definition['min']
|
313
|
-
@max = definition['max']
|
314
|
-
@member = shape_at('member')
|
315
|
-
end
|
94
|
+
class FloatShape < Shape; end
|
316
95
|
|
317
|
-
|
318
|
-
attr_reader :member
|
96
|
+
class IntegerShape < Shape
|
319
97
|
|
320
98
|
# @return [Integer, nil]
|
321
|
-
|
99
|
+
attr_accessor :min
|
322
100
|
|
323
101
|
# @return [Integer, nil]
|
324
|
-
|
102
|
+
attr_accessor :max
|
325
103
|
|
326
104
|
end
|
327
105
|
|
328
|
-
class
|
106
|
+
class ListShape < Shape
|
329
107
|
|
330
|
-
|
331
|
-
|
332
|
-
@min = definition['min']
|
333
|
-
@max = definition['max']
|
334
|
-
@key = shape_at('key')
|
335
|
-
@value = shape_at('value')
|
336
|
-
end
|
337
|
-
|
338
|
-
# @return [Shape]
|
339
|
-
attr_reader :key
|
340
|
-
|
341
|
-
# @return [Shape]
|
342
|
-
attr_reader :value
|
108
|
+
# @return [ShapeRef]
|
109
|
+
attr_accessor :member
|
343
110
|
|
344
111
|
# @return [Integer, nil]
|
345
|
-
|
112
|
+
attr_accessor :min
|
346
113
|
|
347
114
|
# @return [Integer, nil]
|
348
|
-
|
115
|
+
attr_accessor :max
|
349
116
|
|
350
117
|
end
|
351
118
|
|
352
|
-
class
|
119
|
+
class MapShape < Shape
|
353
120
|
|
354
|
-
|
355
|
-
|
356
|
-
@enum = Set.new(definition['enum']) if definition['enum']
|
357
|
-
@pattern = definition['pattern']
|
358
|
-
@min = definition['min']
|
359
|
-
@max = definition['max']
|
360
|
-
end
|
361
|
-
|
362
|
-
# @return [Set, nil]
|
363
|
-
attr_reader :enum
|
121
|
+
# @return [ShapeRef]
|
122
|
+
attr_accessor :key
|
364
123
|
|
365
|
-
# @return [
|
366
|
-
|
124
|
+
# @return [ShapeRef]
|
125
|
+
attr_accessor :value
|
367
126
|
|
368
127
|
# @return [Integer, nil]
|
369
|
-
|
128
|
+
attr_accessor :min
|
370
129
|
|
371
130
|
# @return [Integer, nil]
|
372
|
-
|
131
|
+
attr_accessor :max
|
373
132
|
|
374
133
|
end
|
375
134
|
|
376
|
-
class
|
135
|
+
class StringShape < Shape
|
377
136
|
|
378
|
-
|
137
|
+
# @return [Set<String>, nil]
|
138
|
+
attr_accessor :enum
|
379
139
|
|
380
|
-
|
381
|
-
|
382
|
-
def initialize(definition, options = {})
|
383
|
-
@format = definition['timestampFormat']
|
384
|
-
super
|
385
|
-
end
|
386
|
-
|
387
|
-
# @return [String]
|
388
|
-
attr_reader :format
|
140
|
+
# @return [Integer, nil]
|
141
|
+
attr_accessor :min
|
389
142
|
|
390
|
-
# @
|
391
|
-
|
392
|
-
# when {#format} is not set on this timestamp shape.
|
393
|
-
# @return [String]
|
394
|
-
def format_time(time, default_format)
|
395
|
-
format = @format || default_format
|
396
|
-
case format
|
397
|
-
when 'iso8601' then time.utc.iso8601
|
398
|
-
when 'rfc822' then time.utc.rfc822
|
399
|
-
when 'httpdate' then time.httpdate
|
400
|
-
when 'unixTimestamp' then time.utc.to_i
|
401
|
-
else
|
402
|
-
msg = "invalid timestamp format #{format.inspect}"
|
403
|
-
raise ArgumentError, msg
|
404
|
-
end
|
405
|
-
end
|
143
|
+
# @return [Integer, nil]
|
144
|
+
attr_accessor :max
|
406
145
|
|
407
146
|
end
|
408
147
|
|
409
|
-
class
|
148
|
+
class StructureShape < Shape
|
410
149
|
|
411
|
-
def initialize(
|
412
|
-
@
|
413
|
-
@
|
414
|
-
|
150
|
+
def initialize(options = {})
|
151
|
+
@members = {}
|
152
|
+
@members_by_location_name = {}
|
153
|
+
@required = Set.new
|
154
|
+
super()
|
415
155
|
end
|
416
156
|
|
417
|
-
# @return [
|
418
|
-
|
157
|
+
# @return [Set<Symbol>]
|
158
|
+
attr_accessor :required
|
419
159
|
|
420
|
-
# @
|
421
|
-
|
160
|
+
# @param [Symbol] name
|
161
|
+
# @param [ShapeRef] shape_ref
|
162
|
+
def add_member(name, shape_ref)
|
163
|
+
name = name.to_sym
|
164
|
+
@required << name if shape_ref.required
|
165
|
+
@members_by_location_name[shape_ref.location_name] = [name, shape_ref]
|
166
|
+
@members[name] = shape_ref
|
167
|
+
end
|
422
168
|
|
423
|
-
|
169
|
+
# @return [Array<Symbol>]
|
170
|
+
def member_names
|
171
|
+
@members.keys
|
172
|
+
end
|
424
173
|
|
425
|
-
|
174
|
+
# @param [Symbol] member_name
|
175
|
+
# @return [Boolean] Returns `true` if there exists a member with
|
176
|
+
# the given name.
|
177
|
+
def member?(member_name)
|
178
|
+
@members.key?(member_name.to_sym)
|
179
|
+
end
|
426
180
|
|
427
|
-
|
181
|
+
# @return [Enumerator<[Symbol,ShapeRef]>]
|
182
|
+
def members
|
183
|
+
@members.to_enum
|
184
|
+
end
|
428
185
|
|
429
|
-
|
186
|
+
# @param [Symbol] name
|
187
|
+
# @return [ShapeRef]
|
188
|
+
def member(name)
|
189
|
+
if member?(name)
|
190
|
+
@members[name.to_sym]
|
191
|
+
else
|
192
|
+
raise ArgumentError, "no such member #{name.inspect}"
|
193
|
+
end
|
194
|
+
end
|
430
195
|
|
431
|
-
|
196
|
+
# @api private
|
197
|
+
def member_by_location_name(location_name)
|
198
|
+
@members_by_location_name[location_name]
|
199
|
+
end
|
432
200
|
|
433
|
-
|
201
|
+
end
|
434
202
|
|
435
|
-
|
436
|
-
register('byte', Shapes::Byte)
|
437
|
-
register('boolean', Shapes::Boolean)
|
438
|
-
register('character', Shapes::Character)
|
439
|
-
register('double', Shapes::Double)
|
440
|
-
register('float', Shapes::Float)
|
441
|
-
register('integer', Shapes::Integer)
|
442
|
-
register('list', Shapes::List)
|
443
|
-
register('long', Shapes::Long)
|
444
|
-
register('map', Shapes::Map)
|
445
|
-
register('string', Shapes::String)
|
446
|
-
register('structure', Shapes::Structure)
|
447
|
-
register('timestamp', Shapes::Timestamp)
|
203
|
+
class TimestampShape < Shape; end
|
448
204
|
|
449
205
|
end
|
450
206
|
end
|