Skip to content

Do not dynamically define operation methods #3235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
require_relative 'aws-sdk-code-generator/rbs/resource_batch_action'
require_relative 'aws-sdk-code-generator/rbs/resource_client_request'
require_relative 'aws-sdk-code-generator/rbs/waiter'
require_relative 'aws-sdk-code-generator/views/rbs/async_client_class'
require_relative 'aws-sdk-code-generator/views/rbs/client_class'
require_relative 'aws-sdk-code-generator/views/rbs/errors_module'
require_relative 'aws-sdk-code-generator/views/rbs/resource_class'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def structure(ref, context, visited)
event_ctx = shape['members'].each.inject([]) do |ctx, (member_name, member_ref)|
event_type = Underscore.underscore(member_name).to_sym
event_types << event_type
ctx << "For #{event_type.inspect} event available at #on_#{event_type}_event callback"\
ctx << "# For #{event_type.inspect} event available at #on_#{event_type}_event callback"\
' and response eventstream enumerator:'
event_entry = entry(member_ref, 'event', Set.new).join("\n ")
ctx << (event_entry.empty? ? ' #=> EmptyStruct' : event_entry + "\n")
end
# Add eventstream entry
event_ctx.unshift("#{context}.event_types #=> #{event_types.inspect}\n")
event_ctx.unshift("#{context} #=> Enumerator")
event_ctx.unshift("All events are available at #{context}:")
event_ctx.unshift("# All events are available at #{context}:")
return event_ctx
elsif shape['members']
shape['members'].each_pair do |member_name, member_ref|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,14 @@ def rbs_files(options = {})
Enumerator.new do |y|
prefix = options.fetch(:prefix, '')
codegenerated_plugins = codegen_plugins(prefix)
client_class = Views::RBS::ClientClass.new(
service_name: @service.name,
codegenerated_plugins: codegenerated_plugins,
aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
legacy_endpoints: @service.legacy_endpoints?,
signature_version: @service.signature_version,
api: @service.api,
waiters: @service.waiters,
protocol: @service.protocol,
add_plugins: @service.add_plugins,
remove_plugins: @service.remove_plugins,
)
client_class = client_class_rbs(codegenerated_plugins)
y.yield("#{prefix}/client.rbs", client_class.render)
if @service.protocol_settings['h2']
y.yield(
"#{prefix}/async_client.rbs",
async_client_class_rbs(codegenerated_plugins).render
)
end
y.yield("#{prefix}/errors.rbs", Views::RBS::ErrorsModule.new(
service: @service
).render)
Expand All @@ -135,7 +130,7 @@ def rbs_files(options = {})
client_class: client_class,
api: @service.api,
resources: @service.resources,
paginators: @service.paginators,
paginators: @service.paginators
).render)
y.yield("#{prefix}/waiters.rbs", Views::RBS::WaitersModule.new(
service_name: @service.name,
Expand Down Expand Up @@ -206,6 +201,22 @@ def client_class(codegenerated_plugins)
).render
end

def client_class_rbs(codegenerated_plugins)
Views::RBS::ClientClass.new(
service_name: @service.name,
codegenerated_plugins: codegenerated_plugins,
aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
legacy_endpoints: @service.legacy_endpoints?,
signature_version: @service.signature_version,
api: @service.api,
waiters: @service.waiters,
protocol: @service.protocol,
add_plugins: @service.add_plugins,
remove_plugins: @service.remove_plugins,
protocol_settings: @service.protocol_settings
)
end

def async_client_class(codegenerated_plugins)
Views::AsyncClientClass.new(
service_identifier: @service.identifier,
Expand All @@ -226,6 +237,22 @@ def async_client_class(codegenerated_plugins)
).render
end

def async_client_class_rbs(codegenerated_plugins)
Views::RBS::AsyncClientClass.new(
service_name: @service.name,
codegenerated_plugins: codegenerated_plugins,
aws_sdk_core_lib_path: @aws_sdk_core_lib_path,
legacy_endpoints: @service.legacy_endpoints?,
signature_version: @service.signature_version,
api: @service.api,
protocol: @service.protocol,
add_plugins: @service.add_plugins,
remove_plugins: @service.remove_plugins,
protocol_settings: @service.protocol_settings,
async_client: true
)
end

def errors_module
Views::ErrorsModule.new(service: @service).render
end
Expand Down
Loading