Class: SwaggerPetstoreOpenApi30::Client
- Inherits:
-
Object
- Object
- SwaggerPetstoreOpenApi30::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/swagger_petstore_open_api30/client.rb
Overview
swagger_petstore_open_api30 client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
Instance Method Summary collapse
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, petstore_auth_credentials: nil, api_key_credentials: nil, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#pet ⇒ PetApi
Access to pet controller.
-
#petstore_auth ⇒ Object
Returns the configured authentication petstore_auth instance.
-
#store ⇒ StoreApi
Access to store controller.
-
#user ⇒ UserApi
Access to user controller.
- #user_agent_detail ⇒ Object
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, petstore_auth_credentials: nil, api_key_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 39 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put get put], http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, petstore_auth_credentials: nil, api_key_credentials: nil, config: nil ) @config = if config.nil? Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, proxy_settings: proxy_settings, logging_configuration: logging_configuration, environment: environment, petstore_auth_credentials: petstore_auth_credentials, api_key_credentials: api_key_credentials ) else config end user_agent_params = BaseApi.user_agent_parameters @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseApi::GLOBAL_ERRORS) .user_agent(BaseApi.user_agent, agent_parameters: user_agent_params) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
10 11 12 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 10 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
89 90 91 92 93 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 89 def self.from_env(**overrides) default_config = Configuration.build_default_config_from_env new_config = default_config.clone_with(**overrides) new(config: new_config) end |
Instance Method Details
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
78 79 80 81 82 83 84 85 86 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 78 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[petstore_auth api_key].each { |auth| @auth_managers[auth] = nil } @auth_managers['petstore_auth'] = PetstoreAuth.new( http_client_config.petstore_auth_credentials, global_config ) @auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials) end |
#pet ⇒ PetApi
Access to pet controller.
23 24 25 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 23 def pet @pet ||= PetApi.new @global_configuration end |
#petstore_auth ⇒ Object
Returns the configured authentication petstore_auth instance.
17 18 19 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 17 def petstore_auth @auth_managers['petstore_auth'] end |
#store ⇒ StoreApi
Access to store controller.
29 30 31 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 29 def store @store ||= StoreApi.new @global_configuration end |
#user ⇒ UserApi
Access to user controller.
35 36 37 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 35 def user @user ||= UserApi.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/swagger_petstore_open_api30/client.rb', line 12 def user_agent_detail config.user_agent_detail end |