aws-sdk-code-generator 0.5.0.pre → 0.6.0.pre
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/lib/aws-sdk-code-generator/api.rb +2 -1
- data/lib/aws-sdk-code-generator/client_operation_documentation.rb +2 -1
- data/lib/aws-sdk-code-generator/client_operation_list.rb +4 -0
- data/lib/aws-sdk-code-generator/code_builder.rb +2 -2
- data/lib/aws-sdk-code-generator/endpoint_parameter.rb +190 -0
- data/lib/aws-sdk-code-generator/helper.rb +11 -1
- data/lib/aws-sdk-code-generator/plugin_list.rb +3 -1
- data/lib/aws-sdk-code-generator/resource_batch_action_code.rb +1 -1
- data/lib/aws-sdk-code-generator/resource_client_request.rb +1 -1
- data/lib/aws-sdk-code-generator/resource_waiter.rb +1 -1
- data/lib/aws-sdk-code-generator/service.rb +65 -17
- data/lib/aws-sdk-code-generator/views/client_api_module.rb +32 -15
- data/lib/aws-sdk-code-generator/views/endpoint_parameters_class.rb +6 -50
- data/lib/aws-sdk-code-generator/views/endpoint_provider_class.rb +9 -0
- data/lib/aws-sdk-code-generator/views/endpoints_module.rb +18 -124
- data/lib/aws-sdk-code-generator/views/endpoints_plugin.rb +46 -4
- data/lib/aws-sdk-code-generator/views/errors_module.rb +21 -0
- data/lib/aws-sdk-code-generator/views/features/smoke.rb +5 -4
- data/lib/aws-sdk-code-generator/views/rbs/client_class.rb +1 -1
- data/lib/aws-sdk-code-generator/views/rbs/types_module.rb +2 -2
- data/lib/aws-sdk-code-generator/views/resource_class.rb +22 -0
- data/lib/aws-sdk-code-generator/views/root_resource_class.rb +19 -0
- data/lib/aws-sdk-code-generator/views/service_module.rb +41 -27
- data/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +20 -11
- data/lib/aws-sdk-code-generator/views/types_module.rb +28 -4
- data/lib/aws-sdk-code-generator.rb +12 -0
- data/templates/async_client_class.mustache +6 -1
- data/templates/client_api_module.mustache +7 -0
- data/templates/client_class.mustache +11 -3
- data/templates/endpoint_parameters_class.mustache +16 -13
- data/templates/endpoints_module.mustache +18 -11
- data/templates/endpoints_plugin.mustache +34 -18
- data/templates/errors_module.mustache +5 -0
- data/templates/resource_class.mustache +6 -1
- data/templates/root_resource_class.mustache +5 -0
- data/templates/service_module.mustache +13 -3
- data/templates/spec/endpoint_provider_spec_class.mustache +1 -1
- data/templates/types_module.mustache +4 -0
- metadata +6 -5
| @@ -9,7 +9,7 @@ module AwsSdkCodeGenerator | |
| 9 9 | 
             
                    @service = options.fetch(:service)
         | 
| 10 10 | 
             
                    if (parameters = @service.endpoint_rules&.fetch('parameters'))
         | 
| 11 11 | 
             
                      @parameters = parameters.map do |k,p|
         | 
| 12 | 
            -
                        EndpointParameter.new(k, p)
         | 
| 12 | 
            +
                        EndpointParameter.new(k, p, @service)
         | 
| 13 13 | 
             
                      end
         | 
| 14 14 | 
             
                    end
         | 
| 15 15 | 
             
                  end
         | 
| @@ -17,6 +17,11 @@ module AwsSdkCodeGenerator | |
| 17 17 | 
             
                  # @return [Array<EndpointParameter>]
         | 
| 18 18 | 
             
                  attr_reader :parameters
         | 
| 19 19 |  | 
| 20 | 
            +
                  # @return [Array<EndpointParameter>]
         | 
| 21 | 
            +
                  def config_parameters
         | 
| 22 | 
            +
                    parameters.select { |p| p.source == 'config' }
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 20 25 | 
             
                  # @return [String|nil]
         | 
| 21 26 | 
             
                  def generated_src_warning
         | 
| 22 27 | 
             
                    return if @service.protocol == 'api-gateway'
         | 
| @@ -26,55 +31,6 @@ module AwsSdkCodeGenerator | |
| 26 31 | 
             
                  def module_name
         | 
| 27 32 | 
             
                    @service.module_name
         | 
| 28 33 | 
             
                  end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                  class EndpointParameter
         | 
| 31 | 
            -
                    def initialize(name, definition={})
         | 
| 32 | 
            -
                      @name = name
         | 
| 33 | 
            -
                      @type = definition['type']
         | 
| 34 | 
            -
                      @built_in = definition['builtIn']
         | 
| 35 | 
            -
                      @default = definition['default']
         | 
| 36 | 
            -
                      @required = definition['required']
         | 
| 37 | 
            -
                      @documentation = "# @!attribute #{underscore_name}\n"
         | 
| 38 | 
            -
                      if definition['documentation']
         | 
| 39 | 
            -
                        @documentation += "  #   #{definition['documentation']}\n"
         | 
| 40 | 
            -
                      end
         | 
| 41 | 
            -
                      if deprecated = definition['deprecated']
         | 
| 42 | 
            -
                        @documentation += "  #\n  #   @deprecated\n"
         | 
| 43 | 
            -
                        if deprecated['message']
         | 
| 44 | 
            -
                          @documentation += "  #     #{deprecated['message']}\n"
         | 
| 45 | 
            -
                        end
         | 
