aws-sdk-code-generator 0.1.0.pre → 0.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-code-generator.rb +68 -75
  3. data/lib/aws-sdk-code-generator/api.rb +130 -0
  4. data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
  5. data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
  6. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +268 -0
  7. data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
  8. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +108 -0
  9. data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
  10. data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
  11. data/lib/aws-sdk-code-generator/docstring.rb +199 -0
  12. data/lib/aws-sdk-code-generator/error_list.rb +77 -0
  13. data/lib/aws-sdk-code-generator/errors.rb +2 -0
  14. data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
  15. data/lib/aws-sdk-code-generator/gem_builder.rb +19 -25
  16. data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
  17. data/lib/aws-sdk-code-generator/helper.rb +77 -61
  18. data/lib/aws-sdk-code-generator/plugin_list.rb +146 -0
  19. data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
  20. data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
  21. data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
  22. data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
  23. data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
  24. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
  25. data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
  26. data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
  27. data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
  28. data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
  29. data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
  30. data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
  31. data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
  32. data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
  33. data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
  34. data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
  35. data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
  36. data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
  37. data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
  38. data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
  39. data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
  40. data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
  41. data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
  42. data/lib/aws-sdk-code-generator/service.rb +30 -7
  43. data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
  44. data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
  45. data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
  46. data/lib/aws-sdk-code-generator/underscore.rb +10 -5
  47. data/lib/aws-sdk-code-generator/view.rb +33 -0
  48. data/lib/aws-sdk-code-generator/views.rb +2 -0
  49. data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
  50. data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
  51. data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
  52. data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
  53. data/lib/aws-sdk-code-generator/views/client_api_module.rb +583 -0
  54. data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
  55. data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
  56. data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
  57. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
  58. data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
  59. data/lib/aws-sdk-code-generator/views/features/smoke.rb +51 -0
  60. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
  61. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +2 -0
  62. data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
  63. data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
  64. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
  65. data/lib/aws-sdk-code-generator/views/service_module.rb +30 -14
  66. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
  67. data/lib/aws-sdk-code-generator/views/types_module.rb +294 -0
  68. data/lib/aws-sdk-code-generator/views/version.rb +2 -0
  69. data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
  70. data/lib/aws-sdk-code-generator/waiter.rb +95 -0
  71. data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
  72. metadata +61 -68
  73. data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
  74. data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
  75. data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
  76. data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
  77. data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
  78. data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
  79. data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
  80. data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
  81. data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
  82. data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
  83. data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
  84. data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
  85. data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
  86. data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
  87. data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
  88. data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
  89. data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
  90. data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
  91. data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
  92. data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
  93. data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
  94. data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
  95. data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
  96. data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
  97. data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
  98. data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
  99. data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
  100. data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
  101. data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
  102. data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
  103. data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
  104. data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
  105. data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
  106. data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
  107. data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
  108. data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
  109. data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
  110. data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
  111. data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
  112. data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
  113. data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
  114. data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
  115. data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
  116. data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
  117. data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
  118. data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
  119. data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
  120. data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
  121. data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
  122. data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
  123. data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
  124. data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
  125. data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
  126. data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
  127. data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
  128. data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
  129. data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
  130. data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
  131. data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceActionCode
5
+
6
+ def initialize(options)
7
+ action = options.fetch(:action)
8
+ @request = action.fetch('request')
9
+ @resource = action.fetch('resource', nil)
10
+ @streaming = options.fetch(:streaming, false)
11
+ end
12
+
13
+ def build
14
+ parts = []
15
+ if batch_action?
16
+ parts << 'batch = []'
17
+ parts << client_request
18
+ parts << ResourceBatchBuilder.new(resource: @resource).build
19
+ parts << "#{resource_type}::Collection.new([batch], size: batch.size)"
20
+ elsif resource_action?
21
+ parts << client_request(
22
+ @resource['identifiers'].any? { |i| i['source'] == 'response' } || @resource['path']
23
+ )
24
+ parts << ResourceBuilder.new(resource: @resource, request_made: true).build
25
+ else
26
+ parts << client_request
27
+ parts << 'resp.data'
28
+ end
29
+ parts.join("\n").rstrip
30
+ end
31
+
32
+ private
33
+
34
+ def client_request(resp = true)
35
+ ResourceClientRequest.build(request: @request, resp: resp, streaming: @streaming)
36
+ end
37
+
38
+ def resource_type
39
+ @resource['type']
40
+ end
41
+
42
+ def batch_action?
43
+ if resource_action?
44
+ paths = (@resource['identifiers'] || []).map {|i| i['path'] }
45
+ paths << @resource['path']
46
+ paths.compact.any? { |path| path.match(/\[/) }
47
+ else
48
+ false
49
+ end
50
+ end
51
+
52
+ def resource_action?
53
+ !!@resource
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceAssociation
5
+ class << self
6
+
7
+ # @return [Array<ResourceMethod>]
8
+ def build_list(options)
9
+ associations = []
10
+ associations += has_associations(options)
11
+ associations += has_many_associations(options)
12
+ associations.sort_by(&:method_name)
13
+ end
14
+
15
+ private
16
+
17
+ def has_associations(options)
18
+ options.fetch(:resource).fetch('has', {}).map do |name, assoc|
19
+ ResourceHasAssociation.build(options.merge(
20
+ name: name,
21
+ assoc: assoc,
22
+ ))
23
+ end
24
+ end
25
+
26
+ def has_many_associations(options)
27
+ options.fetch(:resource).fetch('hasMany', {}).map do |name, assoc|
28
+ ResourceHasManyAssociation.build(options.merge(
29
+ name: name,
30
+ assoc: assoc,
31
+ ))
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceAttribute
5
+
6
+ # @return [String]
7
+ attr_accessor :name
8
+
9
+ # @return [String, nil]
10
+ attr_accessor :documentation
11
+
12
+ class << self
13
+
14
+ # @return [Array<ResourceAttribute>)
15
+ def build_list(resource, api)
16
+ if resource['shape']
17
+ data_attribute_names(resource, api).map do |member_name, member_ref|
18
+ docstring = Docstring.block_comment(
19
+ Docstring.html_to_markdown(Api.docstring(member_ref, api))
20
+ )
21
+ docstring = (docstring ? "#{docstring}\n" : '')
22
+ type = Api.ruby_type(member_ref, api)
23
+ ResourceAttribute.new.tap do |attr|
24
+ attr.name = Underscore.underscore(member_name)
25
+ attr.documentation = docstring + "# @return [#{type}]"
26
+ end
27
+ end
28
+ else
29
+ []
30
+ end
31
+
32
+ end
33
+
34
+ private
35
+
36
+ def data_attribute_names(resource, api)
37
+
38
+ identifiers = resource['identifiers']
39
+
40
+ skip = Set.new
41
+
42
+ # do no duplicate identifiers
43
+ identifiers.each do |i|
44
+ skip << i['name']
45
+ skip << i['memberName'] if i.key?('memberName')
46
+ end
47
+
48
+ # do no duplicate action names
49
+ (resource['actions'] || {}).keys.each do |action_name|
50
+ skip << action_name
51
+ end
52
+
53
+ # do no duplicate has association names
54
+ (resource['has'] || {}).keys.each do |association_name|
55
+ skip << association_name
56
+ end
57
+
58
+ # do no duplicate hasMany association names
59
+ (resource['hasMany'] || {}).keys.each do |association_name|
60
+ skip << association_name
61
+ end
62
+
63
+ shape = Api.shape(resource['shape'], api)
64
+ members = shape['members'] || {}
65
+ Enumerator.new do |y|
66
+ members.each do |member_name, member_ref|
67
+ unless skip.include?(member_name)
68
+ y.yield(member_name, member_ref)
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceBatchAction
5
+ class << self
6
+
7
+ # @return [Array<ResourceMethod>]
8
+ def build_list(resource_name, resource, api)
9
+ resource.fetch('batchActions', {}).map do |name, action|
10
+ method_name = build_method_name(name, action)
11
+ ResourceMethod.new.tap do |m|
12
+ m.method_name = method_name
13
+ m.arguments = 'options = {}'
14
+ m.code = code(action, api)
15
+ m.documentation = docs(method_name, resource_name, action, api)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def code(action, api)
23
+ ResourceBatchActionCode.new(action: action, api: api).build
24
+ end
25
+
26
+ def docs(method_name, resource_name, action, api)
27
+ ResourceBatchActionDocumentation.new(
28
+ method_name: method_name,
29
+ var_name: Underscore.underscore(resource_name),
30
+ action: action,
31
+ api: api
32
+ ).build
33
+ end
34
+
35
+ def build_method_name(name, action)
36
+ method_name = "batch_" + Underscore.underscore(name)
37
+ method_name += '!' if dangerous?(name, action)
38
+ method_name
39
+ end
40
+
41
+ def dangerous?(name, action)
42
+ if
43
+ name.match(/delete/i) ||
44
+ name.match(/terminate/i) ||
45
+ action['request']['operation'].match(/delete/i) ||
46
+ action['request']['operation'].match(/terminate/i)
47
+ then
48
+ true
49
+ else
50
+ false
51
+ end
52
+ end
53
+
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,136 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceBatchActionCode
5
+
6
+ def initialize(options)
7
+ @action = options.fetch(:action)
8
+ @api = options.fetch(:api)
9
+ compute_params
10
+ end
11
+
12
+ # @return [String]
13
+ def build
14
+ parts = []
15
+ parts << 'batch_enum.each do |batch|'
16
+ parts << initialize_params
17
+ parts << apply_params_per_batch
18
+ parts << " batch[0].client.#{client_method}(params)"
19
+ parts << 'end'
20
+ parts << 'nil'
21
+ parts.join("\n").rstrip
22
+ end
23
+
24
+ private
25
+
26
+ def compute_params
27
+ @batch_obj = {}
28
+ @per_batch = {}
29
+ @action_prefix = false
30
+ @action['request']['params'].each do |param|
31
+ if param['target'].include?('[')
32
+ parts = param['target'].split('[')
33
+ pair = parts[0].split('.')
34
+ if pair.length > 1
35
+ @action_prefix = pair.first
36
+ end
37
+ batch_name = pair.last
38
+ batch_param = underscore(parts[1].sub(/.*?\./, ''))
39
+ batch_param = batch_param == "" ? underscore(param['name']) : batch_param
40
+ (@batch_obj[batch_name] ||= []) << {
41
+ batch_param.to_sym => underscore(param['name'] || param['path'])
42
+ }
43
+ else
44
+ @per_batch[param['target']] = underscore(param['name'])
45
+ end
46
+ end
47
+ end
48
+
49
+ def client_method
50
+ Underscore.underscore(@action['request']['operation'])
51
+ end
52
+
53
+ def initialize_params
54
+ param_block = []
55
+ param_block << " params = Aws::Util.copy_hash(options)"
56
+ param_block << apply_param_hash
57
+ param_block.join("\n")
58
+ end
59
+
60
+ def apply_param_hash
61
+ block = []
62
+ @per_batch.each do |key, value|
63
+ block << " params[:#{underscore(key)}] = batch[0].#{value}"
64
+ end
65
+ if @action_prefix
66
+ action = underscore(@action_prefix)
67
+ block << " params[:#{action}] ||= {}"
68
+ @batch_obj.keys.each do |key|
69
+ block << " params[:#{action}][:#{underscore(key)}] ||= []"
70
+ end
71
+ else
72
+ @batch_obj.keys.each {|key| block << " params[:#{underscore(key)}] ||= []"}
73
+ end
74
+ block.join("\n")
75
+ end
76
+
77
+ def apply_params_per_batch
78
+ each_batch = []
79
+ each_batch << " batch.each do |item|"
80
+ @batch_obj.each do |key, value|
81
+ hash = {}
82
+ value.each do |v|
83
+ param, identifier = v.first
84
+ hash[param.to_sym] = "item.#{identifier}"
85
+ end
86
+ first_line = @action_prefix ? " params[:#{underscore(@action_prefix)}][:#{underscore(key)}] << "
87
+ : " params[:#{underscore(key)}] << "
88
+ if list_of_string?(key, @action['request']['operation'])
89
+ _, v = hash.first
90
+ each_batch << first_line + v
91
+ else
92
+ each_batch << first_line + "{"
93
+ # hashformatter treats this as inline, need extra indent
94
+ indent_count = hash.size == 1 ? 3 : 2
95
+ each_batch << indent_helper(HashFormatter.new(wrap: false).format(hash), indent_count)
96
+ each_batch << " }"
97
+ end
98
+ end
99
+ each_batch << " end"
100
+ each_batch.join("\n")
101
+ end
102
+
103
+ def indent_helper(lines, count)
104
+ block = []
105
+ lines.split("\n").each do |line|
106
+ next if line.strip == ""
107
+ block << " " * count + line
108
+ end
109
+ block.join("\n")
110
+ end
111
+
112
+ def underscore(str)
113
+ Underscore.underscore(str)
114
+ end
115
+
116
+ def list_of_string?(member, operation_name)
117
+ operation_shape = @api['operations'][operation_name]
118
+ input_shape = @api['shapes'][operation_shape['input']['shape']]
119
+
120
+ members = input_shape['type'] == 'structure' ? 'members' : 'member'
121
+ if @action_prefix
122
+ prefix_shape_ref = input_shape[members][@action_prefix]
123
+ _, prefix_shape = Api.resolve(prefix_shape_ref, @api)
124
+ prefix_members = prefix_shape['type'] == 'structure' ? 'members' : 'member'
125
+ member_shape_ref = prefix_shape[prefix_members][member]
126
+ else
127
+ member_shape_ref = input_shape[members][member]
128
+ end
129
+ _, shape = Api.resolve(member_shape_ref, @api)
130
+ return false unless shape['type'] == 'list'
131
+ _, item_shape = Api.resolve(shape['member'], @api)
132
+ item_shape['type'] == 'string'
133
+ end
134
+
135
+ end
136
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ class ResourceBatchActionDocumentation
5
+
6
+ def initialize(options)
7
+ @var_name = options.fetch(:var_name)
8
+ @method_name = options.fetch(:method_name)
9
+ @action = options.fetch(:action)
10
+ @api = options.fetch(:api)
11
+ compute_params
12
+ end
13
+
14
+ # @return [String]
15
+ def build
16
+ Docstring.join_docstrings([
17
+ request_syntax_example,
18
+ '# @param options ({})',
19
+ option_tags,
20
+ "# @return [void]",
21
+ ], block_comment: false, separator: false)
22
+ end
23
+
24
+ private
25
+
26
+ def request_syntax_example
27
+ if input_ref
28
+ SyntaxExample.new(
29
+ api: @api,
30
+ shape: input_shape,
31
+ method_name: @method_name,
32
+ receiver: @var_name,
33
+ resp_var: nil,
34
+ skip: skip_params
35
+ ).format
36
+ end
37
+ end
38
+
39
+ def skip_params
40
+ skip = []
41
+ if @action_prefix
42
+ skip << @action_prefix
43
+ else
44
+ skip += @per_batch.keys
45
+ skip += @batch_obj.keys
46
+ end
47
+ skip + ResourceSkipParams.compute(input_shape, @action['request'])
48
+ end
49
+
50
+ def option_tags
51
+ skip = skip_params
52
+ if input_shape = Api.shape(input_ref, @api)
53
+ input_shape['members'].map do |member_name, member_ref|
54
+ if skip.include?(member_name)
55
+ nil # skipped
56
+ else
57
+ YardOptionTag.new(
58
+ name: Underscore.underscore(member_name),
59
+ required: input_shape.fetch('required', []).include?(member_name),
60
+ ruby_type: Api.ruby_input_type(member_ref, @api),
61
+ docstring: Docstring.html_to_markdown(Api.docstring(member_ref, @api)),
62
+ ).to_str
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def input_ref
69
+ @api['operations'][@action['request']['operation']]['input']
70
+ end
71
+
72
+ def input_shape
73
+ Api.shape(input_ref, @api)
74
+ end
75
+
76
+ def compute_params
77
+ @batch_obj = {}
78
+ @per_batch = {}
79
+ @action_prefix = false
80
+ @action['request']['params'].each do |param|
81
+ if param['target'].include?('[')
82
+ parts = param['target'].split('[')
83
+ pair = parts[0].split('.')
84
+ if pair.length > 1
85
+ @action_prefix = pair.first
86
+ end
87
+ batch_name = pair.last
88
+ batch_param = underscore(parts[1].sub(/.*?\./, ''))
89
+ batch_param = batch_param == "" ? underscore(param['name']) : batch_param
90
+ (@batch_obj[batch_name] ||= []) << {
91
+ batch_param.to_sym => underscore(param['name'] || param['path'])
92
+ }
93
+ else
94
+ @per_batch[param['target']] = underscore(param['name'])
95
+ end
96
+ end
97
+ end
98
+
99
+ def client_method
100
+ underscore(@action['request']['operation'])
101
+ end
102
+
103
+ def underscore(str)
104
+ Underscore.underscore(str)
105
+ end
106
+
107
+ end
108
+ end