Class: Seahorse::Client::Plugin

Inherits:
Object
  • Object
show all
Extended by:
HandlerBuilder
Defined in:
lib/seahorse/client/plugin.rb

Direct Known Subclasses

Aws::Plugins::APIGAuthorizerToken, Aws::Plugins::APIGCredentialsConfiguration, Aws::Plugins::APIGUserAgent, Aws::Plugins::ApiKey, Aws::Plugins::BearerAuthorization, Aws::Plugins::ChecksumAlgorithm, Aws::Plugins::ClientMetricsPlugin, Aws::Plugins::ClientMetricsSendPlugin, Aws::Plugins::CredentialsConfiguration, Aws::Plugins::DefaultsMode, Aws::Plugins::EndpointDiscovery, Aws::Plugins::EndpointPattern, Aws::Plugins::EventStreamConfiguration, Aws::Plugins::GlobalConfiguration, Aws::Plugins::HelpfulSocketErrors, Aws::Plugins::HttpChecksum, Aws::Plugins::IdempotencyToken, Aws::Plugins::InvocationId, Aws::Plugins::JsonvalueConverter, Aws::Plugins::Logging, Aws::Plugins::ParamConverter, Aws::Plugins::ParamValidator, Aws::Plugins::Protocols::ApiGateway, Aws::Plugins::Protocols::EC2, Aws::Plugins::Protocols::JsonRpc, Aws::Plugins::Protocols::Query, Aws::Plugins::Protocols::RestJson, Aws::Plugins::Protocols::RestXml, Aws::Plugins::Protocols::RpcV2, Aws::Plugins::RecursionDetection, Aws::Plugins::RegionalEndpoint, Aws::Plugins::RequestCompression, Aws::Plugins::ResponsePaging, Aws::Plugins::RetryErrors, Aws::Plugins::Sign, Aws::Plugins::SignatureV2, Aws::Plugins::SignatureV4, Aws::Plugins::StubResponses, Aws::Plugins::Telemetry, Aws::Plugins::TransferEncoding, Aws::Plugins::UserAgent, Aws::SSO::Plugins::Endpoints, Aws::SSOOIDC::Plugins::Endpoints, Aws::STS::Plugins::Endpoints, Aws::STS::Plugins::STSRegionalEndpoints, Seahorse::Client::Plugins::ContentLength, Seahorse::Client::Plugins::Endpoint, Seahorse::Client::Plugins::H2, Seahorse::Client::Plugins::Logging, Seahorse::Client::Plugins::NetHttp, Seahorse::Client::Plugins::OperationMethods, Seahorse::Client::Plugins::RaiseResponseErrors, Seahorse::Client::Plugins::RequestCallback, Seahorse::Client::Plugins::ResponseTarget

Defined Under Namespace

Classes: CodeLiteral, PluginOption

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HandlerBuilder

handle, handle_request, handle_response, handler_for, new_handler

Class Method Details

.after_initialize(&block) ⇒ Object



71
72
73
# File 'lib/seahorse/client/plugin.rb', line 71

def after_initialize(&block)
  after_initialize_hooks << block
end

.after_initialize_hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



91
92
93
# File 'lib/seahorse/client/plugin.rb', line 91

def after_initialize_hooks
  @after_initialize_hooks ||= []
end

.before_initialize(&block) ⇒ Object



67
68
69
# File 'lib/seahorse/client/plugin.rb', line 67

def before_initialize(&block)
  before_initialize_hooks << block
end

.before_initialize_hooksObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



86
87
88
# File 'lib/seahorse/client/plugin.rb', line 86

def before_initialize_hooks
  @before_initialize_hooks ||= []
end

.handlersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



81
82
83
# File 'lib/seahorse/client/plugin.rb', line 81

def handlers
  @handlers ||= HandlerList.new
end

.literal(string) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



96
97
98
# File 'lib/seahorse/client/plugin.rb', line 96

def literal(string)
  CodeLiteral.new(string)
end

.option(name, options = {}, &block) ⇒ void

This method returns an undefined value.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :default (Object)

    Can also be set by passing a block.

  • :doc_default (String)
  • :required (Boolean)
  • :doc_type (String)
  • :docs (String)


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/seahorse/client/plugin.rb', line 54

def option(name, default = nil, options = {}, &block)
  # For backwards-compat reasons, the default value can be passed as 2nd
  # positional argument (before the options hash) or as the `:default` option
  # in the options hash.
  if default.is_a? Hash
    options = default
  else
    options[:default] = default
  end
  options[:default_block] = block if block_given?
  self.options << PluginOption.new(name, options)
end

.optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



76
77
78
# File 'lib/seahorse/client/plugin.rb', line 76

def options
  @options ||= []
end

Instance Method Details

#add_handlers(handlers, config) ⇒ void

This method returns an undefined value.

Parameters:



24
25
26
# File 'lib/seahorse/client/plugin.rb', line 24

def add_handlers(handlers, config)
  handlers.copy_from(self.class.handlers)
end

#add_options(config) ⇒ void

This method returns an undefined value.

Parameters:



11
12
13
14
15
16
17
18
19
# File 'lib/seahorse/client/plugin.rb', line 11

def add_options(config)
  self.class.options.each do |option|
    if option.default_block
      config.add_option(option.name, &option.default_block)
    else
      config.add_option(option.name, option.default)
    end
  end
end

#after_initialize(client) ⇒ void

This method returns an undefined value.

Parameters:



39
40
41
42
43
# File 'lib/seahorse/client/plugin.rb', line 39

def after_initialize(client)
  self.class.after_initialize_hooks.each do |block|
    block.call(client)
  end
end

#before_initialize(client_class, options) ⇒ void

This method returns an undefined value.

Parameters:



31
32
33
34
35
# File 'lib/seahorse/client/plugin.rb', line 31

def before_initialize(client_class, options)
  self.class.before_initialize_hooks.each do |block|
    block.call(client_class, options)
  end
end