-
Notifications
You must be signed in to change notification settings - Fork 6
Types
Matt Muller edited this page Oct 5, 2021
·
6 revisions
Types are light-weight classes that contain shape data. Types are built from params on input and populated by service responses on output. Types have a 1:1 mapping to Smithy structure shapes.
module SampleService
module Types
MyOperationInput = Struct.new(
:id,
:nested,
keyword_init: true
) do
include Seahorse::Struct
end
end
end
Each Type includes the Seahorse::Struct
class. This class adds a to_h
method that deeply converts nested structs to hashes.
Types are automatically constructed using the Params module when a hash of params are passed into the Client's operation. Types can be constructed manually and passed into the Client's operation if desired.
# client.rb
def my_operation(params = {}, options = {})
stack = Seahorse::MiddlewareStack.new
# input is Types::MyOperationInput
input = Params::MyOperationInput.build(params: params)
stack.use(...)
...
resp = stack.run(input: input, ...)
...
end