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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/lib/aws-sdk-code-generator/api.rb +150 -0
  3. data/lib/aws-sdk-code-generator/apply_docs.rb +15 -2
  4. data/lib/aws-sdk-code-generator/client_constructor.rb +39 -0
  5. data/lib/aws-sdk-code-generator/client_operation_documentation.rb +282 -0
  6. data/lib/aws-sdk-code-generator/client_operation_list.rb +148 -0
  7. data/lib/aws-sdk-code-generator/client_response_structure_example.rb +115 -0
  8. data/lib/aws-sdk-code-generator/code_builder.rb +146 -133
  9. data/lib/aws-sdk-code-generator/crosslink.rb +42 -0
  10. data/lib/aws-sdk-code-generator/docstring.rb +199 -0
  11. data/lib/aws-sdk-code-generator/error_list.rb +77 -0
  12. data/lib/aws-sdk-code-generator/errors.rb +2 -0
  13. data/lib/aws-sdk-code-generator/eventstream_example.rb +220 -0
  14. data/lib/aws-sdk-code-generator/gem_builder.rb +42 -25
  15. data/lib/aws-sdk-code-generator/hash_formatter.rb +5 -2
  16. data/lib/aws-sdk-code-generator/helper.rb +86 -119
  17. data/lib/aws-sdk-code-generator/plugin_list.rb +147 -0
  18. data/lib/aws-sdk-code-generator/resource_action.rb +69 -0
  19. data/lib/aws-sdk-code-generator/resource_action_code.rb +57 -0
  20. data/lib/aws-sdk-code-generator/resource_association.rb +37 -0
  21. data/lib/aws-sdk-code-generator/resource_attribute.rb +76 -0
  22. data/lib/aws-sdk-code-generator/resource_batch_action.rb +56 -0
  23. data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +136 -0
  24. data/lib/aws-sdk-code-generator/resource_batch_action_documentation.rb +108 -0
  25. data/lib/aws-sdk-code-generator/resource_batch_builder.rb +212 -0
  26. data/lib/aws-sdk-code-generator/resource_builder.rb +48 -0
  27. data/lib/aws-sdk-code-generator/resource_client_request.rb +62 -0
  28. data/lib/aws-sdk-code-generator/resource_client_request_documentation.rb +81 -0
  29. data/lib/aws-sdk-code-generator/resource_client_request_params.rb +86 -0
  30. data/lib/aws-sdk-code-generator/resource_data_method.rb +60 -0
  31. data/lib/aws-sdk-code-generator/resource_has_association.rb +117 -0
  32. data/lib/aws-sdk-code-generator/resource_has_many_association.rb +52 -0
  33. data/lib/aws-sdk-code-generator/resource_has_many_association_code.rb +76 -0
  34. data/lib/aws-sdk-code-generator/resource_identifier.rb +44 -0
  35. data/lib/aws-sdk-code-generator/resource_identifiers_method.rb +29 -0
  36. data/lib/aws-sdk-code-generator/resource_load_method.rb +68 -0
  37. data/lib/aws-sdk-code-generator/resource_method.rb +22 -0
  38. data/lib/aws-sdk-code-generator/resource_skip_params.rb +36 -0
  39. data/lib/aws-sdk-code-generator/resource_value_source.rb +68 -0
  40. data/lib/aws-sdk-code-generator/resource_waiter.rb +80 -0
  41. data/lib/aws-sdk-code-generator/service.rb +30 -7
  42. data/lib/aws-sdk-code-generator/shared_example.rb +131 -0
  43. data/lib/aws-sdk-code-generator/syntax_example.rb +60 -0
  44. data/lib/aws-sdk-code-generator/syntax_example_hash.rb +174 -0
  45. data/lib/aws-sdk-code-generator/underscore.rb +10 -5
  46. data/lib/aws-sdk-code-generator/view.rb +33 -0
  47. data/lib/aws-sdk-code-generator/views/apig_endpoint_class.rb +25 -0
  48. data/lib/aws-sdk-code-generator/views/apig_readme.rb +32 -0
  49. data/lib/aws-sdk-code-generator/views/async_client_class.rb +68 -0
  50. data/lib/aws-sdk-code-generator/views/authorizer_class.rb +17 -0
  51. data/lib/aws-sdk-code-generator/views/client_api_module.rb +602 -0
  52. data/lib/aws-sdk-code-generator/views/client_class.rb +93 -0
  53. data/lib/aws-sdk-code-generator/views/docstring.rb +27 -0
  54. data/lib/aws-sdk-code-generator/views/errors_module.rb +32 -0
  55. data/lib/aws-sdk-code-generator/views/event_streams_module.rb +149 -0
  56. data/lib/aws-sdk-code-generator/views/features/env.rb +9 -0
  57. data/lib/aws-sdk-code-generator/views/features/smoke.rb +52 -0
  58. data/lib/aws-sdk-code-generator/views/features/smoke_step_definitions.rb +26 -0
  59. data/lib/aws-sdk-code-generator/views/features/step_definitions.rb +6 -2
  60. data/lib/aws-sdk-code-generator/views/gemspec.rb +39 -5
  61. data/lib/aws-sdk-code-generator/views/resource_class.rb +122 -0
  62. data/lib/aws-sdk-code-generator/views/root_resource_class.rb +58 -0
  63. data/lib/aws-sdk-code-generator/views/service_module.rb +38 -14
  64. data/lib/aws-sdk-code-generator/views/spec/spec_helper.rb +9 -0
  65. data/lib/aws-sdk-code-generator/views/types_module.rb +329 -0
  66. data/lib/aws-sdk-code-generator/views/version.rb +2 -0
  67. data/lib/aws-sdk-code-generator/views/waiters_module.rb +37 -0
  68. data/lib/aws-sdk-code-generator/views.rb +2 -0
  69. data/lib/aws-sdk-code-generator/waiter.rb +95 -0
  70. data/lib/aws-sdk-code-generator/yard_option_tag.rb +43 -0
  71. data/lib/aws-sdk-code-generator.rb +68 -75
  72. data/templates/apig_endpoint_class.mustache +16 -0
  73. data/templates/apig_readme.mustache +62 -0
  74. data/templates/async_client_class.mustache +125 -0
  75. data/templates/authorizer_class.mustache +37 -0
  76. data/templates/client_api_module.mustache +106 -0
  77. data/templates/client_class.mustache +295 -0
  78. data/templates/code.mustache +4 -0
  79. data/templates/documentation.mustache +4 -0
  80. data/templates/errors_module.mustache +70 -0
  81. data/templates/event_streams_module.mustache +76 -0
  82. data/templates/features/env.mustache +15 -0
  83. data/templates/features/smoke.mustache +22 -0
  84. data/templates/features/smoke_step_definitions.mustache +31 -0
  85. data/templates/features/step_definitions.mustache +13 -0
  86. data/templates/gemspec.mustache +31 -0
  87. data/templates/license.txt +202 -0
  88. data/templates/method.mustache +7 -0
  89. data/templates/resource_class.mustache +304 -0
  90. data/templates/root_resource_class.mustache +51 -0
  91. data/templates/service_module.mustache +58 -0
  92. data/templates/spec/spec_helper.mustache +15 -0
  93. data/templates/types_module.mustache +53 -0
  94. data/templates/version.mustache +1 -0
  95. data/templates/waiters_module.mustache +112 -0
  96. metadata +115 -70
  97. data/lib/aws-sdk-code-generator/dsl/access_control_statement.rb +0 -23
  98. data/lib/aws-sdk-code-generator/dsl/attribute_accessor.rb +0 -43
  99. data/lib/aws-sdk-code-generator/dsl/attribute_reader.rb +0 -11
  100. data/lib/aws-sdk-code-generator/dsl/attribute_writer.rb +0 -11
  101. data/lib/aws-sdk-code-generator/dsl/autoload_statement.rb +0 -15
  102. data/lib/aws-sdk-code-generator/dsl/block_param.rb +0 -11
  103. data/lib/aws-sdk-code-generator/dsl/class.rb +0 -27
  104. data/lib/aws-sdk-code-generator/dsl/code_literal.rb +0 -66
  105. data/lib/aws-sdk-code-generator/dsl/code_object.rb +0 -33
  106. data/lib/aws-sdk-code-generator/dsl/docstring.rb +0 -36
  107. data/lib/aws-sdk-code-generator/dsl/eigenclass.rb +0 -15
  108. data/lib/aws-sdk-code-generator/dsl/extend_statement.rb +0 -12
  109. data/lib/aws-sdk-code-generator/dsl/formatter.rb +0 -25
  110. data/lib/aws-sdk-code-generator/dsl/include_statement.rb +0 -17
  111. data/lib/aws-sdk-code-generator/dsl/main.rb +0 -105
  112. data/lib/aws-sdk-code-generator/dsl/method.rb +0 -108
  113. data/lib/aws-sdk-code-generator/dsl/module.rb +0 -167
  114. data/lib/aws-sdk-code-generator/dsl/option_tag.rb +0 -36
  115. data/lib/aws-sdk-code-generator/dsl/param.rb +0 -43
  116. data/lib/aws-sdk-code-generator/dsl/param_list.rb +0 -38
  117. data/lib/aws-sdk-code-generator/dsl/return_tag.rb +0 -19
  118. data/lib/aws-sdk-code-generator/dsl/tag_default.rb +0 -20
  119. data/lib/aws-sdk-code-generator/dsl/tag_docstring.rb +0 -27
  120. data/lib/aws-sdk-code-generator/dsl/tag_type.rb +0 -18
  121. data/lib/aws-sdk-code-generator/generators/client_api_module.rb +0 -334
  122. data/lib/aws-sdk-code-generator/generators/client_class.rb +0 -389
  123. data/lib/aws-sdk-code-generator/generators/client_operation_documentation.rb +0 -166
  124. data/lib/aws-sdk-code-generator/generators/errors_module.rb +0 -25
  125. data/lib/aws-sdk-code-generator/generators/resource/action.rb +0 -88
  126. data/lib/aws-sdk-code-generator/generators/resource/batch_builder.rb +0 -211
  127. data/lib/aws-sdk-code-generator/generators/resource/builder.rb +0 -50
  128. data/lib/aws-sdk-code-generator/generators/resource/client_getter.rb +0 -15
  129. data/lib/aws-sdk-code-generator/generators/resource/client_request.rb +0 -49
  130. data/lib/aws-sdk-code-generator/generators/resource/client_request_docs.rb +0 -97
  131. data/lib/aws-sdk-code-generator/generators/resource/client_request_params.rb +0 -88
  132. data/lib/aws-sdk-code-generator/generators/resource/collection_class.rb +0 -180
  133. data/lib/aws-sdk-code-generator/generators/resource/data_attribute_getter.rb +0 -24
  134. data/lib/aws-sdk-code-generator/generators/resource/data_loaded_method.rb +0 -18
  135. data/lib/aws-sdk-code-generator/generators/resource/data_method.rb +0 -49
  136. data/lib/aws-sdk-code-generator/generators/resource/exists_method.rb +0 -29
  137. data/lib/aws-sdk-code-generator/generators/resource/extract_identifier_method.rb +0 -32
  138. data/lib/aws-sdk-code-generator/generators/resource/has_association.rb +0 -101
  139. data/lib/aws-sdk-code-generator/generators/resource/has_many_association.rb +0 -108
  140. data/lib/aws-sdk-code-generator/generators/resource/identifier_getter.rb +0 -26
  141. data/lib/aws-sdk-code-generator/generators/resource/identifiers_method.rb +0 -28
  142. data/lib/aws-sdk-code-generator/generators/resource/initialize_method.rb +0 -67
  143. data/lib/aws-sdk-code-generator/generators/resource/load_method.rb +0 -65
  144. data/lib/aws-sdk-code-generator/generators/resource/value_source.rb +0 -68
  145. data/lib/aws-sdk-code-generator/generators/resource/waiter_method.rb +0 -61
  146. data/lib/aws-sdk-code-generator/generators/resource_class.rb +0 -325
  147. data/lib/aws-sdk-code-generator/generators/response_structure_example.rb +0 -83
  148. data/lib/aws-sdk-code-generator/generators/root_resource_class.rb +0 -42
  149. data/lib/aws-sdk-code-generator/generators/service_documentation.rb +0 -64
  150. data/lib/aws-sdk-code-generator/generators/shared_example.rb +0 -132
  151. data/lib/aws-sdk-code-generator/generators/structure_type_class.rb +0 -95
  152. data/lib/aws-sdk-code-generator/generators/syntax_example.rb +0 -169
  153. data/lib/aws-sdk-code-generator/generators/types_module.rb +0 -52
  154. data/lib/aws-sdk-code-generator/generators/waiter_class.rb +0 -62
  155. data/lib/aws-sdk-code-generator/generators/waiters_module.rb +0 -20
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class ClientClass < View
6
+
7
+ # @option options [required, String] :service_identifier
8
+ # @option options [required, String] :service_name
9
+ # @option options [required, String] :module_name
10
+ # @option options [required, String] :gem_name
11
+ # @option options [required, String] :gem_version
12
+ # @option options [required, String] :aws_sdk_core_lib_path
13
+ # @option options [required, String] :protocol
14
+ # @option options [required, String] :signature_version
15
+ # @option options [required, Boolean] :endpoint_discovery_required
16
+ # @option options [required, Hash] :add_plugins
17
+ # @option options [required, Array] :remove_plugins
18
+ # @option options [required, Hash] :api
19
+ # @option options [Hash] :waiters
20
+ # @option options [Hash] :client_examples
21
+ def initialize(options)
22
+ @service_identifier = options.fetch(:service_identifier)
23
+ @service_name = options.fetch(:service_name)
24
+ @module_name = options.fetch(:module_name)
25
+ @gem_name = options.fetch(:gem_name)
26
+ @gem_version = options.fetch(:gem_version)
27
+ @plugins = PluginList.new(options)
28
+ @client_constructor = ClientConstructor.new(options.merge(plugins: @plugins))
29
+ @operations = ClientOperationList.new(options).to_a
30
+ @waiters = Waiter.build_list(options[:waiters])
31
+ @custom = options.fetch(:custom)
32
+ end
33
+
34
+ # @return [String]
35
+ attr_reader :service_identifier
36
+
37
+ # @return [String]
38
+ attr_reader :service_name
39
+
40
+ # @return [String]
41
+ attr_reader :module_name
42
+
43
+ # @return [String]
44
+ attr_reader :gem_name
45
+
46
+ # @return [String]
47
+ attr_reader :gem_version
48
+
49
+ # @return [ClientConstructor]
50
+ attr_reader :client_constructor
51
+
52
+ # @return [Array<Operation>]
53
+ attr_reader :operations
54
+
55
+ # @return [String|nil]
56
+ def generated_src_warning
57
+ return if @custom
58
+ GENERATED_SRC_WARNING
59
+ end
60
+
61
+ # @return [Array<String>]
62
+ def plugin_requires
63
+ @plugins.map(&:require_path)
64
+ end
65
+
66
+ # @return [Array<String>]
67
+ def plugin_class_names
68
+ @plugins.map(&:class_name)
69
+ end
70
+
71
+ # @return [Array<Waiter>]
72
+ def waiters
73
+ @waiters
74
+ end
75
+
76
+ # @return [Boolean]
77
+ def waiters?
78
+ @waiters.size > 0
79
+ end
80
+
81
+ # @return [String<Markdown>]
82
+ def waiters_markdown_table
83
+ Waiter.markdown_table(@waiters)
84
+ end
85
+
86
+ # @return [Boolean]
87
+ def authorizer?
88
+ @custom
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+
5
+ module AwsSdkCodeGenerator
6
+ module Views
7
+ class BlockComment < View
8
+
9
+ # @param [String, nil] text
10
+ def initialize(text)
11
+ @text = text
12
+ end
13
+
14
+ # @return [Array<String>]
15
+ def lines
16
+ @text.to_s.lines.map do |line|
17
+ if line == "\n"
18
+ "#"
19
+ else
20
+ "# #{line}"
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class ErrorsModule < View
6
+
7
+ # @option options [required, Service] :service
8
+ def initialize(options)
9
+ @service = options.fetch(:service)
10
+ @service_name = @service.name
11
+ @errors = ErrorList.new(api: @service.api, module_name: module_name).to_a
12
+ end
13
+
14
+ # @return [Array<Error>]
15
+ attr_reader :errors
16
+
17
+ # @return [String]
18
+ attr_reader :service_name
19
+
20
+ # @return [String|nil]
21
+ def generated_src_warning
22
+ return if @service.protocol == 'api-gateway'
23
+ GENERATED_SRC_WARNING
24
+ end
25
+
26
+ def module_name
27
+ @service.module_name
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,149 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class EventStreamsModule < View
6
+
7
+ include Helper
8
+
9
+ def initialize(options)
10
+ @service = options.fetch(:service)
11
+ input, output = extract_eventstreams
12
+ @input_eventstreams = input
13
+ @output_eventstreams = output
14
+ end
15
+
16
+ # @return [Array<EventStreamClass>]
17
+ attr_reader :input_eventstreams
18
+
19
+ # @return [Array<EventStreamClass>]
20
+ attr_reader :output_eventstreams
21
+
22
+ # @return [String|nil]
23
+ def generated_src_warning
24
+ return if @service.protocol == 'api-gateway'
25
+ GENERATED_SRC_WARNING
26
+ end
27
+
28
+ def module_name
29
+ @service.module_name
30
+ end
31
+
32
+ def extract_eventstreams
33
+ es = []
34
+ @service.api['operations'].each do |_, ref|
35
+ pair = []
36
+ if input = ref['input']
37
+ input_shape = @service.api['shapes'][input['shape']]
38
+ input_shape['members'].each do |_, m_ref|
39
+ if @service.api['shapes'][m_ref['shape']]['eventstream']
40
+ shape = @service.api['shapes'][m_ref['shape']]
41
+ pair << {
42
+ class_name: m_ref['shape'],
43
+ event_entries: eventstream_members_w_doc(shape),
44
+ types: eventstream_members(shape)
45
+ }
46
+ end
47
+ end
48
+ end
49
+ # have a placeholder for input
50
+ pair << nil if pair.empty?
51
+ if output = ref['output']
52
+ output_shape = @service.api['shapes'][output['shape']]
53
+ output_shape['members'].each do |_, m_ref|
54
+ if @service.api['shapes'][m_ref['shape']]['eventstream']
55
+ shape = @service.api['shapes'][m_ref['shape']]
56
+ pair << {
57
+ class_name: m_ref['shape'],
58
+ types: eventstream_members(shape)
59
+ }
60
+ end
61
+ end
62
+ end
63
+ es << pair unless pair.compact.empty?
64
+ end
65
+ # rename eventstream when needed
66
+ input_es = []
67
+ output_es = []
68
+ es.each do |pair|
69
+ input, output = pair
70
+ # bidirectional and sharing same eventstream shape
71
+ if input && output && input[:class_name] == output[:class_name]
72
+ input[:class_name] = "Input" + input[:class_name]
73
+ output[:class_name] = "Output" + output[:class_name]
74
+ end
75
+ input_es << EventStreamClass.new(input) if input
76
+ output_es << EventStreamClass.new(output) if output
77
+ end
78
+ [input_es, output_es]
79
+ end
80
+
81
+ def eventstream_members(shape)
82
+ raise 'no event members for an eventstream' if shape['members'].nil?
83
+ shape['members'].keys.map {|m| underscore(m)}
84
+ end
85
+
86
+ def eventstream_members_w_doc(shape)
87
+ raise 'no event members for an eventstream' if shape['members'].nil?
88
+ shape['members'].inject([]) do |m, (n, ref)|
89
+ event_shape = @service.api['shapes'][ref['shape']]
90
+ option_tags = event_shape['members'].map do |member_name, member_ref|
91
+ next if member_ref['documented'] === false
92
+ docstring = Api.docstring(member_ref, @service.api)
93
+ YardOptionTag.new(
94
+ name: Underscore.underscore(member_name),
95
+ ruby_type: Api.ruby_input_type(member_ref, @service.api),
96
+ required: shape.fetch('required', []).include?(member_name),
97
+ docstring: Docstring.html_to_markdown(docstring),
98
+ option_hash_name: 'params',
99
+ ).to_s
100
+ end
101
+ param_hash_str = Docstring.join_docstrings([option_tags], block_comment: false)
102
+ m << EventEntry.new(
103
+ name: underscore(n),
104
+ param_hash: Docstring.indent(param_hash_str, ' ')
105
+ )
106
+ m
107
+ end
108
+ end
109
+
110
+ private
111
+
112
+ class EventEntry
113
+
114
+ def initialize(options)
115
+ @name = options.fetch(:name)
116
+ @param_hash = options.fetch(:param_hash)
117
+ end
118
+
119
+ # @return [String]
120
+ attr_reader :name
121
+
122
+ # @return [String]
123
+ attr_reader :param_hash
124
+
125
+ end
126
+
127
+ class EventStreamClass
128
+
129
+ def initialize(options)
130
+ @class_name = options.fetch(:class_name)
131
+ @types = options.fetch(:types)
132
+ @event_entries = options[:event_entries] || []
133
+ end
134
+
135
+ # @return [String]
136
+ attr_accessor :class_name
137
+
138
+ # @return [Array<String>]
139
+ attr_accessor :types
140
+
141
+ # @return [Array<EventEntry>]
142
+ attr_reader :event_entries
143
+
144
+ end
145
+
146
+ end
147
+ end
148
+ end
149
+
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AwsSdkCodeGenerator
2
4
  module Views
