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,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+
5
+ module AwsSdkCodeGenerator
6
+ class ClientResponseStructureExample
7
+
8
+ ENUMERABLE_METHODS = Class.new.new.extend(Enumerable).methods - [:count]
9
+
10
+ # @option options [required, Hash] :shape_ref
11
+ # @option options [required, Hash] :api
12
+ def initialize(options = {})
13
+ @shape_ref = options.fetch(:shape_ref)
14
+ @api = options.fetch(:api)
15
+ end
16
+
17
+ def to_str
18
+ "@example Response structure\n\n #{entry(@shape_ref, 'resp', Set.new).join("\n ")}"
19
+ end
20
+ alias to_s to_str
21
+
22
+ private
23
+
24
+ def structure(ref, context, visited)
25
+ lines = []
26
+ shape = shape(ref)
27
+ if shape['eventstream']
28
+ event_types = []
29
+ # Add event entry
30
+ event_ctx = shape['members'].each.inject([]) do |ctx, (member_name, member_ref)|
31
+ event_type = Underscore.underscore(member_name).to_sym
32
+ event_types << event_type
33
+ ctx << "For #{event_type.inspect} event available at #on_#{event_type}_event callback"\
34
+ ' and response eventstream enumerator:'
35
+ event_entry = entry(member_ref, 'event', Set.new).join("\n ")
36
+ ctx << (event_entry.empty? ? ' #=> EmptyStruct' : event_entry + "\n")
37
+ end
38
+ # Add eventstream entry
39
+ event_ctx.unshift("#{context}.event_types #=> #{event_types.inspect}\n")
40
+ event_ctx.unshift("#{context} #=> Enumerator")
41
+ event_ctx.unshift("All events are available at #{context}:")
42
+ return event_ctx
43
+ elsif shape['members']
44
+ shape['members'].each_pair do |member_name, member_ref|
45
+ method_name = underscore(member_name)
46
+ if context == 'resp' && ENUMERABLE_METHODS.include?(method_name.to_sym)
47
+ lines += entry(member_ref, "#{context}.data.#{method_name}", visited)
48
+ else
49
+ lines += entry(member_ref, "#{context}.#{method_name}", visited)
50
+ end
51
+ end
52
+ end
53
+ lines
54
+ end
55
+
56
+ def list(ref, context, visited)
57
+ lines = []
58
+ lines << "#{context} #=> Array"
59
+ lines += entry(shape(ref)['member'], "#{context}[0]", visited)
60
+ lines
61
+ end
62
+
63
+ def map(ref, context, visited)
64
+ lines = []
65
+ lines << "#{context} #=> Hash"
66
+ lines += entry(shape(ref)['value'], "#{context}[#{map_key(ref)}]", visited)
67
+ lines
68
+ end
69
+
70
+ def map_key(ref)
71
+ shape(ref)['key']['shape'].inspect
72
+ end
73
+
74
+ def entry(ref, context, visited)
75
+ if ref['shape'] == 'AttributeValue'
76
+ return ["#{context} #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>"]
77
+ elsif visited.include?(ref['shape'])
78
+ return ["#{context} #=> Types::#{ref['shape']}"]
79
+ else
80
+ visited = visited + [ref['shape']]
81
+ end
82
+ case shape(ref)['type']
83
+ when 'structure' then structure(ref, context, visited)
84
+ when 'list' then list(ref, context, visited)
85
+ when 'map' then map(ref, context, visited)
86
+ else ["#{context} #=> #{type(ref)}"]
87
+ end
88
+ end
89
+
90
+ def type(ref)
91
+ if shape(ref)['type'] == 'string'
92
+ string(ref)
93
+ else
94
+ Api.ruby_type(ref, @api)
95
+ end
96
+ end
97
+
98
+ def string(ref)
99
+ if shape(ref)['enum']
100
+ "String, one of #{shape(ref)['enum'].map(&:inspect).join(', ')}"
101
+ else
102
+ 'String'
103
+ end
104
+ end
105
+
106
+ def shape(ref)
107
+ Api.shape(ref, @api)
108
+ end
109
+
110
+ def underscore(str)
111
+ Underscore.underscore(str)
112
+ end
113
+
114
+ end
115
+ end
@@ -1,23 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module AwsSdkCodeGenerator
2
4
  class CodeBuilder
3
5
 
4
- # @api private
5
- GENERATED_SRC_WARNING = <<-WARNING
6
- # WARNING ABOUT GENERATED CODE
7
- #
8
- # This file is generated. See the contributing for info on making contributions:
9
- # https://github.com/aws/aws-sdk-ruby/blob/master/CONTRIBUTING.md
10
- #
11
- # WARNING ABOUT GENERATED CODE
12
-
13
- WARNING
14
-
15
- include Helper
16
-
17
6
  # @option options [required, Service] :service
