aws-sdk-core 2.0.48 → 2.1.0
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.
- 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
@@ -0,0 +1,163 @@
|
|
1
|
+
module Aws
|
2
|
+
module Api
|
3
|
+
module Docs
|
4
|
+
class ParamFormatter
|
5
|
+
|
6
|
+
include Utils
|
7
|
+
include Seahorse::Model::Shapes
|
8
|
+
|
9
|
+
def initialize(shape_ref)
|
10
|
+
@shape_ref = shape_ref
|
11
|
+
@recursive_shapes = compute_recursive_shapes(@shape_ref)
|
12
|
+
end
|
13
|
+
|
14
|
+
def format
|
15
|
+
if @shape_ref && @shape_ref.shape.member_names.count > 0
|
16
|
+
ref_value(@shape_ref, '', [])
|
17
|
+
else
|
18
|
+
''
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def ref_value(ref, i, visited)
|
25
|
+
if visited.include?(ref.shape)
|
26
|
+
return "{\n#{i} # recursive #{ref.shape.name}\n#{i}}"
|
27
|
+
else
|
28
|
+
visited = visited + [ref.shape]
|
29
|
+
end
|
30
|
+
case ref.shape
|
31
|
+
when StructureShape
|
32
|
+
if ref.shape.name == 'AttributeValue'
|
33
|
+
'"value"'
|
34
|
+
else
|
35
|
+
struct(ref, i, visited)
|
36
|
+
end
|
37
|
+
when BlobShape
|
38
|
+
if ref[:response_target]
|
39
|
+
'"/path/to/file"'
|
40
|
+
elsif ref[:streaming]
|
41
|
+
'source_file'
|
42
|
+
else
|
43
|
+
'"data"'
|
44
|
+
end
|
45
|
+
when ListShape then list(ref, i, visited)
|
46
|
+
when MapShape then map(ref, i, visited)
|
47
|
+
when BooleanShape then "true"
|
48
|
+
when IntegerShape then '1'
|
49
|
+
when FloatShape then '1.0'
|
50
|
+
when StringShape then string(ref)
|
51
|
+
when TimestampShape then 'Time.now'
|
52
|
+
else raise "unsupported shape #{ref.shape.class.name}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def struct(ref, i, visited)
|
57
|
+
lines = ['{']
|
58
|
+
ref.shape.members.each do |member_name, member_ref|
|
59
|
+
lines << struct_member(member_name, member_ref, i, visited)
|
60
|
+
end
|
61
|
+
lines << "#{i}}"
|
62
|
+
lines.join("\n")
|
63
|
+
end
|
64
|
+
|
65
|
+
def struct_member(member_name, member_ref, i, visited)
|
66
|
+
entry = "#{i} #{member_name}: #{ref_value(member_ref, i + ' ', visited)},"
|
67
|
+
apply_comments(member_ref, entry)
|
68
|
+
end
|
69
|
+
|
70
|
+
def list(ref, i, visited)
|
71
|
+
if complex?(ref.shape.member)
|
72
|
+
complex_list(ref.shape.member, i, visited)
|
73
|
+
else
|
74
|
+
scalar_list(ref.shape.member, i, visited)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def scalar_list(ref, i, visited)
|
79
|
+
"[#{ref_value(ref, i, visited)}]"
|
80
|
+
end
|
81
|
+
|
82
|
+
def complex_list(ref, i, visited)
|
83
|
+
"[\n#{i} #{ref_value(ref, i + ' ', visited)},\n#{i}]"
|
84
|
+
end
|
85
|
+
|
86
|
+
def map(ref, i, visited)
|
87
|
+
key = string(ref.shape.key)
|
88
|
+
value = ref_value(ref.shape.value, i + ' ', visited)
|
89
|
+
"{\n#{i} #{key} => #{value},#{comments(ref.shape.value)}\n#{i}}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def string(ref)
|
93
|
+
if ref.shape.enum
|
94
|
+
ref.shape.enum.first.inspect
|
95
|
+
elsif ref.shape.name
|
96
|
+
ref.shape.name.inspect
|
97
|
+
else
|
98
|
+
'"string"'
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def apply_comments(ref, text)
|
103
|
+
lines = text.lines.to_a
|
104
|
+
if lines[0].match(/\n$/)
|
105
|
+
lines[0] = lines[0].sub(/\n$/, comments(ref) + "\n")
|
106
|
+
else
|
107
|
+
lines[0] += comments(ref)
|
108
|
+
end
|
109
|
+
lines.join
|
110
|
+
end
|
111
|
+
|
112
|
+
def comments(ref)
|
113
|
+
comments = []
|
114
|
+
if ref[:response_target]
|
115
|
+
comments << 'where to write response data, file path, or IO object'
|
116
|
+
end
|
117
|
+
if ref[:streaming]
|
118
|
+
comments << 'file/IO object, or string data'
|
119
|
+
end
|
120
|
+
if ref.required
|
121
|
+
comments << 'required'
|
122
|
+
end
|
123
|
+
if enum = enum_values(ref)
|
124
|
+
comments << "accepts #{enum.to_a.join(', ')}"
|
125
|
+
end
|
126
|
+
if ddb_av?(ref)
|
127
|
+
comments << 'value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>'
|
128
|
+
end
|
129
|
+
comments == [] ? '' : " # #{comments.join(', ')}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def recursive?(ref)
|
133
|
+
@recursive_shapes.include?(ref.shape)
|
134
|
+
end
|
135
|
+
|
136
|
+
def enum_values(ref)
|
137
|
+
case ref.shape
|
138
|
+
when ListShape then enum_values(ref.shape.member)
|
139
|
+
when StringShape then ref.shape.enum
|
140
|
+
else nil
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def complex?(ref)
|
145
|
+
if StructureShape === ref.shape
|
146
|
+
!ddb_av?(ref)
|
147
|
+
else
|
148
|
+
ListShape === ref.shape || MapShape === ref.shape
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def ddb_av?(ref)
|
153
|
+
case ref.shape
|
154
|
+
when ListShape then ddb_av?(ref.shape.member)
|
155
|
+
when StructureShape then ref.shape.name == 'AttributeValue'
|
156
|
+
else false
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Aws
|
2
|
+
module Api
|
3
|
+
module Docs
|
4
|
+
class RequestSyntaxExample
|
5
|
+
|
6
|
+
include Utils
|
7
|
+
include Seahorse::Model::Shapes
|
8
|
+
|
9
|
+
def initialize(method_name, operation)
|
10
|
+
@method_name = method_name
|
11
|
+
@operation = operation
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_str
|
15
|
+
params = ParamFormatter.new(operation_input_ref(@operation))
|
16
|
+
"resp = client.#{@method_name}(#{params.format})"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Aws
|
2
|
+
module Api
|
3
|
+
module Docs
|
4
|
+
class ResponseStructureExample
|
5
|
+
|
6
|
+
include Utils
|
7
|
+
include Seahorse::Model::Shapes
|
8
|
+
|
9
|
+
def initialize(method_name, operation)
|
10
|
+
@method_name = method_name
|
11
|
+
@operation = operation
|
12
|
+
@recursive_shapes = compute_recursive_shapes(@operation.output)
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_str
|
16
|
+
if @operation.output
|
17
|
+
lines = entry(@operation.output, "resp", [])
|
18
|
+
lines.empty? ? nil : lines.join("\n")
|
19
|
+
else
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def structure(ref, context, visited)
|
27
|
+
lines = []
|
28
|
+
ref.shape.members.each do |member_name, member_ref|
|
29
|
+
lines += entry(member_ref, "#{context}.#{member_name}", visited)
|
30
|
+
end
|
31
|
+
lines
|
32
|
+
end
|
33
|
+
|
34
|
+
def list(ref, context, visited)
|
35
|
+
lines = []
|
36
|
+
lines << "#{context} #=> Array"
|
37
|
+
lines += entry(ref.shape.member, "#{context}[0]", visited)
|
38
|
+
lines
|
39
|
+
end
|
40
|
+
|
41
|
+
def map(ref, context, visited)
|
42
|
+
lines = []
|
43
|
+
lines << "#{context} #=> Hash"
|
44
|
+
lines += entry(ref.shape.value, "#{context}[#{map_key(ref)}]", visited)
|
45
|
+
lines
|
46
|
+
end
|
47
|
+
|
48
|
+
def map_key(ref)
|
49
|
+
(ref.shape.key.shape.name || 'string').inspect
|
50
|
+
end
|
51
|
+
|
52
|
+
def entry(ref, context, visited)
|
53
|
+
if ref.shape.name == 'AttributeValue'
|
54
|
+
return ["#{context} #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>"]
|
55
|
+
elsif visited.include?(ref.shape)
|
56
|
+
return ["#{context} #=> Types::#{ref.shape.name}"]
|
57
|
+
else
|
58
|
+
visited = visited + [ref.shape]
|
59
|
+
end
|
60
|
+
case ref.shape
|
61
|
+
when StructureShape then structure(ref, context, visited)
|
62
|
+
when ListShape then list(ref, context, visited)
|
63
|
+
when MapShape then map(ref, context, visited)
|
64
|
+
else ["#{context} #=> #{value(ref)}"]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def value(ref)
|
69
|
+
case ref.shape
|
70
|
+
when StringShape then string(ref)
|
71
|
+
when IntegerShape then 'Integer'
|
72
|
+
when FloatShape then 'Float'
|
73
|
+
when BooleanShape then 'true/false'
|
74
|
+
when BlobShape then 'IO'
|
75
|
+
when TimestampShape then 'Time'
|
76
|
+
else raise "unhandled shape type #{ref.shape.class.name}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def string(ref)
|
81
|
+
if ref.shape.enum
|
82
|
+
"String, one of #{ref.shape.enum.map(&:inspect).join(', ')}"
|
83
|
+
else
|
84
|
+
'String'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module Aws
|
4
|
+
module Api
|
5
|
+
module Docs
|
6
|
+
module Utils
|
7
|
+
|
8
|
+
include Seahorse::Model
|
9
|
+
include Seahorse::Model::Shapes
|
10
|
+
|
11
|
+
def tag(string)
|
12
|
+
YARD::DocstringParser.new.parse(string).to_docstring.tags.first
|
13
|
+
end
|
14
|
+
|
15
|
+
def summary(string)
|
16
|
+
if string
|
17
|
+
YARD::DocstringParser.new.parse(string).to_docstring.summary
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def operation_input_ref(operation, options = {})
|
24
|
+
struct = StructureShape.new
|
25
|
+
|
26
|
+
# add the response target input member if the operation is streaming
|
27
|
+
if
|
28
|
+
operation.output &&
|
29
|
+
operation.output[:payload] &&
|
30
|
+
operation.output[:payload_member][:streaming]
|
31
|
+
then
|
32
|
+
target = ShapeRef.new(shape: BlobShape.new)
|
33
|
+
target[:response_target] = true
|
34
|
+
target.documentation = "Specifies where to stream response data. You can provide the path where a file will be created on disk, or you can provide an IO object. If omitted, the response data will be loaded into memory and written to a StringIO object."
|
35
|
+
struct.add_member(:response_target, target)
|
36
|
+
end
|
37
|
+
|
38
|
+
# copy existing input members
|
39
|
+
skip = options[:without] || Set.new
|
40
|
+
if operation.input
|
41
|
+
operation.input.shape.members.each do |member_name, member_ref|
|
42
|
+
unless skip.include?(member_name.to_s)
|
43
|
+
struct.add_member(member_name, member_ref)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
ShapeRef.new(shape: struct)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Given a shape reference, this function returns a Set of all
|
52
|
+
# of the recursive shapes found in tree.
|
53
|
+
def compute_recursive_shapes(ref, stack = [], recursive = Set.new)
|
54
|
+
if ref && !stack.include?(ref.shape)
|
55
|
+
stack.push(ref.shape)
|
56
|
+
case ref.shape
|
57
|
+
when StructureShape
|
58
|
+
ref.shape.members.each do |_, member_ref|
|
59
|
+
compute_recursive_shapes(member_ref, stack, recursive)
|
60
|
+
end
|
61
|
+
when ListShape
|
62
|
+
compute_recursive_shapes(ref.shape.member, stack, recursive)
|
63
|
+
when MapShape
|
64
|
+
compute_recursive_shapes(ref.shape.value, stack, recursive)
|
65
|
+
end
|
66
|
+
stack.pop
|
67
|
+
elsif ref
|
68
|
+
recursive << ref.shape
|
69
|
+
end
|
70
|
+
recursive
|
71
|
+
end
|
72
|
+
|
73
|
+
# Given a shape ref, returns the type accepted when given as input.
|
74
|
+
def input_type(ref, link = false)
|
75
|
+
if BlobShape === ref.shape
|
76
|
+
'IO,String'
|
77
|
+
else
|
78
|
+
output_type(ref, link)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Given a shape ref, returns the type returned in output.
|
83
|
+
def output_type(ref, link = false)
|
84
|
+
case ref.shape
|
85
|
+
when StructureShape
|
86
|
+
type = "Types::" + ref.shape.name
|
87
|
+
link ? "{#{type}}" : type
|
88
|
+
when ListShape
|
89
|
+
"Array<#{output_type(ref.shape.member, link)}>"
|
90
|
+
when MapShape
|
91
|
+
"Hash<String,#{output_type(ref.shape.value, link)}>"
|
92
|
+
when BlobShape
|
93
|
+
ref[:streaming] ? 'IO,File' : 'String'
|
94
|
+
when BooleanShape then 'Boolean'
|
95
|
+
when FloatShape then 'Float'
|
96
|
+
when IntegerShape then 'Integer'
|
97
|
+
when StringShape then 'String'
|
98
|
+
when TimestampShape then 'Time'
|
99
|
+
else raise "unsupported shape #{ref.shape.class.name}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# Documents a structure member as a attribute method
|
104
|
+
def document_struct_member(yard_class, member_name, ref, read_write = true)
|
105
|
+
m = YARD::CodeObjects::MethodObject.new(yard_class, member_name)
|
106
|
+
m.scope = :instance
|
107
|
+
m.docstring = struct_member_docstring(ref.documentation, ref)
|
108
|
+
returns = "@return [#{output_type(ref)}] #{summary(ref.documentation)}"
|
109
|
+
m.add_tag(tag(returns))
|
110
|
+
yard_class.instance_attributes[member_name] = read_write ?
|
111
|
+
{ :read => m, :write => m } :
|
112
|
+
{ :read => m }
|
113
|
+
end
|
114
|
+
|
115
|
+
def struct_member_docstring(docs, ref)
|
116
|
+
if
|
117
|
+
Seahorse::Model::Shapes::StringShape === ref.shape &&
|
118
|
+
ref.shape.enum
|
119
|
+
then
|
120
|
+
docs = "#{docs}<p>Possible values:</p><ul>"
|
121
|
+
docs += ref.shape.enum.map { |v| "<li><tt>#{v}</tt></li>" }.join
|
122
|
+
docs += "</ul>"
|
123
|
+
docs
|
124
|
+
else
|
125
|
+
docs
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
module Aws
|
2
|
+
module Api
|
3
|
+
class ShapeMap
|
4
|
+
|
5
|
+
include Seahorse::Model::Shapes
|
6
|
+
|
7
|
+
EMPTY_REF = begin
|
8
|
+
shape = StructureShape.new
|
9
|
+
shape[:struct_class] = Aws::EmptyStructure
|
10
|
+
ShapeRef.new(shape: shape)
|
11
|
+
end
|
12
|
+
|
13
|
+
SHAPE_CLASSES = {
|
14
|
+
'blob' => BlobShape,
|
15
|
+
'byte' => StringShape,
|
16
|
+
'boolean' => BooleanShape,
|
17
|
+
'character' => StringShape,
|
18
|
+
'double' => FloatShape,
|
19
|
+
'float' => FloatShape,
|
20
|
+
'integer' => IntegerShape,
|
21
|
+
'list' => ListShape,
|
22
|
+
'long' => IntegerShape,
|
23
|
+
'map' => MapShape,
|
24
|
+
'string' => StringShape,
|
25
|
+
'structure' => StructureShape,
|
26
|
+
'timestamp' => TimestampShape,
|
27
|
+
}
|
28
|
+
|
29
|
+
# @param [Hash] shape_definitions
|
30
|
+
# @option options [DocstringProvider] :docs (NullDocstringProvider)
|
31
|
+
def initialize(shape_definitions, options = {})
|
32
|
+
@shapes = {}
|
33
|
+
@docs = options[:docs] || Docs::NullDocstringProvider.new
|
34
|
+
build_shapes(shape_definitions)
|
35
|
+
end
|
36
|
+
|
37
|
+
def [](shape_name)
|
38
|
+
if shape = @shapes[shape_name]
|
39
|
+
shape
|
40
|
+
else
|
41
|
+
raise ArgumentError, "unknown shape #{shape_name.inspect}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def each_structure
|
46
|
+
@shapes.each do |_, shape|
|
47
|
+
if StructureShape === shape && !shape[:error] && !shape[:exception]
|
48
|
+
yield(shape)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def shape_ref(definition, options = {})
|
54
|
+
if definition
|
55
|
+
|
56
|
+
meta = definition.dup
|
57
|
+
|
58
|
+
shape = self[meta.delete('shape')]
|
59
|
+
location = meta.delete('location')
|
60
|
+
location_name = meta.delete('locationName')
|
61
|
+
location_name ||= options[:member_name] unless location == 'headers'
|
62
|
+
documentation = @docs.shape_ref_docs(shape.name, options[:target])
|
63
|
+
|
64
|
+
ShapeRef.new(
|
65
|
+
shape: shape,
|
66
|
+
location: location,
|
67
|
+
location_name: location_name,
|
68
|
+
required: !!options[:required],
|
69
|
+
deprecated: !!(meta.delete('deprecated') || shape[:deprecated]),
|
70
|
+
documentation: documentation,
|
71
|
+
metadata: meta)
|
72
|
+
else
|
73
|
+
EMPTY_REF
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def build_shapes(definitions)
|
80
|
+
definitions.each do |name, definition|
|
81
|
+
shape = SHAPE_CLASSES[definition['type']].new
|
82
|
+
shape.name = name
|
83
|
+
@shapes[name] = shape
|
84
|
+
end
|
85
|
+
definitions.each do |name, definition|
|
86
|
+
traits = definition.dup
|
87
|
+
shape = @shapes[name]
|
88
|
+
apply_shape_refs(shape, traits)
|
89
|
+
apply_shape_traits(shape, traits)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def apply_shape_refs(shape, traits)
|
94
|
+
case shape
|
95
|
+
when StructureShape
|
96
|
+
required = Set.new(traits.delete('required') || [])
|
97
|
+
(traits.delete('members') || {}).each do |member_name, ref|
|
98
|
+
name = underscore(member_name)
|
99
|
+
shape.add_member(name, shape_ref(ref,
|
100
|
+
member_name: member_name,
|
101
|
+
required: required.include?(member_name),
|
102
|
+
target: "#{shape.name}$#{member_name}",
|
103
|
+
))
|
104
|
+
end
|
105
|
+
shape[:struct_class] = Structure.new(*shape.member_names)
|
106
|
+
when ListShape
|
107
|
+
shape.member = shape_ref(
|
108
|
+
traits.delete('member'),
|
109
|
+
target: "#{shape.name}$member")
|
110
|
+
when MapShape
|
111
|
+
shape.key = shape_ref(
|
112
|
+
traits.delete('key'),
|
113
|
+
target: "#{shape.name}$key")
|
114
|
+
shape.value = shape_ref(
|
115
|
+
traits.delete('value'),
|
116
|
+
target: "#{shape.name}$value")
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def apply_shape_traits(shape, traits)
|
121
|
+
shape.enum = Set.new(traits.delete('enum')) if traits.key?('enum')
|
122
|
+
shape.min = traits.delete('min') if traits.key?('min')
|
123
|
+
shape.max = traits.delete('max') if traits.key?('max')
|
124
|
+
shape.documentation = @docs.shape_docs(shape.name)
|
125
|
+
if payload = traits.delete('payload')
|
126
|
+
shape[:payload] = underscore(payload)
|
127
|
+
shape[:payload_member] = shape.member(shape[:payload])
|
128
|
+
end
|
129
|
+
traits.each do |key, value|
|
130
|
+
shape[key] = value
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def underscore(str)
|
135
|
+
Seahorse::Util.underscore(str).to_sym
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|