| 46 | 
            -
                        if deprecated['since']
         | 
| 47 | 
            -
                          @documentation += "  #     Since: #{deprecated['since']}\n"
         | 
| 48 | 
            -
                        end
         | 
| 49 | 
            -
                      end
         | 
| 50 | 
            -
                      @documentation += "  #\n  #   @return [#{@type}]\n  #"
         | 
| 51 | 
            -
                    end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                    # @return [String]
         | 
| 54 | 
            -
                    attr_reader :name
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                    # @return [String]
         | 
| 57 | 
            -
                    attr_reader :documentation
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                    # @return [Boolean]
         | 
| 60 | 
            -
                    attr_reader :required
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                    # @return [String,Boolean]
         | 
| 63 | 
            -
                    attr_reader :default
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                    def default?
         | 
| 66 | 
            -
                      !@default.nil?
         | 
| 67 | 
            -
                    end
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                    def boolean_default?
         | 
| 70 | 
            -
                      default? && (@default == true || @default == false)
         | 
| 71 | 
            -
                    end
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                    def underscore_name
         | 
| 74 | 
            -
                      Underscore.underscore(name)
         | 
| 75 | 
            -
                    end
         | 
| 76 | 
            -
                  end
         | 
| 77 | 
            -
             | 
| 78 34 | 
             
                end
         | 
| 79 35 | 
             
              end
         | 
| 80 36 | 
             
            end
         | 
| @@ -9,6 +9,11 @@ module AwsSdkCodeGenerator | |
| 9 9 | 
             
                  def initialize(options)
         | 
| 10 10 | 
             
                    @service = options.fetch(:service)
         | 
| 11 11 | 
             
                    @endpoint_rules = @service.endpoint_rules
         | 
| 12 | 
            +
                    # Used to collect metrics in the generated endpoint provider
         | 
| 13 | 
            +
                    @has_account_id_endpoint_mode =
         | 
| 14 | 
            +
                      @endpoint_rules['parameters'].find do |_, param|
         | 
| 15 | 
            +
                        param['builtIn'] == 'AWS::Auth::AccountIdEndpointMode'
         | 
| 16 | 
            +
                      end
         | 
| 12 17 |  | 
| 13 18 | 
             
                    version = @endpoint_rules['version']
         | 
| 14 19 | 
             
                    return if version&.match(/^\d+\.\d+$/) # && version == '1.0'
         | 
| @@ -76,6 +81,10 @@ module AwsSdkCodeGenerator | |
| 76 81 | 
             
                    if endpoint['properties']
         | 
| 77 82 | 
             
                      res << ", properties: #{templated_hash_to_s(endpoint['properties'])}"
         | 
| 78 83 | 
             
                    end
         | 
| 84 | 
            +
                    if @has_account_id_endpoint_mode
         | 
| 85 | 
            +
                      account_id_endpoint = endpoint['url'].include?('{AccountId}')
         | 
| 86 | 
            +
                      res << ", metadata: { account_id_endpoint: #{account_id_endpoint} }"
         | 
| 87 | 
            +
                    end
         | 
| 79 88 | 
             
                    res << ")\n"
         | 
| 80 89 | 
             
                    indent(res.string, levels)
         | 
| 81 90 | 
             
                  end
         | 
| @@ -10,11 +10,12 @@ module AwsSdkCodeGenerator | |
| 10 10 | 
             
                    @parameters = @service.endpoint_rules.fetch('parameters', {})
         | 
| 11 11 |  | 
| 12 12 | 
             
                    @endpoint_classes = @service.api['operations'].each.with_object([]) do
         | 
| 13 | 
            -
                      |(name, op),  | 
| 14 | 
            -
                       | 
| 13 | 
            +
                      |(name, op), classes|
         | 
| 14 | 
            +
                      endpoint_class = EndpointClass.new(
         | 
| 15 15 | 
             
                        name: name,
         | 
| 16 16 | 
             
                        parameters: endpoint_parameters_for_operation(op)
         | 
| 17 17 | 
             
                      )
         | 
| 18 | 
            +
                      classes << endpoint_class unless endpoint_class.parameters.empty?
         | 
| 18 19 | 
             
                    end
         | 
| 19 20 | 
             
                  end
         | 
| 20 21 |  | 
| @@ -31,147 +32,40 @@ module AwsSdkCodeGenerator | |
| 31 32 | 
             
                    @service.module_name
         | 
| 32 33 | 
             
                  end
         | 
| 33 34 |  | 
| 35 | 
            +
                  def operation_specific_parameters?
         | 
| 36 | 
            +
                    @endpoint_classes.empty?
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 34 39 | 
             
                  class EndpointClass
         | 
| 35 40 | 
             
                    def initialize(options)
         | 
| 36 41 | 
             
                      @name = options[:name]
         | 
| 42 | 
            +
                      @operation = Underscore.underscore(@name)
         | 
| 37 43 | 
             
                      @parameters = options[:parameters]
         | 
| 38 44 | 
             
                    end
         | 
| 39 45 |  | 
| 40 46 | 
             
                    # @return [String]
         | 
| 41 47 | 
             
                    attr_reader :name
         | 
| 42 48 |  | 
| 43 | 
            -
                    # @return [Array<EndpointParameter>]
         | 
| 44 | 
            -
                    attr_reader :parameters
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                    def has_endpoint_built_in?
         | 
| 47 | 
            -
                      parameters.any? { |p| p.param_data['builtIn'] == 'SDK::Endpoint' }
         | 
| 48 | 
            -
                    end
         | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
                  class EndpointParameter
         | 
| 52 | 
            -
                    def initialize(options)
         | 