7
+ #
8
+ # @option options [required, String] :aws_sdk_core_lib_path
9
+ # Path to the lib directory for the source code of the
10
+ # AWS SDK for Ruby. This is needed so that documentation
11
+ # can be generated for default plugins and their options.
12
+ #
13
+ # @option options [Hash<String, Array<Hash>] :client_examples ({})
14
+ # A hash of client examples. Hash keys should be API operation method
15
+ # names (snake_cased). Hash values should be arrays of hashes.
16
+ # Each hash should contain the following keys:
17
+ #
18
+ # * `:name` - The name of the example
19
+ # * `:code` - The Ruby example code
20
+ #
18
21
  def initialize(options)
19
22
  @service = options.fetch(:service)
20
- # TODO : remove these
23
+ @aws_sdk_core_lib_path = options.fetch(:aws_sdk_core_lib_path)
24
+ @client_examples = options.fetch(:client_examples, {})
21
25
  @add_plugins = @service.add_plugins
22
26
  @remove_plugins = @service.remove_plugins
23
27
  @gem_dependencies = @service.gem_dependencies
@@ -29,38 +33,52 @@ module AwsSdkCodeGenerator
29
33
  @examples = @service.examples
30
34
  end
31
35
 
36
+ # Generates the source for a library as a single string.
37
+ # @return [String<code>]
38
+ # @api private
32
39
  def source
33
- svc_mod = new_svc_module
34
- @gem_dependencies.each { |gem_name, _| svc_mod.require(gem_name) }
35
- svc_mod.docstring(service_docstring)
36
- each_module do |mod, _|
37
- svc_mod.add(mod)
40
+ code = @gem_dependencies.map { |gem_name, _| "require '#{gem_name}'" }
41
+ source_files.each.with_index do |(file_name, src_code), n|
42
+ # skip the service module and customizations
43
+ next if file_name.include? '/customizations.rb'
44
+ next unless file_name.include? '/'
45
+ # skip markdown files
46
+ next if file_name.include? 'README.md'
47
+ code << src_code
38
48
  end
39
- @callback.call(svc_mod) if @callback
40
- svc_mod.root.to_s
49
+ code.join("\n")
41
50
  end
42
51
 
43
- # @option options [String] :prefix
44
52
  # @return [Enumerable<String<path>, String<code>>]
45
53
  def source_files(options = {})
46
- prefix = options.fetch(:prefix, nil)
47
- prefix ||= @module_names.map { |n| underscore(n) }.join('/')
48
- # prefix should always be the gemname. The service-module (the first
49
- # item yielded below) should be moved from here into the gem builder
50
- # The source code builder should simply yield the empty module
54
+ prefix = options.fetch(:prefix, @service.gem_name)
51
55
  Enumerator.new do |y|
52
- y.yield("#{prefix}.rb", Views::ServiceModule.new(service: @service, prefix: prefix).render)
53
- y.yield("#{prefix}/customizations.rb", '')
54
- each_module do |mod, type, code|
55
- case type
56
- when :unwrapped
57
- filename = File.join(prefix, underscore(mod.name) + '.rb')
58
- y.yield(filename, GENERATED_SRC_WARNING + wrap(mod))
59
- when :wrapped # dsl module
60
- filename = File.join(prefix, underscore(mod.name) + '.rb')
61
- y.yield(filename, GENERATED_SRC_WARNING + mod.root.to_s)
62
- else
63
- raise "expected :wrapped or :unwrapped"
56
+ if @service.protocol == 'api-gateway'
57
+ y.yield("#{prefix}/../../README.md", apig_readme)
58
+ y.yield("#{prefix}/plugins/authorizer.rb", authorizer_class)
59
+ y.yield("#{prefix}/plugins/apig_endpoint.rb", apig_endpoint_class)
60
+ end
61
+ y.yield("#{prefix}.rb", service_module(prefix))
62
+ unless %w[aws-sdk-sts aws-sdk-sso].include? prefix
63
+ y.yield("#{prefix}/customizations.rb", '')
64
+ end
65
+ y.yield("#{prefix}/types.rb", types_module)
66
+ if has_eventstream
67
+ y.yield("#{prefix}/event_streams.rb", event_streams_module)
68
+ end
69
+ y.yield("#{prefix}/client_api.rb", client_api_module)
70
+ y.yield("#{prefix}/client.rb", client_class)
71
+ if @service.protocol_settings['h2'] == 'eventstream'
72
+ y.yield("#{prefix}/async_client.rb", async_client_class)
73
+ end
74
+ y.yield("#{prefix}/errors.rb", errors_module)
75
+ y.yield("#{prefix}/waiters.rb", waiters_module) if @waiters
76
+ y.yield("#{prefix}/resource.rb", root_resource_class)
77
+ if @resources
78
+ @resources['resources'].keys.sort.each do |name|
79
+ path = "#{prefix}/#{Underscore.underscore(name)}.rb"
80
+ code = resource_class(name, @resources['resources'][name])
81
+ y.yield(path, code)
64
82
  end
