Skip to content
Merged
Show file tree
Hide file tree
Changes from 102 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
aabc0ed
Revert revert set of api and shapes changes
jterapin Dec 12, 2024
8de8dc5
Revert "Revert "Revert "Remove API and Operation in favor for shapes"""
jterapin Dec 12, 2024
f55501b
Add more shapes and update documentation
jterapin Dec 13, 2024
476ba78
Update shape documentation for Timestamp
jterapin Dec 13, 2024
d2c3cb8
Add more shapes and add a new file - prelude shapes
jterapin Dec 13, 2024
cd0b7de
Merge branch 'decaf' into decaf-api
jterapin Dec 13, 2024
e87c7e5
Update shape docs
jterapin Dec 13, 2024
f0dd1e6
Update prelude shapes
jterapin Dec 13, 2024
2db8d33
Merge branch 'decaf' into decaf-api
jterapin Dec 13, 2024
a9736db
Revert changes related to member vise
jterapin Dec 13, 2024
b90fdae
Update prelude shapes to include in client module
jterapin Dec 13, 2024
b49b650
Merge decaf into branch
jterapin Dec 13, 2024
361ce67
Merge decaf into branch
jterapin Dec 16, 2024
63dceeb
Relocate prelude shapes
jterapin Dec 16, 2024
c5ec635
Add api to the client
jterapin Dec 16, 2024
416f313
Fix prelude shapes
jterapin Dec 16, 2024
96c8202
Make minor adjustments
jterapin Dec 17, 2024
e309773
Merge decaf into branch
jterapin Dec 18, 2024
777b1c8
Clean up conflicts
jterapin Dec 18, 2024
d090515
Merge branch 'decaf' into decaf-api
jterapin Dec 18, 2024
5bb2449
Adjust views based on recent changes
jterapin Dec 18, 2024
ddde53f
Update to config and client to base on service and operation shapes
jterapin Dec 18, 2024
556c9ca
Added intEnum shape
jterapin Dec 18, 2024
e89e212
Update file names to shapes
jterapin Dec 19, 2024
8b726af
Merge branch 'decaf' into decaf-api
jterapin Dec 19, 2024
a23b9be
Add service def to shapes
jterapin Dec 19, 2024
d08cfb9
Update client to reflect service shape updates
jterapin Dec 19, 2024
f7ecf76
Appease rubocop
jterapin Dec 19, 2024
be46e1b
Appease rubocop
jterapin Dec 19, 2024
8a770d5
Appease rubocop again
jterapin Dec 19, 2024
407d38b
Add demo for reviewing purposes
jterapin Dec 19, 2024
409ef39
Update rubocop conflict
jterapin Dec 19, 2024
294249a
Revert "Add demo for reviewing purposes"
jterapin Dec 19, 2024
ff5d8d8
Remove API and Operation in favor for shapes
jterapin Dec 19, 2024
2582091
Add schema
jterapin Dec 19, 2024
5139776
Merge branch 'decaf' into decaf-api
jterapin Dec 20, 2024
8cca891
Revert "Update client to reflect service shape updates"
jterapin Dec 20, 2024
940ad73
Update client shapes
jterapin Dec 21, 2024
18a65ef
Update codegen shapes
jterapin Dec 21, 2024
4dbbbce
Fix existing specs
jterapin Dec 21, 2024
a8d56c3
Update readme to include a client creation
jterapin Dec 23, 2024
20fa83c
Update to get client in a working state
jterapin Dec 23, 2024
04798d9
Appease rubocop
jterapin Dec 23, 2024
fe22d0c
Fix shape generation
jterapin Dec 23, 2024
1d31250
Fix shape generation again
jterapin Dec 23, 2024
12650cc
Update fixture model to include documentation trait
jterapin Dec 23, 2024
5aa7057
Update top level model to include documentation trait
jterapin Dec 23, 2024
e48e6a4
Fix operation shape
jterapin Dec 23, 2024
732940e
Add shapes specs
jterapin Dec 23, 2024
5e7e3a9
Uncomment client specs now that they are passing
jterapin Dec 23, 2024
97fbed6
Merge branch 'decaf' into decaf-api
jterapin Dec 23, 2024
f1fe3a6
Update new specs to use schema
jterapin Dec 23, 2024
8ff9846
Fix failures
jterapin Dec 23, 2024
542e5ff
Appease rubocop
jterapin Dec 23, 2024
6a939e0
Add demo
jterapin Dec 23, 2024
e24cada
Make minor adjustment to shapes spec
jterapin Dec 23, 2024
33b867c
Revert "Update fixture model to include documentation trait"
jterapin Dec 23, 2024
6bfdfd8
Revert "Update top level model to include documentation trait"
jterapin Dec 23, 2024
8168853
Revert "Add demo"
jterapin Dec 23, 2024
3b867b1
Testing
jterapin Dec 23, 2024
cc1d7f0
Add more testingh
jterapin Dec 23, 2024
dec6863
debugging cont
jterapin Dec 23, 2024
7685060
Reapply "Add demo"
jterapin Dec 23, 2024
839b3e5
Add shapes fixtures
jterapin Dec 23, 2024
32a2a4d
Revert "debugging cont"
jterapin Dec 23, 2024
105dc32
Merge decaf into branch
jterapin Dec 24, 2024
8ed9042
Remove Enum Shapes expectation to have Type variation
jterapin Dec 24, 2024
c8d99ad
Add union to types view
jterapin Dec 24, 2024
b48b8d1
Update to handle different type of members
jterapin Dec 26, 2024
7adca52
Update smithy-client shapes specs to handle different type of members
jterapin Dec 26, 2024
2254a10
Add shape tests
jterapin Dec 26, 2024
7e7a64a
Merge branch 'decaf' into decaf-api
jterapin Dec 26, 2024
b98fe14
Fix merged in failures
jterapin Dec 26, 2024
1abb5df
Fix rubocop failure
jterapin Dec 26, 2024
e4e6f7a
Remove dummy file
jterapin Dec 26, 2024
0b9690a
Merge decaf into branch
jterapin Dec 27, 2024
e2f1154
Remove to fix
jterapin Dec 27, 2024
c4e204e
Add doc fix
jterapin Dec 27, 2024
5374bb0
Update MapShape to only have key and value attributes
jterapin Dec 27, 2024
39b120e
Remove Prelude prefix
jterapin Dec 30, 2024
78737ad
Update shapes based on feedback
jterapin Dec 30, 2024
d5266d4
Clean up shapes view
jterapin Dec 30, 2024
956e722
Update IRB path
jterapin Dec 30, 2024
b818b14
Update documentation
jterapin Dec 30, 2024
d26e0fb
Update smithy client shapes specs
jterapin Dec 30, 2024
b2fb7de
Update shapes
jterapin Dec 30, 2024
8602b24
Update fixture model
jterapin Dec 30, 2024
d417e23
Merge decaf into branch
jterapin Jan 3, 2025
5f25273
Updates shapes to use the new index
jterapin Jan 3, 2025
6434ec6
Merge branch 'decaf' into decaf-api
jterapin Jan 3, 2025
b909034
Update based on feedbacks
jterapin Jan 3, 2025
d15bf05
Minor tweaks
jterapin Jan 3, 2025
76151e2
Update projections
jterapin Jan 3, 2025
9fc289f
Fix ERB formatting
jterapin Jan 3, 2025
4358d5a
Fix rubocop failure
jterapin Jan 3, 2025
3bea282
Light updates
jterapin Jan 3, 2025
ece751b
Fix trait typo
jterapin Jan 3, 2025
509b708
Merge branch 'decaf' into decaf-api
jterapin Jan 6, 2025
5254267
Update based on feedback
jterapin Jan 6, 2025
9a9101d
Add shapes
jterapin Jan 6, 2025
4d0aac6
Merge decaf into branch
jterapin Jan 6, 2025
bf14d58
Fix errors
jterapin Jan 6, 2025
a823c49
Update member method name
jterapin Jan 6, 2025
47952d7
Minor tweak
jterapin Jan 6, 2025
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
6 changes: 3 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Metrics/BlockLength:
Metrics/ClassLength:
Max: 200

