Class: Seahorse::Client::Base
- Inherits:
-
Object
- Object
- Seahorse::Client::Base
show all
- Includes:
- HandlerBuilder
- Defined in:
- aws-sdk-core/lib/seahorse/client/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#handle, #handle_request, #handle_response
Instance Attribute Details
26
27
28
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 26
def config
@config
end
|
29
30
31
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 29
def handlers
@handlers
end
|
Class Method Details
.add_plugin(plugin) ⇒ void
This method returns an undefined value.
Registers a plugin with this client.
131
132
133
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 131
def add_plugin(plugin)
@plugins.add(plugin)
end
|
175
176
177
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 175
def api
@api ||= Model::Api.new
end
|
.clear_plugins ⇒ void
This method returns an undefined value.
149
150
151
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 149
def clear_plugins
@plugins.set([])
end
|
.define(options = {}) ⇒ Class<Client::Base>
Also known as:
extend
198
199
200
201
202
203
204
205
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 198
def define(options = {})
subclass = Class.new(self)
subclass.set_api(options[:api] || api)
Array(options[:plugins]).each do |plugin|
subclass.add_plugin(plugin)
end
subclass
end
|
.new(options = {}) ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 101
def new(options = {})
plugins = build_plugins
options = options.dup
before_initialize(plugins, options)
client = allocate
client.send(:initialize, plugins, options)
client
end
|
.plugins ⇒ Array<Plugin>
Returns the list of registered plugins for this Client. Plugins are
inherited from the client super class when the client is defined.
170
171
172
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 170
def plugins
Array(@plugins).freeze
end
|
.remove_plugin(plugin) ⇒ void
This method returns an undefined value.
140
141
142
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 140
def remove_plugin(plugin)
@plugins.remove(plugin)
end
|
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 181
def set_api(api)
@api =
case api
when nil then Model::Api.new({})
when Model::Api then api
when Hash then Model::Api.new(api)
when String, Pathname then Model::Api.new(Util.load_json(api))
else raise ArgumentError, "invalid api definition #{api}"
end
define_operation_methods
@api
end
|
.set_plugins(plugins) ⇒ void
This method returns an undefined value.
159
160
161
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 159
def set_plugins(plugins)
@plugins.set(plugins)
end
|
Instance Method Details
#build_request(operation_name, params = {}) ⇒ Request
Builds and returns a Request for the named operation. The request
will not have been sent.
35
36
37
38
39
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 35
def build_request(operation_name, params = {})
Request.new(
@handlers.for(operation_name),
context_for(operation_name, params))
end
|
43
44
45
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 43
def operation(name)
config.api.operation(name)
end
|
#operation_names ⇒ Array<Symbol>
55
56
57
|
# File 'aws-sdk-core/lib/seahorse/client/base.rb', line 55
def operation_names
self.class.api.operation_names
end
|