3
5
  module Features
@@ -12,12 +14,19 @@ module AwsSdkCodeGenerator
12
14
  @gem_dependencies = service.gem_dependencies.map do |gem_name, _|
13
15
  { dependency: gem_name }
14
16
  end
17
+ @custom = service.protocol == 'api-gateway'
15
18
  end
16
19
 
17
20
  attr_reader :gem_name
18
21
  attr_reader :module_name
19
22
  attr_reader :gem_dependencies
20
23
 
24
+ # @return [String|nil]
25
+ def generated_src_warning
26
+ return if @custom
27
+ GENERATED_SRC_WARNING
28
+ end
29
+
21
30
  end
22
31
  end
23
32
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ module Features
6
+ class Smoke < View
7
+
8
+ # @param [Hash] options
9
+ # @option options [required, Service] :service
10
+ def initialize(options)
11
+ service = options.fetch(:service)
12
+ @custom = service.protocol == 'api-gateway'
13
+ @service = service.name
14
+
15
+ # This will only be called if this is defined
16
+ smoke_json = service.smoke_tests
17
+ @client_region = smoke_json["defaultRegion"]
18
+ @client_endpoint = smoke_json["defaultEndpoint"]
19
+ @smoke_tests = smoke_json["testCases"].map do |test|
20
+ h = {
21
+ operation: underscore(test["operationName"]),
22
+ smoke_test_tags: "@#{service.identifier} @smoke",
23
+ }
24
+ if test["errorExpectedFromService"]
25
+ h[:error_expectation] = "I expect an error was raised"
26
+ h[:scenario_string] = "Call Aws::#{service.module_name}::Client##{h[:operation]} and expect it to fail"
27
+ else
28
+ h[:error_expectation] = "I expect an error was not raised"
29
+ h[:scenario_string] = "Call #{service.module_name}::Client##{h[:operation]} and expect it to succeed"
30
+ end
31
+ h[:param_hash] = test["input"].inject({}) do |acc, kv|
32
+ raw_key, value = kv
33
+ key = underscore(raw_key)
34
+ acc[key] = value
35
+ acc
36
+ end.to_json
37
+ h
38
+ end
39
+ end
40
+
41
+ attr_reader :service, :client_region, :client_endpoint, :smoke_tests
42
+
43
+ # @return [String|nil]
44
+ def generated_src_warning
45
+ return if @custom
46
+ GENERATED_SRC_WARNING
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ module Features
6
+ class SmokeStepDefinitions < View
7
+
8
+ # @param [Hash] options
9
+ # @option options [required, Service] :service
10
+ def initialize(options)
11
+ service = options.fetch(:service)
12
+ @module_name = service.module_name
13
+ end
14
+
15
+ attr_reader :module_name
16
+
17
+ # @return [String|nil]
18
+ def generated_src_warning
19
+ return if @custom
20
+ GENERATED_SRC_WARNING
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AwsSdkCodeGenerator
2
4
  module Views
