Class: OCI::Config
- Inherits:
-
Object
- Object
- OCI::Config
- Defined in:
- lib/oci/config.rb
Overview
This class contains accessors for configuration attributes needed when using the SDK
Constant Summary collapse
- OCI_REGION_ENV =
'OCI_REGION'.freeze
Instance Attribute Summary collapse
-
#additional_user_agent ⇒ String
If set, then this string will be added to the user agent sent with each request.
-
#authentication_type ⇒ String
The authentication type user want to apply Example: instance_principal.
-
#connection_timeout ⇒ Integer
The time limit for the connection phase in seconds.
-
#delegation_token_file ⇒ String
The file location of delegation token Example: ~/.oci/delegation.
-
#fingerprint ⇒ String
SSL Fingerprint to use for authentication.
-
#key_content ⇒ String
Client private key content.
-
#key_file ⇒ String
Client private key file.
-
#log_requests ⇒ true, false
Whether to log detailed request and response data.
-
#logger ⇒ Logger
Gets the logger used for debugging.
-
#pass_phrase ⇒ String
Pass phrase used for key file, if it is encrypted.
-
#region ⇒ OCI::Regions::REGION_ENUM
Gets the region var.
-
#tenancy ⇒ String
OCID of the tenancy to use for authentication.
-
#timeout ⇒ Integer
The time limit for HTTP request in seconds.
-
#user ⇒ String
OCID of the user to use for authentication.
Class Method Summary collapse
-
.validate_and_build_config_with_signer(config, signer) ⇒ Object
rubocop:enable Metrics/PerceivedComplexity.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#validate ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
107 108 109 110 111 112 |
# File 'lib/oci/config.rb', line 107 def initialize @timeout = 0 @connection_timeout = 10 @log_requests = false @key_content = nil end |
Instance Attribute Details
#additional_user_agent ⇒ String
If set, then this string will be added to the user agent sent with each request.
93 94 95 |
# File 'lib/oci/config.rb', line 93 def additional_user_agent @additional_user_agent end |
#authentication_type ⇒ String
The authentication type user want to apply Example: instance_principal
105 106 107 |
# File 'lib/oci/config.rb', line 105 def authentication_type @authentication_type end |
#connection_timeout ⇒ Integer
The time limit for the connection phase in seconds. Defaults to 10 seconds.
87 88 89 |
# File 'lib/oci/config.rb', line 87 def connection_timeout @connection_timeout end |
#delegation_token_file ⇒ String
The file location of delegation token Example: ~/.oci/delegation
99 100 101 |
# File 'lib/oci/config.rb', line 99 def delegation_token_file @delegation_token_file end |
#fingerprint ⇒ String
SSL Fingerprint to use for authentication. Example: 20:3b:97:13:55:1c:1c:0d:d3:37:d8:50:4e:c5:3a:12
32 33 34 |
# File 'lib/oci/config.rb', line 32 def fingerprint @fingerprint end |
#key_content ⇒ String
Client private key content. key_content takes precedence if both key_file and key_content are provided. For the security reason, don't provide the key content in the configuration file itself and it will be ignored by SDK. The value should be same as the content which is normally found in a .pem file. Example: “—–BEGIN RSA PRIVATE KEY—–nProc-Type: 4,ENCRYPTEDnDEK-Info: AES-128-CBC,D3D04C29BD3061489F4FF579A2133620nnjZO+B3DMBTz6Pszk0EUS8O2gU0T…jZpon—–END RSA PRIVATE KEY—–n”
53 54 55 |
# File 'lib/oci/config.rb', line 53 def key_content @key_content end |
#key_file ⇒ String
Client private key file. Example: ~/.ssh/oci_key
44 45 46 |
# File 'lib/oci/config.rb', line 44 def key_file @key_file end |
#log_requests ⇒ true, false
Whether to log detailed request and response data. This will always write to STDOUT. Defaults to false.
75 76 77 |
# File 'lib/oci/config.rb', line 75 def log_requests @log_requests end |
#logger ⇒ Logger
Gets the logger used for debugging. If nil, then OCI#logger will be returned instead.
117 118 119 120 121 |
# File 'lib/oci/config.rb', line 117 def logger return OCI.logger if @logger.nil? @logger end |
#pass_phrase ⇒ String
Pass phrase used for key file, if it is encrypted.
58 59 60 |
# File 'lib/oci/config.rb', line 58 def pass_phrase @pass_phrase end |
#region ⇒ OCI::Regions::REGION_ENUM
Gets the region var. If the region doesn't exist, check OCI_REGION_ENV env var to search for it
126 127 128 129 130 |
# File 'lib/oci/config.rb', line 126 def region @region ||= ENV[OCI::Config::OCI_REGION_ENV] @region end |
#tenancy ⇒ String
OCID of the tenancy to use for authentication. Example: ocid1.tenancy.oc1..aaaaaaaaba3pv6wkcr4jqae5f15p2b2m2yt2j6rx32uzr4h25vqstifsfdsq
38 39 40 |
# File 'lib/oci/config.rb', line 38 def tenancy @tenancy end |
#timeout ⇒ Integer
The time limit for HTTP request in seconds. Defaults to 0 (times out in 365 days).
81 82 83 |
# File 'lib/oci/config.rb', line 81 def timeout @timeout end |
#user ⇒ String
OCID of the user to use for authentication. Example: ocidv1:user:oc1:phx:1460406592659:aaaaaaaawcbqrkycbolrirg2n3xjl5fabc
26 27 28 |
# File 'lib/oci/config.rb', line 26 def user @user end |
Class Method Details
.validate_and_build_config_with_signer(config, signer) ⇒ Object
rubocop:enable Metrics/PerceivedComplexity
155 156 157 158 159 160 161 162 163 |
# File 'lib/oci/config.rb', line 155 def self.validate_and_build_config_with_signer(config, signer) config ||= OCI.config unless signer.is_a?(OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner) || \ signer.is_a?(OCI::Auth::Signers::SecurityTokenSigner) config ||= OCI::Config.new if signer.is_a?(OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner) || \ signer.is_a?(OCI::Auth::Signers::SecurityTokenSigner) config.validate unless signer.is_a?(OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner) || \ signer.is_a?(OCI::Auth::Signers::SecurityTokenSigner) config end |
Instance Method Details
#validate ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/oci/config.rb', line 133 def validate # currently, config file auth type only supports delegation token auth which is `instance_principal` based auth return unless @authentication_type.nil? && @delegation_token_file.nil? %w[user fingerprint tenancy].each do |name| if !instance_variable_defined?("@#{name}") || instance_variable_get("@#{name}").nil? raise OCI::InvalidConfigError, "The #{name} is missing in configuration." end end raise OCI::InvalidConfigError, 'The region is missing in configuration or environment variable.' if @region.nil? if (!instance_variable_defined?('@key_file') || instance_variable_get('@key_file').nil?) && @key_content.nil? raise OCI::InvalidConfigError, 'The key_file and key_content cannot both be missing in configuration.' end PATTERNS.each do |name, pattern| raise OCI::InvalidConfigError, "The format of #{name} is invalid." if (pattern =~ instance_variable_get("@#{name}")).nil? end end |