Skip to content

Commit

Permalink
Fix query serializaiton of empty lists. See: smithy-lang/smithy#1444
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Jul 20, 2023
1 parent a4ef5bf commit 5cc9628
Show file tree
Hide file tree
Showing 29 changed files with 3,671 additions and 2,422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ protected void renderListBuildMethod(ListShape shape) {
dataName, "element", !shape.hasTrait(SparseTrait.class)));
})
.closeBlock("end")
.openBlock("\nif input.empty?")
.write("params[context[0...context.rindex('.')]] = ''")
.closeBlock("end")
.closeBlock("end");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ protected void renderListBuildMethod(ListShape shape) {
dataName, "element", !shape.hasTrait(SparseTrait.class)));
})
.closeBlock("end")
.openBlock("\nif input.empty?")
.write("params[context[0...context.rindex('.')]] = ''")
.closeBlock("end")
.closeBlock("end");

}
Expand Down
132 changes: 66 additions & 66 deletions gems/aws-sdk-lambda/lib/aws-sdk-lambda/builders.rb

Large diffs are not rendered by default.

1,593 changes: 868 additions & 725 deletions gems/aws-sdk-lambda/lib/aws-sdk-lambda/client.rb

Large diffs are not rendered by default.

54 changes: 36 additions & 18 deletions gems/aws-sdk-lambda/lib/aws-sdk-lambda/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

module AWS::SDK::Lambda
# @!method initialize(*options)
# @option args [AWS::SDK::Core::CredentialProvider] :credential_provider (*AWS::SDK::Core::CREDENTIAL_PROVIDER_CHAIN)
# @option args [AWS::SDK::Core::CredentialProvider] :credential_provider
# A credential provider is a class that fetches your AWS credentials. This can be an instance
# of any one of the following classes:
#
Expand Down Expand Up @@ -55,12 +55,18 @@ module AWS::SDK::Lambda
# @option args [Hearth::HTTP::Client] :http_client (Hearth::HTTP::Client.new)
# The HTTP Client to use for request transport.
#
# @option args [Hearth::InterceptorList] :interceptors (Hearth::InterceptorList.new)
# A list of Interceptors to apply to the client. Interceptors are a generic extension point that allows injecting logic at specific stages of execution within the SDK. Logic injection is done with hooks that the interceptor implements. Hooks are either read-only or read/write. Read-only hooks allow an interceptor to read the input, transport request, transport response or output messages. Read/write hooks allow an interceptor to modify one of these messages.
#
# @option args [Symbol] :log_level (:info)
# The default log level to use with the Logger.
#
# @option args [Logger] :logger (Logger.new($stdout, level: cfg.log_level))
# The Logger instance to use for logging.
#
# @option args [Hearth::PluginList] :plugins (Hearth::PluginList.new)
# A list of Plugins to apply to the client. Plugins are callables that take one argument: Config. Plugins may modify the provided config.
#
# @option args [String] :profile (default)
# The AWS region to connect to. The configured `:region` is
# used to determine the service `:endpoint`. When not passed,
Expand Down Expand Up @@ -105,12 +111,18 @@ module AWS::SDK::Lambda
# @!attribute http_client
# @return [Hearth::HTTP::Client]
#
# @!attribute interceptors
# @return [Hearth::InterceptorList]
#
# @!attribute log_level
# @return [Symbol]
#
# @!attribute logger
# @return [Logger]
#
# @!attribute plugins
# @return [Hearth::PluginList]
#
# @!attribute profile
# @return [String]
#
Expand All @@ -134,8 +146,10 @@ module AWS::SDK::Lambda
:disable_host_prefix,
:endpoint,
:http_client,
:interceptors,
:log_level,
:logger,
:plugins,
:profile,
:region,
:retry_strategy,
Expand All @@ -148,32 +162,36 @@ module AWS::SDK::Lambda

private