3
5
  module Features
@@ -9,10 +11,12 @@ module AwsSdkCodeGenerator
9
11
  service = options.fetch(:service)
10
12
  @var_name = service.identifier
11
13
  @module_name = service.module_name
14
+ if service.smoke_tests
15
+ @client_endpoint = service.smoke_tests['defaultEndpoint']
16
+ end
12
17
  end
13
18
 
14
- attr_reader :var_name
15
- attr_reader :module_name
19
+ attr_reader :var_name, :module_name, :client_endpoint
16
20
 
17
21
  end
18
22
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AwsSdkCodeGenerator
2
4
  module Views
3
5
  class Gemspec < View
@@ -5,6 +7,13 @@ module AwsSdkCodeGenerator
5
7
  # @option options [required, Service] :service
6
8
  def initialize(options)
7
9
  @service = options.fetch(:service)
10
+ @custom = @service.protocol == 'api-gateway'
11
+ end
12
+
13
+ # @return [String|nil]
14
+ def generated_src_warning
15
+ return if @service.protocol == 'api-gateway'
16
+ GENERATED_SRC_WARNING
8
17
  end
9
18
 
10
19
  # @return [String]
@@ -12,21 +21,46 @@ module AwsSdkCodeGenerator
12
21
  @service.gem_name
