Skip to content

Commit

Permalink
Fix generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mullermp committed Oct 20, 2023
1 parent 43eb4bb commit efa28fb
Showing 1 changed file with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,13 @@ def initialize(options)
Param.new(Underscore.underscore(k), v)
end
@client_params += options[:built_in_params].map do |k,v|
if k == 'AWS::Auth::CredentialScope'
Param.new(
'credentials',
"Aws::Credentials.new('stubbed-akid', 'stubbed-secret', nil, '#{v}')"
)
# the expected default of UseGlobalEndpoint does not match
# the Ruby SDK's default value
elsif @service.identifier == 's3' && k == 'AWS::S3::UseGlobalEndpoint'
built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
else
built_in_to_param(k, v)
end
built_in_to_param(k, v)
end
# the expected default of UseGlobalEndpoint in rules
# does not match the Ruby SDK's default value
if @service.identifier == 's3' &&
!options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint')
@client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false)
end
end

Expand Down Expand Up @@ -155,17 +150,21 @@ def transform_operation_values(value)
def built_in_to_param(built_in, value)
case built_in
when 'AWS::Region'
Param.new('region', "'#{value}'")
Param.new('region', value)
when 'AWS::UseFIPS'
Param.new('use_fips_endpoint', value)
when 'AWS::UseDualStack'
Param.new('use_dualstack_endpoint', value)
when 'AWS::Auth::CredentialScope'
Param.new(
'credentials',
"Aws::Credentials.new('stubbed-akid', 'stubbed-secret', nil, '#{value}')",
true
)
when 'AWS::STS::UseGlobalEndpoint'
val = value ? 'legacy' : 'regional'
Param.new('sts_regional_endpoints', "'#{val}'")
Param.new('sts_regional_endpoints', value ? 'legacy' : 'regional')
when 'AWS::S3::UseGlobalEndpoint'
val = value ? 'legacy' : 'regional'
Param.new('s3_us_east_1_regional_endpoint', "'#{val}'")
Param.new('s3_us_east_1_regional_endpoint', value ? 'legacy' : 'regional')
when 'AWS::S3::Accelerate'
Param.new('use_accelerate_endpoint', value)
when 'AWS::S3::ForcePathStyle'
Expand All @@ -175,20 +174,29 @@ def built_in_to_param(built_in, value)
when 'AWS::S3::DisableMultiRegionAccessPoints'
Param.new('s3_disable_multiregion_access_points', value)
when 'SDK::Endpoint'
Param.new('endpoint', "'#{value}'")
Param.new('endpoint', value)
else
raise ArgumentError, "#{built_in} not supported."
end
end
end

class Param
def initialize(param, value)
def initialize(param, value, literal = false)
@param = param
@value = value
@literal = literal
end

attr_accessor :param, :value
attr_accessor :param

def value
if @value.is_a?(String) && !@literal
"'#{@value}'"
else
@value
end
end
end

end
Expand Down

0 comments on commit efa28fb

Please sign in to comment.