| 53 | 
            -
                      @key = options[:key]
         | 
| 54 | 
            -
                      @value = options[:value]
         | 
| 55 | 
            -
                      @source = options[:source]
         | 
| 56 | 
            -
                      @param_data = options[:param_data]
         | 
| 57 | 
            -
                    end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                    # @return [String]
         | 
| 60 | 
            -
                    attr_accessor :key
         | 
| 61 | 
            -
             | 
| 62 | 
            -
                    # @return [String]
         | 
| 63 | 
            -
                    attr_accessor :value
         | 
| 64 | 
            -
             | 
| 65 49 | 
             
                    # @return [String]
         | 
| 66 | 
            -
                     | 
| 50 | 
            +
                    attr_reader :operation
         | 
| 67 51 |  | 
| 68 | 
            -
                    # @return [ | 
| 69 | 
            -
                     | 
| 70 | 
            -
             | 
| 71 | 
            -
                    def static_string?
         | 
| 72 | 
            -
                      @source == 'staticContextParam' && value.is_a?(String)
         | 
| 73 | 
            -
                    end
         | 
| 52 | 
            +
                    # @return [Array<EndpointParameter>]
         | 
| 53 | 
            +
                    attr_reader :parameters
         | 
| 74 54 | 
             
                  end
         | 
| 75 55 |  | 
| 76 | 
            -
             | 
| 77 56 | 
             
                  private
         | 
| 78 57 |  | 
| 79 58 | 
             
                  def endpoint_parameters_for_operation(operation)
         | 
| 80 | 
            -
                    @parameters.each.with_object([]) do |(param_name, param_data),  | 
| 81 | 
            -
                       | 
| 82 | 
            -
                         | 
| 83 | 
            -
             | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
                        key: Underscore.underscore(param_name),
         | 
| 87 | 
            -
                        value: value,
         | 
| 88 | 
            -
                        source: source,
         | 
| 89 | 
            -
                        param_data: param_data
         | 
| 59 | 
            +
                    @parameters.each.with_object([]) do |(param_name, param_data), parameters|
         | 
| 60 | 
            +
                      p = EndpointParameter.new(
         | 
| 61 | 
            +
                        param_name,
         | 
| 62 | 
            +
                        param_data,
         | 
| 63 | 
            +
                        @service,
         | 
| 64 | 
            +
                        operation
         | 
| 90 65 | 
             
                      )
         | 
| 66 | 
            +
                      parameters << p if p.source == 'operation'
         | 
| 91 67 | 
             
                    end
         | 
| 92 68 | 
             
                  end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                  # Most to least
         | 
| 95 | 
            -
                  # staticContextParams
         | 
| 96 | 
            -
                  # contextParam
         | 
| 97 | 
            -
                  # clientContextParams
         | 
| 98 | 
            -
                  # Built-In Bindings
         | 
| 99 | 
            -
                  # Built-in binding default values
         | 
| 100 | 
            -
                  def endpoint_parameter_value(operation, param_name, param_data)
         | 
| 101 | 
            -
                    value, source = [
         | 
| 102 | 
            -
                      static_context_param(operation, param_name), 'staticContextParam'
         | 
| 103 | 
            -
                    ]
         | 
| 104 | 
            -
                    value, source = [
         | 
| 105 | 
            -
                      context_param_value(operation, param_name), 'contextParam'
         | 
| 106 | 
            -
                    ] unless value
         | 
| 107 | 
            -
                    value, source = [
         | 
| 108 | 
            -
                      client_context_param_value(param_name, param_data),
         | 
| 109 | 
            -
                      'clientContextParam'
         | 
| 110 | 
            -
                    ] unless value
         | 
| 111 | 
            -
                    value, source = [
         | 
| 112 | 
            -
                      built_in_client_context_param_value(param_data), 'builtIn'
         | 
| 113 | 
            -
                    ] unless value
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                    [value || 'nil', source]
         | 
| 116 | 
            -
                  end
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                  def client_context_param_value(param_name, param_data)
         | 
| 119 | 
            -
                    if @service.api['clientContextParams']&.key?(param_name) &&
         | 
| 120 | 
            -
                       !param_data['builtIn']
         | 
| 121 | 
            -
                      "context.config.#{Underscore.underscore(param_name)}"
         | 
| 122 | 
            -
                    end
         | 
| 123 | 
            -
                  end
         | 
| 124 | 
            -
             | 
| 125 | 
            -
                  def built_in_client_context_param_value(param_data)
         | 
| 126 | 
            -
                    case param_data['builtIn']
         | 
| 127 | 
            -
                    when 'AWS::Region'
         | 
| 128 | 
            -
                      'context.config.region'
         | 
| 129 | 
            -
                    when 'AWS::UseFIPS'
         | 
| 130 | 
            -
                      'context.config.use_fips_endpoint'
         | 
| 131 | 
            -
                    when 'AWS::UseDualStack'
         | 
| 132 | 
            -
                      if @service.name == 'S3' || @service.name == 'S3Control'
         | 
| 133 | 
            -
                        'context[:use_dualstack_endpoint]'
         | 
| 134 | 
            -
                      else
         | 
| 135 | 
            -
                        'context.config.use_dualstack_endpoint'
         | 
| 136 | 
            -
                      end
         | 
| 137 | 
            -
                    when 'AWS::STS::UseGlobalEndpoint'
         | 
| 138 | 
            -
                      "context.config.sts_regional_endpoints == 'legacy'"
         | 
| 139 | 
            -
                    when 'AWS::S3::UseGlobalEndpoint'
         | 
| 140 | 
            -
                      "context.config.s3_us_east_1_regional_endpoint == 'legacy'"
         | 