13
22
  end
14
23
 
24
+ def author
25
+ @custom ? 'Author Name' : 'Amazon Web Services'
26
+ end
27
+
28
+ def homepage
29
+ @custom ? 'http://gem-homepage.com' : 'https://github.com/aws/aws-sdk-ruby'
30
+ end
31
+
32
+ def email
33
+ @custom ? 'yourname@email.com' : 'aws-dr-rubygems@amazon.com'
34
+ end
35
+
15
36
  # @return [String]
16
37
  def summary
17
- "AWS SDK for Ruby - #{@service.short_name}"
38
+ @custom ? @service.short_name : "AWS SDK for Ruby - #{@service.short_name}"
39
+ end
40
+
41
+ def metadata
42
+ @custom ? false : true
18
43
  end
19
44
 
20
45
  # @return [String]
21
46
  def description
22
- if @service.short_name != @service.full_name
23
- abbreviation = " (#{@service.short_name})"
47
+ if @custom
48
+ desc = "Gem Description"
49
+ else
50
+ if @service.short_name != @service.full_name
51
+ abbreviation = " (#{@service.short_name})"
52
+ end
53
+ desc = "Official AWS Ruby gem for #{@service.full_name}#{abbreviation}. "
54
+ desc += 'This gem is part of the AWS SDK for Ruby.'
24
55
  end