Metrics/MethodLength:
Max: 20

Metrics/ModuleLength:
Exclude:
- '**/spec/**/*.rb'

Metrics/MethodLength:
Max: 20

Naming/FileName:
Exclude:
- '**/spec/**/*.rb'
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ local build using smithy cli
bundle exec smithy build --debug model/weather.smithy
```

local build using smithy-ruby executable
local build using smithy-ruby executable:
```
export SMITHY_PLUGIN_DIR=build/smithy/source/smithy-ruby
bundle exec smithy-ruby smith client --gem-name weather --gem-version 1.0.0 --destination-root projections/weather <<< $(smithy ast model/weather.smithy)
```

IRB on weather gem
IRB on `weather` gem:
```
irb -I build/smithy/weather/smithy-ruby/lib -I gems/smithy-client/lib -r weather
irb -I projections/weather/lib -I gems/smithy-client/lib -r weather
```

Create a Weather client:
```
client = Weather::Client.new(endpoint: 'https://example.com')
client.get_current_time
```

Build a fixture
Expand Down
4 changes: 2 additions & 2 deletions gems/smithy-client/lib/smithy-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

# model

require_relative 'smithy-client/api'
require_relative 'smithy-client/base'
require_relative 'smithy-client/errors'
require_relative 'smithy-client/operation'
require_relative 'smithy-client/schema'
require_relative 'smithy-client/shapes'
require_relative 'smithy-client/structure'

# endpoints
Expand Down
26 changes: 13 additions & 13 deletions gems/smithy-client/lib/smithy-client/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def build_input(operation_name, params = {})
# names. These are valid arguments to {#build_input} and are also
# valid methods.
def operation_names
self.class.api.operation_names
self.class.schema.operation_names
end

# @api private
Expand All @@ -58,12 +58,12 @@ def inspect
# opportunity to register options with default values.
def build_config(plugins, options)
config = Configuration.new
config.add_option(:api)
config.add_option(:schema)
config.add_option(:plugins)
plugins.each do |plugin|
plugin.add_options(config) if plugin.respond_to?(:add_options)
end
config.build!(options.merge(api: self.class.api))
config.build!(options.merge(schema: self.class.schema))
end

# Gives each plugin the opportunity to register handlers for this client.
Expand All @@ -84,7 +84,7 @@ def after_initialize(plugins)
def context_for(operation_name, params)
HandlerContext.new(
operation_name: operation_name,
operation: config.api.operation(operation_name),
operation: config.schema.operation(operation_name),
client: self,
params: params,
config: config
Expand Down Expand Up @@ -162,24 +162,24 @@ def plugins
Array(@plugins).freeze
end

# @return [API]
def api
@api ||= API.new
# @return [Schema]
def schema
@schema ||= Schema.new
end

# @param [API] api
def api=(api)
@api = api
# @param [Schema] schema
def schema=(schema)
@schema = schema
define_operation_methods
end

# @option options [API] :api (API.new)
# @option options [Schema] :schema (Schema.new)
# @option options [Array<Plugin>] :plugins ([]) A list of plugins to
# add to the client class created.
# @return [Class<Client::Base>]
def define(options = {})
subclass = Class.new(self)
subclass.api = options[:api] || api
subclass.schema = options[:schema] || schema
Array(options[:plugins]).each do |plugin|
subclass.add_plugin(plugin)
end
Expand All @@ -191,7 +191,7 @@ def define(options = {})

def define_operation_methods
operations_module = Module.new
@api.operation_names.each do |method_name|
@schema.operation_names.each do |method_name|
operations_module.send(:define_method, method_name) do |*args, &block|
params = args[0] || {}
options = args[1] || {}
Expand Down
4 changes: 2 additions & 2 deletions gems/smithy-client/lib/smithy-client/handler_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Client
# Context that is passed to handlers during execution.
class HandlerContext
# @option options [Symbol] :operation_name (nil)
# @option options [Operation] :operation (nil)
# @option options [OperationShape] :operation (nil)
# @option options [Base] :client (nil)
# @option options [Hash] :params ({})
# @option options [Configuration] :config (nil)
Expand All @@ -26,7 +26,7 @@ def initialize(options = {})
# @return [Symbol] Name of the API operation called.
attr_accessor :operation_name

# @return [Operation]
# @return [OperationShape] Shape of the Operation called.
attr_accessor :operation

# @return [Base]
Expand Down
25 changes: 0 additions & 25 deletions gems/smithy-client/lib/smithy-client/operation.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@
module Smithy
module Client
# @api private
class API
class Schema
include Enumerable

def initialize
@metadata = {}
@service = nil
@operations = {}
yield self if block_given?
end

# @return [String, nil]
attr_accessor :version
# @return [ServiceShape, nil]
attr_accessor :service

# @return [Hash]
attr_accessor :metadata
# @return [Hash<Symbol, OperationShape>]
attr_accessor :operations

# @return [OperationShape]
def add_operation(name, operation)
@operations[name] = operation
end

# @return [Hash<Symbol, OperationShape>]
def each(&)
@operations.each(&)
end

# @return [Array<Symbol>]
def add_operation(name, operation)
@operations[name] = operation
# @return [String]
def inspect
"#<#{self.class.name}>"
end

# @param [String] name
# @return [Operation]
# @return [OperationShape] operation
def operation(name)
raise ArgumentError, "unknown operation #{name.inspect}" unless @operations.key?(name)

Expand All @@ -39,11 +45,6 @@ def operation(name)
def operation_names
@operations.keys
end

# @api private
def inspect
"#<#{self.class.name}>"
end
end
end
end
Loading
Loading