| 141 | 
            -
                    when 'AWS::S3::Accelerate'
         | 
| 142 | 
            -
                      if @service.name == 'S3' || @service.name == 'S3Control'
         | 
| 143 | 
            -
                        'context[:use_accelerate_endpoint]'
         | 
| 144 | 
            -
                      else
         | 
| 145 | 
            -
                        'context.config.use_accelerate_endpoint'
         | 
| 146 | 
            -
                      end
         | 
| 147 | 
            -
                    when 'AWS::S3::ForcePathStyle'
         | 
| 148 | 
            -
                      'context.config.force_path_style'
         | 
| 149 | 
            -
                    when 'AWS::S3::UseArnRegion', 'AWS::S3Control::UseArnRegion'
         | 
| 150 | 
            -
                      'context.config.s3_use_arn_region'
         | 
| 151 | 
            -
                    when 'AWS::S3::DisableMultiRegionAccessPoints'
         | 
| 152 | 
            -
                      'context.config.s3_disable_multiregion_access_points'
         | 
| 153 | 
            -
                    when 'SDK::Endpoint'
         | 
| 154 | 
            -
                      'endpoint'
         | 
| 155 | 
            -
                    end
         | 
| 156 | 
            -
                  end
         | 
| 157 | 
            -
             | 
| 158 | 
            -
                  def context_param_value(operation, param_name)
         | 
| 159 | 
            -
                    return nil unless operation['input']
         | 
| 160 | 
            -
             | 
| 161 | 
            -
                    input_shape = operation['input']['shape']
         | 
| 162 | 
            -
                    members = @service.api['shapes'][input_shape].fetch('members', {})
         | 
| 163 | 
            -
                    members.detect do |(member_name, member)|
         | 
| 164 | 
            -
                      context_param = member.fetch('contextParam', {})
         | 
| 165 | 
            -
                      if context_param.fetch('name', nil) == param_name
         | 
| 166 | 
            -
                        break "context.params[:#{Underscore.underscore(member_name)}]"
         | 
| 167 | 
            -
                      end
         | 
| 168 | 
            -
                    end
         | 
| 169 | 
            -
                  end
         | 
| 170 | 
            -
             | 
| 171 | 
            -
                  def static_context_param(operation, param_name)
         | 
| 172 | 
            -
                    operation.fetch('staticContextParams', {})
         | 
| 173 | 
            -
                             .fetch(param_name, {}).fetch('value', nil)
         | 
| 174 | 
            -
                  end
         | 
| 175 69 | 
             
                end
         | 
| 176 70 | 
             
              end
         | 
| 177 71 | 
             
            end
         | 
| @@ -6,15 +6,25 @@ module AwsSdkCodeGenerator | |
| 6 6 | 
             
                  # @option options [required, Service] :service
         | 
| 7 7 | 
             
                  def initialize(options)
         | 
| 8 8 | 
             
                    @service = options.fetch(:service)
         | 
| 9 | 
            -
                     | 
| 10 | 
            -
             | 
| 9 | 
            +
                    endpoint_parameters = @service.endpoint_rules.fetch('parameters', {})
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                    # HACK: AccountIdEndpointMode should likely be a client context
         | 
| 12 | 
            +
                    # param, but it's a built in that should be per-service.
         | 
| 13 | 
            +
                    @endpoint_options = []
         | 
| 14 | 
            +
                    endpoint_parameters.each do |_key, data|
         | 
| 15 | 
            +
                      next unless data['builtIn'] == 'AWS::Auth::AccountIdEndpointMode'
         | 
| 11 16 |  | 
| 12 | 
            -
                      @endpoint_options  | 
| 17 | 
            +
                      @endpoint_options << account_id_endpoint_mode_option
         | 
| 18 | 
            +
                      @account_id_endpoint_mode = true
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                    if (client_options = @service.api['clientContextParams'])
         | 
| 22 | 
            +
                      client_options.each do |name, _data|
         | 
| 13 23 | 
             
                        param_data = endpoint_parameters[name]
         | 
| 14 24 |  | 
| 15 25 | 
             
                        next if param_data['builtIn']
         | 
| 16 26 |  | 
| 17 | 
            -
                         | 
| 27 | 
            +
                        @endpoint_options << EndpointOption.new(
         | 
| 18 28 | 
             
                          name: Underscore.underscore(name),
         | 
| 19 29 | 
             
                          docstring: param_data['documentation'],
         | 
| 20 30 | 
             
                          doc_type: param_data['type'],
         | 
| @@ -22,6 +32,7 @@ module AwsSdkCodeGenerator | |
| 22 32 | 
             
                        )
         | 
| 23 33 | 
             
                      end
         | 
| 24 34 | 
             
                    end
         | 
| 35 | 
            +
             | 
| 25 36 | 
             
                    @endpoint_classes = @service.api['operations'].each.with_object([]) do
         | 
| 26 37 | 
             
                      |(op, _api), array|
         | 
