Class: SwaggerPetstore::Configuration
- Inherits:
-
CoreLibrary::HttpClientConfiguration
- Object
- CoreLibrary::HttpClientConfiguration
- SwaggerPetstore::Configuration
- Defined in:
- lib/swagger_petstore/configuration.rb
Overview
All configuration including auth info and base URI for the API access are configured in this class.
Constant Summary collapse
- ENVIRONMENTS =
All the environments the SDK can run in.
{ Environment::PRODUCTION => { Server::DEFAULT => 'https://petstore.swagger.io/v2' }, Environment::ENVIRONMENT2 => { Server::DEFAULT => 'http://petstore.swagger.io/v2' }, Environment::ENVIRONMENT3 => { Server::DEFAULT => 'https://petstore.swagger.io/oauth' } }.freeze
Class Attribute Summary collapse
-
.environments ⇒ Object
readonly
Returns the value of attribute environments.
Instance Attribute Summary collapse
-
#api_key_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#environment ⇒ Object
readonly
The attribute readers for properties.
-
#http_basic_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#petstore_auth_credentials ⇒ Object
readonly
The attribute readers for properties.
-
#test_header ⇒ Object
readonly
The attribute readers for properties.
Instance Method Summary collapse
- #clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: nil) ⇒ Object
-
#get_base_uri(server = Server::DEFAULT) ⇒ String
Generates the appropriate base URI for the environment and the server.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::PRODUCTION, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: 'TestHeaderDefaultValue') ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, environment: Environment::PRODUCTION, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: 'TestHeaderDefaultValue') ⇒ Configuration
Returns a new instance of Configuration.
34 35 36 37 38 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 |
# File 'lib/swagger_petstore/configuration.rb', line 34 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, environment: Environment::PRODUCTION, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: 'TestHeaderDefaultValue' ) super 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 # Current API environment @environment = String(environment) # The object holding Custom Header Signature credentials @api_key_credentials = api_key_credentials # The object holding Basic Authentication credentials @http_basic_credentials = http_basic_credentials # The object holding OAuth 2 Implicit Grant credentials @petstore_auth_credentials = petstore_auth_credentials # This is a test header @test_header = test_header # The Http Client to use for making requests. set_http_client CoreLibrary::FaradayClient.new(self) end |
Class Attribute Details
.environments ⇒ Object (readonly)
Returns the value of attribute environments.
31 32 33 |
# File 'lib/swagger_petstore/configuration.rb', line 31 def environments @environments end |
Instance Attribute Details
#api_key_credentials ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/swagger_petstore/configuration.rb', line 27 def api_key_credentials @api_key_credentials end |
#environment ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/swagger_petstore/configuration.rb', line 27 def environment @environment end |
#http_basic_credentials ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/swagger_petstore/configuration.rb', line 27 def http_basic_credentials @http_basic_credentials end |
#petstore_auth_credentials ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/swagger_petstore/configuration.rb', line 27 def petstore_auth_credentials @petstore_auth_credentials end |
#test_header ⇒ Object (readonly)
The attribute readers for properties.
27 28 29 |
# File 'lib/swagger_petstore/configuration.rb', line 27 def test_header @test_header end |
Instance Method Details
#clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/swagger_petstore/configuration.rb', line 68 def clone_with(connection: nil, adapter: nil, timeout: nil, max_retries: nil, retry_interval: nil, backoff_factor: nil, retry_statuses: nil, retry_methods: nil, http_callback: nil, environment: nil, api_key_credentials: nil, http_basic_credentials: nil, petstore_auth_credentials: nil, test_header: nil) connection ||= self.connection adapter ||= self.adapter timeout ||= self.timeout max_retries ||= self.max_retries retry_interval ||= self.retry_interval backoff_factor ||= self.backoff_factor retry_statuses ||= self.retry_statuses retry_methods ||= self.retry_methods http_callback ||= self.http_callback environment ||= self.environment api_key_credentials ||= self.api_key_credentials http_basic_credentials ||= self.http_basic_credentials petstore_auth_credentials ||= self.petstore_auth_credentials test_header ||= self.test_header 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, environment: environment, api_key_credentials: api_key_credentials, http_basic_credentials: http_basic_credentials, petstore_auth_credentials: petstore_auth_credentials, test_header: test_header) end |
#get_base_uri(server = Server::DEFAULT) ⇒ String
Generates the appropriate base URI for the environment and the server. required.
120 121 122 |
# File 'lib/swagger_petstore/configuration.rb', line 120 def get_base_uri(server = Server::DEFAULT) ENVIRONMENTS[environment][server].clone end |