def validate!
Hearth::Validator.validate_types!(credential_provider, AWS::SDK::Core::CredentialProvider, context: 'options[:credential_provider]')
Hearth::Validator.validate_types!(disable_host_prefix, TrueClass, FalseClass, context: 'options[:disable_host_prefix]')
Hearth::Validator.validate_types!(endpoint, String, context: 'options[:endpoint]')
Hearth::Validator.validate_types!(http_client, Hearth::HTTP::Client, context: 'options[:http_client]')
Hearth::Validator.validate_types!(log_level, Symbol, context: 'options[:log_level]')
Hearth::Validator.validate_types!(logger, Logger, context: 'options[:logger]')
Hearth::Validator.validate_types!(profile, String, context: 'options[:profile]')
Hearth::Validator.validate_types!(region, String, context: 'options[:region]')
Hearth::Validator.validate_types!(retry_strategy, Hearth::Retry::Strategy, context: 'options[:retry_strategy]')
Hearth::Validator.validate_types!(signer, AWS::SigV4::Signer, context: 'options[:signer]')
Hearth::Validator.validate_types!(stub_responses, TrueClass, FalseClass, context: 'options[:stub_responses]')
Hearth::Validator.validate_types!(validate_input, TrueClass, FalseClass, context: 'options[:validate_input]')
def validate_types!
Hearth::Validator.validate_types!(credential_provider, AWS::SDK::Core::CredentialProvider, context: 'config[:credential_provider]')
Hearth::Validator.validate_types!(disable_host_prefix, TrueClass, FalseClass, context: 'config[:disable_host_prefix]')
Hearth::Validator.validate_types!(endpoint, String, context: 'config[:endpoint]')
Hearth::Validator.validate_types!(http_client, Hearth::HTTP::Client, context: 'config[:http_client]')
Hearth::Validator.validate_types!(interceptors, Hearth::InterceptorList, context: 'config[:interceptors]')
Hearth::Validator.validate_types!(log_level, Symbol, context: 'config[:log_level]')
Hearth::Validator.validate_types!(logger, Logger, context: 'config[:logger]')
Hearth::Validator.validate_types!(plugins, Hearth::PluginList, context: 'config[:plugins]')
Hearth::Validator.validate_types!(profile, String, context: 'config[:profile]')
Hearth::Validator.validate_types!(region, String, context: 'config[:region]')
Hearth::Validator.validate_types!(retry_strategy, Hearth::Retry::Strategy, context: 'config[:retry_strategy]')
Hearth::Validator.validate_types!(signer, AWS::SigV4::Signer, context: 'config[:signer]')
Hearth::Validator.validate_types!(stub_responses, TrueClass, FalseClass, context: 'config[:stub_responses]')
Hearth::Validator.validate_types!(validate_input, TrueClass, FalseClass, context: 'config[:validate_input]')
end

def self.defaults
@defaults ||= {
credential_provider: [*AWS::SDK::Core::CREDENTIAL_PROVIDER_CHAIN],
credential_provider: [proc { *AWS::SDK::Core::CREDENTIAL_PROVIDER_CHAIN }],
disable_host_prefix: [false],
endpoint: [proc { |cfg| cfg[:stub_responses] ? 'http://localhost' : nil } ],
endpoint: [proc { |cfg| cfg[:stub_responses] ? 'http://localhost' : nil }],
http_client: [proc { |cfg| Hearth::HTTP::Client.new(logger: cfg[:logger]) }],
interceptors: [proc { Hearth::InterceptorList.new }],
log_level: [:info],
logger: [proc { |cfg| Logger.new($stdout, level: cfg[:log_level]) } ],
logger: [proc { |cfg| Logger.new($stdout, level: cfg[:log_level]) }],
plugins: [proc { Hearth::PluginList.new }],
profile: [Hearth::Config::EnvProvider.new('AWS_PROFILE', type: 'String'),'default'],
region: [Hearth::Config::EnvProvider.new('AWS_REGION', type: 'String'),AWS::SDK::Core::SharedConfigProvider.new('region', type: 'String')],
retry_strategy: [Hearth::Retry::Standard.new],
retry_strategy: [proc { Hearth::Retry::Standard.new }],
signer: [proc { |cfg| AWS::SigV4::Signer.new(service: 'lambda', region: cfg[:region], credential_provider: cfg[:credential_provider]) }],
stub_responses: [false],
validate_input: [true]
Expand Down
Loading

0 comments on commit 5cc9628

Please sign in to comment.