25
- desc = "Official AWS Ruby gem for #{@service.full_name}#{abbreviation}. "
26
- desc += 'This gem is part of the AWS SDK for Ruby.'
27
56
  desc
28
57
  end
29
58
 
59
+ # @return [String]
60
+ def code_uri
61
+ "https://github.com/aws/aws-sdk-ruby/tree/version-3/gems/#{gem_name}"
62
+ end
63
+
30
64
  # @return [Array<Dependency>]
31
65
  def dependencies
32
66
  @service.gem_dependencies.map do |gem, version|
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class ResourceClass < View
6
+
7
+ def initialize(options)
8
+ @module_name = options.fetch(:module_name)
9
+ @class_name = options.fetch(:class_name)
10
+ api = options.fetch(:api)
11
+ resource = options.fetch(:resource)
12
+ @identifiers = ResourceIdentifier.build_list(resource)
13
+ @identifiers_method = ResourceIdentifiersMethod.build(@identifiers)
14
+ @data_attributes = ResourceAttribute.build_list(resource, api)
15
+ @load_method = ResourceLoadMethod.build(@class_name, resource)
16
+ @data_method = ResourceDataMethod.build(@class_name, resource)
17
+ @client_load_method = Underscore.underscore(resource['load']['request']['operation']) if resource['load']
18
+ @data_class = "Types::#{resource['shape']}"
19
+ @waiters = ResourceWaiter.build_list(resource, options[:waiters])
20
+ @wait_until = options[:waiters] # add #wait_until method if service has waiters
21
+ @actions = ResourceAction.build_list(@class_name, resource, api)
22
+ @associations = build_associations(options)
23
+ @batch_actions = ResourceBatchAction.build_list(@class_name, resource, api)
24
+ @shape = resource['shape']
25
+ @custom = options.fetch(:custom)
26
+ end
27
+
28
+ # @return [String]
29
+ attr_reader :module_name
30
+
31
+ # @return [String]
32
+ attr_reader :class_name
33
+
34
+ # @return [Array<ResourceIdentifier>]
35
+ attr_reader :identifiers
36
+
37
+ # @return [String]
38
+ attr_reader :identifiers_method
39
+
40
+ # @return [Array<ResourceAttribute>]
41
+ attr_reader :data_attributes
42
+
43
+ # @return [String]
44
+ attr_reader :data_class
45
+
46
+ # @return [String]
47
+ attr_reader :load_method
48
+
49
+ # @return [String]
50
+ attr_reader :data_method
51
+
52
+ # @return [String, nil]
53
+ attr_reader :client_load_method
54
+
55
+ # @return [Array<Waiter>]
56
+ attr_reader :waiters
57
+
58
+ # @return [Boolean]
59
+ attr_reader :wait_until
60
+
61
+ # @return [Array<ResourceAction>]
62
+ attr_reader :actions
63
+
64
+ # @return [Array<ResourceAssociation>]
65
+ attr_reader :associations
66
+
67
+ # @return [Array<ResourceBatchAction>]
68
+ attr_reader :batch_actions
69
+
70
+ # @return [String, nil]
71
+ attr_reader :shape
72
+
73
+ # @return [String|nil]
74
+ def generated_src_warning
75
+ return if @custom
76
+ GENERATED_SRC_WARNING
77
+ end
78
+
79
+ # @return [Boolean]
80
+ def waiters?
81
+ !@waiters.empty?
82
+ end
83
+
84
+ # @return [ResoruceWiater, nil]
85
+ def exists_waiter
86
+ @waiters.find { |w| w.name == 'exists' }
87
+ end
88
+
89
+ # @return [Boolean]
90
+ def actions?
91
+ actions.size > 0
92
+ end
93
+
94
+ # @return [Boolean]
95
+ def associations?
96
+ associations.size > 0
97
+ end
98
+
99
+ # @return [Boolean]
100
+ def batch_actions?
101
+ batch_actions.size > 0
102
+ end
103
+
104
+ # @return [Boolean]
105
+ def identifiers?
106
+ @identifiers.size > 0
107
+ end
108
+
109
+ private
110
+
111
+ def build_associations(options)
112
+ ResourceAssociation.build_list(
113
+ class_name: options.fetch(:class_name),
114
+ resource: options.fetch(:resource),
115
+ api: options.fetch(:api),
116
+ paginators: options.fetch(:paginators)
117
+ )
118
+ end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Views
5
+ class RootResourceClass < View
6
+
7
+ def initialize(options)
8
+ @module_name = options.fetch(:module_name)
9
+ @service_name = options.fetch(:service_name)
10
+ class_name = @module_name.split('::').last
11
+ api = options.fetch(:api)
12
+ resource = (options[:resources] || {})['service'] || {}
13
+ @actions = ResourceAction.build_list(class_name, resource, api)
14
+ @associations = ResourceAssociation.build_list(
15
+ class_name: class_name,
16
+ resource: resource,
17
+ api: api,
18
+ paginators: options.fetch(:paginators)
19
+ )
20
+ @custom = options.fetch(:custom)
21
+ end
22
+
23
+ # @return [String]
24
+ attr_reader :module_name
25
+
26
+ # @return [Array<ResourceAction>]
27
+ attr_reader :actions
28
+
29
+ # @return [Array<ResourceAssociation>]
30
+ attr_reader :associations
31
+
32
+ # @return [String]
33
+ attr_reader :service_name
34
+
35
+ # @return [String|nil]
36
+ def generated_src_warning
37
+ return if @custom
38
+ GENERATED_SRC_WARNING
39
+ end
40
+
41
+ # @return [Boolean]
42
+ def actions?
43
+ actions.size > 0
44
+ end
45
+
46
+ # @return [Boolean]
47
+ def associations?
48
+ associations.size > 0
49
+ end
50
+
51
+ # @return [Boolean]
52
+ def documentation?
53
+ actions? || associations?
54
+ end
55
+
56
+ end
57
+ end
58
+ end