65
83
  end
66
84
  end
@@ -68,134 +86,129 @@ module AwsSdkCodeGenerator
68
86
 
69
87
  private
70
88
 
71
- def each_module(&block)
72
- yield(types_module, :unwrapped)
73
- yield(client_api_module, :unwrapped)
74
- yield(client_class, :wrapped)
75
- yield(errors_module, :unwrapped)
76
- yield(waiters_module, :wrapped) if @waiters
77
- yield(root_resource_class, :unwrapped)
78
- if @resources
79
- @resources['resources'].keys.sort.each do |name|
80
- yield(resource_class(name, @resources['resources'][name]), :unwrapped)
81
- end
82
- end
89
+ def service_module(prefix)
90
+ Views::ServiceModule.new(service: @service, prefix: prefix).render
83
91
  end
84
92
 
85
- def new_svc_module
86
- @module_names.inject(Dsl::Main.new) do |mod, module_name|
87
- mod.module(module_name)
88
- end
93
+ def types_module
94
+ Views::TypesModule.new(service: @service).render
89
95
  end
90
96
 
91
- def wrap(mod)
92
- svc_mod = new_svc_module
93
- svc_mod.add(mod)
94
- svc_mod.root.to_s
97
+ def event_streams_module
98
+ Views::EventStreamsModule.new(service: @service).render
95
99
  end
96
100
 
97
- def service_module(autoload_prefix)
98
- autoloads = Generators::ServiceAutoloads.new(
99
- prefix: autoload_prefix,
100
- resources: @resources,
101
- waiters: !!@waiters
102
- )
103
- svc_mod = new_svc_module
104
- @gem_dependencies.each { |gem_name, _| svc_mod.require(gem_name) }
105
- svc_mod.docstring(service_docstring)
106
- svc_mod.code("GEM_VERSION = '#{@service.gem_version}'")
107
- autoloads.apply(svc_mod)
108
- @callback.call(svc_mod) if @callback
109
- svc_mod.root.to_s
101
+ def client_api_module
102
+ Views::ClientApiModule.new(service: @service).render
110
103
  end
111
104
 
112
- def types_module
113
- Generators::TypesModule.new(api: @api)
105
+ def client_class
106
+ Views::ClientClass.new(
107
+ service_identifier: @service.identifier,
108
+ service_name: @service.name,
109
+ protocol_settings: @service.protocol_settings,
110
+ module_name: @service.module_name,
111
+ gem_name: @service.gem_name,
112
+ gem_version: @service.gem_version,
113
+ aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
114
+ client_examples: @client_examples,
115
+ protocol: @service.protocol,
116
+ signature_version: @service.signature_version,
117
+ require_endpoint_discovery: @service.require_endpoint_discovery,
118
+ add_plugins: @service.add_plugins,
119
+ remove_plugins: @service.remove_plugins,
120
+ api: @service.api,
121
+ paginators: @service.paginators,
122
+ waiters: @service.waiters,
123
+ examples: @service.examples,
124
+ custom: @service.protocol == 'api-gateway'
125
+ ).render
126
+ end
127
+
128
+ def async_client_class
129
+ Views::AsyncClientClass.new(
130
+ service_identifier: @service.identifier,
131
+ service_name: @service.name,
132
+ protocol_settings: @service.protocol_settings,
133
+ module_name: @service.module_name,
134
+ gem_name: @service.gem_name,
135
+ gem_version: @service.gem_version,
136
+ aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
137
+ protocol: @service.protocol,
138
+ signature_version: @service.signature_version,
139
+ add_plugins: @service.add_plugins,
140
+ remove_plugins: @service.remove_plugins,
141
+ api: @service.api,
142
+ async_client: true
143
+ ).render
114
144
  end
115
145
 
116
- def client_api_module
117
- Generators::ClientApiModule.new(api: @api, paginators:@paginators)
146
+ def errors_module
147
+ Views::ErrorsModule.new(service: @service).render
118
148
  end
119
149
 
120
- def client_class(svc_mod = new_svc_module)
121
- klass = Generators::ClientClass.new(
122
- parent: svc_mod,
123
- identifier: @module_names.last.downcase,
124
- api: @api,
150
+ def waiters_module
151
+ Views::WaitersModule.new(
152
+ module_name: @service.module_name,
125
153
  waiters: @waiters,
126
- examples: @examples,
127
- add_plugins: @add_plugins,
128
- remove_plugins: @remove_plugins,
129
- gem_name: @service.gem_name,
130
- gem_version: @service.gem_version,
131
- )
132
- svc_mod.add(klass)
133
- klass
154
+ custom: @service.protocol == 'api-gateway'
155
+ ).render
134
156
  end