| 27 38 | 
             
                      array << EndpointClass.new(
         | 
| @@ -47,6 +58,37 @@ module AwsSdkCodeGenerator | |
| 47 58 | 
             
                    @service.module_name
         | 
| 48 59 | 
             
                  end
         | 
| 49 60 |  | 
| 61 | 
            +
                  def has_account_id_endpoint_mode?
         | 
| 62 | 
            +
                    @account_id_endpoint_mode
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  private
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  def account_id_endpoint_mode_option
         | 
| 68 | 
            +
                    docstring = <<-DOCSTRING.chomp
         | 
| 69 | 
            +
            The account ID endpoint mode to use. This can be one of the following values:
         | 
| 70 | 
            +
            * `preferred` - The default behavior. Use the account ID endpoint if
         | 
| 71 | 
            +
              available, otherwise use the standard endpoint.
         | 
| 72 | 
            +
            * `disabled` - Never use the account ID endpoint. Only use the standard
         | 
| 73 | 
            +
              endpoint.
         | 
| 74 | 
            +
            * `required` - Always use the account ID endpoint. If the account ID
         | 
| 75 | 
            +
              cannot be retrieved from credentials, an error is raised.
         | 
| 76 | 
            +
                    DOCSTRING
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                    default = <<-DEFAULT.chomp
         | 
| 79 | 
            +
            value = ENV['AWS_ACCOUNT_ID_ENDPOINT_MODE']
         | 
| 80 | 
            +
                    value ||= Aws.shared_config.account_id_endpoint_mode(profile: cfg.profile)
         | 
| 81 | 
            +
                    value || 'preferred'
         | 
| 82 | 
            +
                    DEFAULT
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                    EndpointOption.new(
         | 
| 85 | 
            +
                      name: 'account_id_endpoint_mode',
         | 
| 86 | 
            +
                      docstring: docstring,
         | 
| 87 | 
            +
                      doc_type: 'String',
         | 
| 88 | 
            +
                      default: default
         | 
| 89 | 
            +
                    )
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 50 92 | 
             
                  class EndpointClass
         | 
| 51 93 | 
             
                    def initialize(options)
         | 
| 52 94 | 
             
                      @operation_name = options[:operation_name]
         | 
| @@ -23,10 +23,31 @@ module AwsSdkCodeGenerator | |
| 23 23 | 
             
                    GENERATED_SRC_WARNING
         | 
| 24 24 | 
             
                  end
         | 
| 25 25 |  | 
| 26 | 
            +
                  # @return [String]
         | 
| 26 27 | 
             
                  def module_name
         | 
| 27 28 | 
             
                    @service.module_name
         | 
| 28 29 | 
             
                  end
         | 
| 29 30 |  | 
| 31 | 
            +
                  # @return [Boolean]
         | 
| 32 | 
            +
                  def customization_file_exists?
         | 
| 33 | 
            +
                    File.exist?(
         | 
| 34 | 
            +
                      File.join(
         | 
| 35 | 
            +
                        Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb"
         | 
| 36 | 
            +
                      )
         | 
| 37 | 
            +
                    )
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  # @return [String]
         | 
| 41 | 
            +
                  def customization_file_path
         | 
| 42 | 
            +
                    "#{gem_name}/customizations/errors"
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  private
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  # @return [String]
         | 
| 48 | 
            +
                  def gem_name
         | 
| 49 | 
            +
                    "aws-sdk-#{module_name.split('::').last.downcase}"
         | 
| 50 | 
            +
                  end
         | 
| 30 51 | 
             
                end
         | 
| 31 52 | 
             
              end
         | 
| 32 53 | 
             
            end
         | 
| @@ -85,13 +85,14 @@ module AwsSdkCodeGenerator | |
| 85 85 | 
             
                        when 'sigv4aRegionSet' then nil # TODO
         | 
| 86 86 | 
             
                        when 'uri' then ['endpoint', raw_value]
         | 
| 87 87 | 
             
                        when 'useFips' then ['use_fips_endpoint', raw_value]
         | 
| 88 | 
            -
                        when ' | 
| 88 | 
            +
                        when 'useDualstack' then ['use_dualstack_endpoint', raw_value]
         | 
| 89 89 | 
             
                        # service specific
         | 
| 90 90 | 
             
                        when 'useGlobalEndpoint'
         | 
| 91 91 | 
             
                          value = raw_value == 'true' ? 'legacy' : 'regional'
         | 
| 92 | 
            -
                           | 
| 92 | 
            +
                          case @service.name
         | 
| 93 | 
            +
                          when 'S3'
         | 
| 93 94 | 
             
                            ['s3_us_east_1_regional_endpoint', value]
         | 
| 94 | 
            -
                           | 
| 95 | 
            +
                          when 'STS'
         | 
| 95 96 | 
             
                            ['sts_regional_endpoints', value]
         | 
| 96 97 | 
             
                          end
         | 
| 97 98 | 
             
                        # s3 specific
         | 
| @@ -104,7 +105,7 @@ module AwsSdkCodeGenerator | |
| 104 105 | 
             
                        when 'useAccountIdRouting' then nil # TODO
         | 
| 105 106 | 
             
                        else
         | 
| 106 107 | 
             
                          # catch all, possible code generated config options
         | 
| 107 | 
            -
                          [ | 
| 108 | 
            +
                          [underscore(raw_key), raw_value]
         | 
| 108 109 | 
             
                        end
         | 
| 109 110 | 
             
                      end
         | 
| 110 111 |  | 
| @@ -138,7 +138,7 @@ module AwsSdkCodeGenerator | |
| 138 138 | 
             
                      grouped = buffer.group_by { |name, _| name }
         | 
| 139 139 | 
             
                      grouped.transform_values(&:count).find_all { |_, c| 1 < c }.each do |name,|
         | 
| 140 140 | 
             
                        case name
         | 
| 141 | 
            -
                        when :endpoint, :endpoint_provider, :retry_limit, :disable_s3_express_session_auth
         | 
| 141 | 
            +
                        when :endpoint, :endpoint_provider, :retry_limit, :disable_s3_express_session_auth, :account_id_endpoint_mode
         | 
| 142 142 | 
             
                          # ok
         | 
| 143 143 | 
             
                        else
         | 
| 144 144 | 
             
                          warn("Duplicate client option in #{@service_name}: `#{grouped[name].map { |g| g.values_at(0, 2) }}`", uplevel: 0)
         | 
| @@ -31,7 +31,7 @@ module AwsSdkCodeGenerator | |
| 31 31 | 
             
                          # exceptions will not have the event trait.
         | 
| 32 32 | 
             
                          shape['members'].each do |name, ref|
         | 
| 33 33 | 
             
                            if !!@service.api['shapes'][ref['shape']]['exception']
         | 
| 34 | 
            -
                              @service.api['shapes'][ref['shape']][' | 
| 34 | 
            +
                              @service.api['shapes'][ref['shape']]['exceptionEvent'] = true
         | 
| 35 35 | 
             
                            end
         | 
| 36 36 | 
             
                          end
         | 
| 37 37 | 
             
                        end
         | 
| @@ -90,7 +90,7 @@ module AwsSdkCodeGenerator | |
| 90 90 | 
             
                          returns: AwsSdkCodeGenerator::RBS.to_type(member_ref, @api)
         | 
| 91 91 | 
             
                        )
         | 
| 92 92 | 
             
                      end
         | 
| 93 | 
            -
                      if shape['event'] || shape[' | 
| 93 | 
            +
                      if shape['event'] || shape['exceptionEvent']
         | 
| 94 94 | 
             
                        members << StructMember.new(
         | 
| 95 95 | 
             
                          member_name: 'event_type',
         | 
| 96 96 | 
             
                          returns: 'untyped'
         | 
| @@ -106,8 +106,30 @@ module AwsSdkCodeGenerator | |
| 106 106 | 
             
                    @identifiers.size > 0
         | 
| 107 107 | 
             
                  end
         | 
| 108 108 |  | 
| 109 | 
            +
                  # @return [Boolean]
         | 
| 110 | 
            +
                  def customization_file_exists?
         | 
| 111 | 
            +
                    File.exist?(
         | 
| 112 | 
            +
                      File.join(
         | 
| 113 | 
            +
                        Helper.gem_lib_path(gem_name), "#{resource_customization}.rb"
         | 
| 114 | 
            +
                      )
         | 
| 115 | 
            +
                    )
         | 
| 116 | 
            +
                  end
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                  # @return [String]
         | 
| 119 | 
            +
                  def resource_customization
         | 
| 120 | 
            +
                    "#{gem_name}/customizations/#{underscored_name}"
         | 
| 121 | 
            +
                  end
         | 
| 122 | 
            +
             | 
| 109 123 | 
             
                  private
         | 
| 110 124 |  | 
| 125 | 
            +
                  def gem_name
         | 
| 126 | 
            +
                    "aws-sdk-#{module_name.split('::').last.downcase}"
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                  def underscored_name
         | 
| 130 | 
            +
                    class_name.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
         | 
| 131 | 
            +
                  end
         | 
| 132 | 
            +
             | 
| 111 133 | 
             
                  def build_associations(options)
         | 
| 112 134 | 
             
                    ResourceAssociation.build_list(
         | 
| 113 135 | 
             
                      class_name: options.fetch(:class_name),
         | 
| @@ -53,6 +53,25 @@ module AwsSdkCodeGenerator | |
| 53 53 | 
             
                    actions? || associations?
         | 
| 54 54 | 
             
                  end
         | 
| 55 55 |  | 
| 56 | 
            +
                  # @return [Boolean]
         | 
| 57 | 
            +
                  def customization_file_exists?
         | 
| 58 | 
            +
                    File.exist?(
         | 
| 59 | 
            +
                      File.join(
         | 
| 60 | 
            +
                        Helper.gem_lib_path(gem_name), "#{customization_file_path}.rb"
         | 
| 61 | 
            +
                      )
         | 
| 62 | 
            +
                    )
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  # @return [String]
         | 
| 66 | 
            +
                  def customization_file_path
         | 
| 67 | 
            +
                    "#{gem_name}/customizations/resource"
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  private
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                  def gem_name
         | 
| 73 | 
            +
                    "aws-sdk-#{module_name.split('::').last.downcase}"
         | 
| 74 | 
            +
                  end
         | 
| 56 75 | 
             
                end
         | 
| 57 76 | 
             
              end
         | 
| 58 77 | 
             
            end
         | 
| @@ -11,9 +11,12 @@ module AwsSdkCodeGenerator | |
| 11 11 | 
             
                  def initialize(options)
         | 
| 12 12 | 
             
                    @service = options.fetch(:service)
         | 
| 13 13 | 
             
                    @prefix = options.fetch(:prefix)
         | 
| 14 | 
            -
                    @codegenerated_plugins = options.fetch(:codegenerated_plugins)
         | 
| 14 | 
            +
                    @codegenerated_plugins = options.fetch(:codegenerated_plugins) || []
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 | 
            +
                  # @return [String]
         | 
| 18 | 
            +
                  attr_reader :prefix
         | 
| 19 | 
            +
             | 
| 17 20 | 
             
                  # @return [String|nil]
         | 
| 18 21 | 
             
                  def generated_src_warning
         | 
| 19 22 | 
             
                    return if @service.protocol == 'api-gateway'
         | 
| @@ -60,47 +63,57 @@ module AwsSdkCodeGenerator | |
| 60 63 | 
             
                    @service.included_in_core?
         | 
| 61 64 | 
             
                  end
         | 
| 62 65 |  | 
| 63 | 
            -
                  # @return [ | 
| 64 | 
            -
                  def  | 
| 65 | 
            -
                     | 
| 66 | 
            -
             | 
| 67 | 
            -
             | 
| 66 | 
            +
                  # @return [String]
         | 
| 67 | 
            +
                  def service_identifier
         | 
| 68 | 
            +
                    @service.identifier
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  # @return [Array<Hash>] list of autoload path hashes with :path, :class_name and
         | 
| 72 | 
            +
                  # :is_plugin keys.
         | 
| 73 | 
            +
                  def autoloads
         | 
| 74 | 
            +
                    paths = []
         | 
| 75 | 
            +
                    paths << auto_load("#{@prefix}/types", :Types)
         | 
| 76 | 
            +
                    paths << auto_load("#{@prefix}/client_api", :ClientApi)
         | 
| 68 77 |  | 
| 69 78 | 
             
                    # these must be required before the client
         | 
| 70 | 
            -
                     | 
| 71 | 
            -
                       | 
| 79 | 
            +
                    paths += @codegenerated_plugins.map do |p|
         | 
| 80 | 
            +
                      auto_load(p.path, p.class_name.split('::').last, true)
         | 
| 72 81 | 
             
                    end
         | 
| 73 82 |  | 
| 74 | 
            -
                    paths << "#{@prefix}/client"
         | 
| 75 | 
            -
                    paths << "#{@prefix}/errors"
         | 
| 76 | 
            -
                    paths << "#{@prefix}/waiters" if @service.waiters
         | 
| 77 | 
            -
                    paths << "#{@prefix}/resource"
         | 
| 83 | 
            +
                    paths << auto_load("#{@prefix}/client", :Client)
         | 
| 84 | 
            +
                    paths << auto_load("#{@prefix}/errors", :Errors)
         | 
| 85 | 
            +
                    paths << auto_load("#{@prefix}/waiters", :Waiters) if @service.waiters
         | 
| 86 | 
            +
                    paths << auto_load("#{@prefix}/resource", :Resource)
         | 
| 78 87 |  | 
| 79 88 | 
             
                    unless @service.legacy_endpoints?
         | 
| 80 | 
            -
                      paths << "#{@prefix}/endpoint_parameters"
         | 
| 81 | 
            -
                      paths << "#{@prefix}/endpoint_provider"
         | 
| 82 | 
            -
                      paths << "#{@prefix}/endpoints"
         | 
| 89 | 
            +
                      paths << auto_load("#{@prefix}/endpoint_parameters", :EndpointParameters)
         | 
| 90 | 
            +
                      paths << auto_load("#{@prefix}/endpoint_provider", :EndpointProvider)
         | 
| 91 | 
            +
                      paths << auto_load("#{@prefix}/endpoints", :Endpoints)
         | 
| 83 92 | 
             
                    end
         | 
| 84 93 |  | 
| 85 94 | 
             
                    if @service.resources && @service.resources['resources']
         | 
| 86 95 | 
             
                      @service.resources['resources'].keys.each do |resource_name|
         | 
| 87 96 | 
             
                        path = "#{@prefix}/#{underscore(resource_name)}"
         | 
| 88 | 
            -
                         | 
| 89 | 
            -
                          raise "resource path conflict for `#{resource_name}'"
         | 
| 90 | 
            -
                        else
         | 
| 91 | 
            -
                          paths << path
         | 
| 92 | 
            -
                        end
         | 
| 97 | 
            +
                        paths << auto_load(path, resource_name)
         | 
| 93 98 | 
             
                      end
         | 
| 94 99 | 
             
                    end
         | 
| 95 | 
            -
                    paths << "#{@prefix}/customizations"
         | 
| 96 100 | 
             
                    if @service.api['metadata']['protocolSettings'] &&
         | 
| 97 | 
            -
             | 
| 98 | 
            -
                      paths << "#{@prefix}/async_client"
         | 
| 99 | 
            -
                      paths << "#{@prefix}/event_streams"
         | 
| 101 | 
            +
                       @service.api['metadata']['protocolSettings']['h2'] == 'eventstream'
         | 
| 102 | 
            +
                      paths << auto_load("#{@prefix}/async_client", :AsyncClient)
         | 
| 103 | 
            +
                      paths << auto_load("#{@prefix}/event_streams", :EventStreams)
         | 
| 100 104 | 
             
                    elsif eventstream_shape?
         | 
| 101 | 
            -
                      paths << "#{@prefix}/event_streams"
         | 
| 105 | 
            +
                      paths << auto_load("#{@prefix}/event_streams", :EventStreams)
         | 
| 102 106 | 
             
                    end
         | 
| 103 | 
            -
             | 
| 107 | 
            +
             | 
| 108 | 
            +
                    paths
         | 
| 109 | 
            +
                  end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                  def auto_load(path, class_name, is_plugin = false)
         | 
| 112 | 
            +
                    {
         | 
| 113 | 
            +
                      file_path: path,
         | 
| 114 | 
            +
                      class_name: class_name,
         | 
| 115 | 
            +
                      is_plugin: is_plugin
         | 
| 116 | 
            +
                    }
         | 
| 104 117 | 
             
                  end
         | 
| 105 118 |  | 
| 106 119 | 
             
                  def example_var_name
         | 
| @@ -108,7 +121,8 @@ module AwsSdkCodeGenerator | |
| 108 121 | 
             
                  end
         | 
| 109 122 |  | 
| 110 123 | 
             
                  def example_operation_name
         | 
| 111 | 
            -
                    raise  | 
| 124 | 
            +
                    raise 'no operations found for the service' if @service.api['operations'].empty?
         | 
| 125 | 
            +
             | 
| 112 126 | 
             
                    underscore(@service.api['operations'].keys.first)
         | 
| 113 127 | 
             
                  end
         | 
| 114 128 |  | 
| @@ -51,9 +51,9 @@ module AwsSdkCodeGenerator | |
| 51 51 | 
             
                            operation_name: Underscore.underscore(
         | 
| 52 52 | 
             
                              operation_inputs_test['operationName']
         | 
| 53 53 | 
             
                            ),
         | 
| 54 | 
            -
                            operation_params: operation_inputs_test['operationParams'] ||  | 
| 55 | 
            -
                            built_in_params: operation_inputs_test['builtInParams'] ||  | 
| 56 | 
            -
                            client_params: operation_inputs_test['clientParams'] ||  | 
| 54 | 
            +
                            operation_params: operation_inputs_test['operationParams'] || {},
         | 
| 55 | 
            +
                            built_in_params: operation_inputs_test['builtInParams'] || {},
         | 
| 56 | 
            +
                            client_params: operation_inputs_test['clientParams'] || {}
         | 
| 57 57 | 
             
                          )
         | 
| 58 58 | 
             
                        end
         | 
| 59 59 | 
             
                      end
         | 
| @@ -117,12 +117,13 @@ module AwsSdkCodeGenerator | |
| 117 117 | 
             
                        @client_params = options[:client_params].map do |k,v|
         | 
| 118 118 | 
             
                          Param.new(Underscore.underscore(k), v)
         | 
| 119 119 | 
             
                        end
         | 
| 120 | 
            -
             | 
| 121 120 | 
             
                        @client_params += options[:built_in_params].map do |k,v|
         | 
| 122 121 | 
             
                          built_in_to_param(k, v)
         | 
| 123 122 | 
             
                        end
         | 
| 124 | 
            -
                        # the expected default of UseGlobalEndpoint  | 
| 125 | 
            -
                         | 
| 123 | 
            +
                        # the expected default of UseGlobalEndpoint in rules
         | 
| 124 | 
            +
                        # does not match the Ruby SDK's default value
         | 
| 125 | 
            +
                        if @service.identifier == 's3' &&
         | 
| 126 | 
            +
                           !options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint')
         | 
| 126 127 | 
             
                          @client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
         | 
| 127 128 | 
             
                        end
         | 
| 128 129 | 
             
                      end
         | 
| @@ -158,6 +159,14 @@ module AwsSdkCodeGenerator | |
| 158 159 | 
             
                          Param.new('use_fips_endpoint', value)
         | 
| 159 160 | 
             
                        when 'AWS::UseDualStack'
         | 
| 160 161 | 
             
                          Param.new('use_dualstack_endpoint', value)
         | 
| 162 | 
            +
                        when 'AWS::Auth::AccountId'
         | 
| 163 | 
            +
                          Param.new(
         | 
| 164 | 
            +
                            'credentials',
         | 
| 165 | 
            +
                            "Aws::Credentials.new('stubbed-akid', 'stubbed-secret', account_id: '#{value}')",
         | 
| 166 | 
            +
                            true
         | 
| 167 | 
            +
                          )
         | 
| 168 | 
            +
                        when 'AWS::Auth::AccountIdEndpointMode'
         | 
| 169 | 
            +
                          Param.new('account_id_endpoint_mode', value)
         | 
| 161 170 | 
             
                        when 'AWS::STS::UseGlobalEndpoint'
         | 
| 162 171 | 
             
                          Param.new('sts_regional_endpoints', value ? 'legacy' : 'regional')
         | 
| 163 172 | 
             
                        when 'AWS::S3::UseGlobalEndpoint'
         | 
| @@ -166,9 +175,7 @@ module AwsSdkCodeGenerator | |
| 166 175 | 
             
                          Param.new('use_accelerate_endpoint', value)
         | 
| 167 176 | 
             
                        when 'AWS::S3::ForcePathStyle'
         | 
| 168 177 | 
             
                          Param.new('force_path_style', value)
         | 
| 169 | 
            -
                        when 'AWS::S3::UseArnRegion'
         | 
| 170 | 
            -
                          Param.new('s3_use_arn_region', value)
         | 
| 171 | 
            -
                        when 'AWS::S3Control::UseArnRegion'
         | 
| 178 | 
            +
                        when 'AWS::S3::UseArnRegion', 'AWS::S3Control::UseArnRegion'
         | 
| 172 179 | 
             
                          Param.new('s3_use_arn_region', value)
         | 
| 173 180 | 
             
                        when 'AWS::S3::DisableMultiRegionAccessPoints'
         | 
| 174 181 | 
             
                          Param.new('s3_disable_multiregion_access_points', value)
         | 
| @@ -181,14 +188,16 @@ module AwsSdkCodeGenerator | |
| 181 188 | 
             
                    end
         | 
| 182 189 |  | 
| 183 190 | 
             
                    class Param
         | 
| 184 | 
            -
                      def initialize(param, value)
         | 
| 191 | 
            +
                      def initialize(param, value, literal = false)
         | 
| 185 192 | 
             
                        @param = param
         | 
| 186 193 | 
             
                        @value = value
         | 
| 194 | 
            +
                        @literal = literal
         | 
| 187 195 | 
             
                      end
         | 
| 196 | 
            +
             | 
| 188 197 | 
             
                      attr_accessor :param
         | 
| 189 198 |  | 
| 190 199 | 
             
                      def value
         | 
| 191 | 
            -
                        if @value.is_a?  | 
| 200 | 
            +
                        if @value.is_a?(String) && !@literal
         | 
| 192 201 | 
             
                          "'#{@value}'"
         | 
| 193 202 | 
             
                        else
         | 
| 194 203 | 
             
                          @value
         |