135
157
 
136
- def errors_module
137
- Generators::ErrorsModule.new(api: @api)
158
+ def authorizer_class
159
+ Views::AuthorizerClass.new(
160
+ module_name: @service.module_name
161
+ ).render
138
162
  end
139
163
 
140
- def waiters_module(svc_mod = new_svc_module)
141
- klass = Generators::WaitersModule.new(
142
- parent: svc_mod,
143
- waiters: @waiters
144
- )
145
- svc_mod.add(klass)
146
- klass
164
+ def apig_endpoint_class
165
+ Views::APIGEndpointClass.new(
166
+ module_name: @service.module_name,
167
+ default_endpoint: @service.default_endpoint
168
+ ).render
147
169
  end
148
170
 
149
171
  def root_resource_class
150
- Generators::RootResourceClass.new({
151
- api: @api,
152
- resources: @resources,
172
+ Views::RootResourceClass.new(
173
+ module_name: @service.module_name,
174
+ service_name: @service.name,
175
+ resources: @service.resources,
153
176
  paginators: @paginators,
154
- var_name: underscore(@module_names.last),
155
- })
177
+ api: @api,
178
+ custom: @service.protocol == 'api-gateway'
179
+ ).render
156
180
  end
157
181
 
158
182
  def resource_class(resource_name, resource_definition)
159
- Generators::ResourceClass.new(
183
+ Views::ResourceClass.new(
184
+ module_name: @service.module_name,
185
+ class_name: resource_name,
160
186
  api: @api,
161
- name: resource_name,
162
- resource: resource_definition,
163
187
  paginators: @paginators,
164
188
  waiters: @waiters,
165
- )
189
+ resource: resource_definition,
190
+ custom: @service.protocol == 'api-gateway'
191
+ ).render
166
192
  end
167
193
 
168
- def service_docstring
169
- metadata = @api['metadata'] || {}
170
- Generators::ServiceDocumentation.new(
171
- product_name: metadata['serviceFullName'] || @module_names.last,
172
- namespace: @module_names.join('::'),
173
- api: @api
174
- ).docstring
194
+ def apig_readme
195
+ Views::APIGReadme.new(
196
+ service_name: @service.name,
197
+ gem_major_version: @service.gem_version.split('.').first,
198
+ gem_name: @service.gem_name,
199
+ module_name: @service.module_name
200
+ ).render
175
201
  end
176
202
 
177
- # @api private
178
- # This method can be removed if move to used the combined API and
179
- # docs JSON document.
180
- def apply_docs(api, docs)
181
- api['documentation'] = docs['service']
182
- docs['operations'].each do |name, docstring|
183
- api['operations'][name]['documentation'] = docstring
184
- end
185
- docs['shapes'].each do |shape_name, shape_docs|
186
- api['shapes'][shape_name]['documentation'] = shape_docs['base']
187
- shape_docs['refs'].each do |ref, ref_docs|
188
- ref_shape, ref_member = ref.split('$')
189
- case api['shapes'][ref_shape]['type']
190
- when 'structure'
191
- api['shapes'][ref_shape]['members'][ref_member]['documentation'] = ref_docs
192
- when 'list', 'map'
193
- api['shapes'][ref_shape][ref_member]['documentation'] = ref_docs
194
- end
203
+ private
195
204
 
196
- end
205
+ def has_eventstream
206
+ @service.api['shapes'].each do |_, ref|
207
+ return true if ref['eventstream']
197
208
  end
209
+ false
198
210
  end
199
211
 
200
212
  end
213
+
201
214
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AwsSdkCodeGenerator
4
+ module Crosslink
5
+
6
+ BASEURL = 'http://docs.aws.amazon.com/'
7
+ EXCLUDE_UIDS = [
8
+ "apigateway",
9
+ "budgets",
10
+ "cloudsearch",
11
+ "cloudsearchdomain",
12
+ "discovery",
13
+ "elastictranscoder",
14
+ "es",
15
+ "glacier",
16
+ "importexport",
17
+ "iot",
18
+ "iot-data",
19
+ "machinelearning",
20
+ "rekognition",
21
+ "sdb",
22
+ "swf"
23
+ ]
24
+
25
+ def self.tag_string(uid, name)
26
+ path = "#{BASEURL}goto/WebAPI/#{uid}/#{name}"
27
+ "@see #{path} AWS API Documentation"
28
+ end
29
+
30
+ def self.taggable?(uid)
31
+ uid && !exclude?(uid)
32
+ end
33
+
34
+ private
35
+ def self.exclude?(uid)
36
+ EXCLUDE_UIDS.any? do |service|
37
+ uid.match(/^#{service}/)
38
+ end
39
+ end
40
+
41
+ end
42
+ end