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
Instance Attribute Summary collapse
-
#additional_user_agent ⇒ String
If set, then this string will be added to the user agent sent with each request.
-
#connection_timeout ⇒ Integer
The time limit for the connection phase in seconds.
-
#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
Defines the logger used for debugging.
-
#pass_phrase ⇒ String
Pass phrase used for key file, if it is encrypted.
-
#region ⇒ OCI::Regions::REGION_ENUM
A region to use for APIs created with this Config.
-
#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.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
94 95 96 97 98 99 |
# File 'lib/oci/config.rb', line 94 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.
92 93 94 |
# File 'lib/oci/config.rb', line 92 def additional_user_agent @additional_user_agent end |
#connection_timeout ⇒ Integer
The time limit for the connection phase in seconds. Defaults to 10 seconds.
86 87 88 |
# File 'lib/oci/config.rb', line 86 def connection_timeout @connection_timeout 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
29 30 31 |
# File 'lib/oci/config.rb', line 29 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”
50 51 52 |
# File 'lib/oci/config.rb', line 50 def key_content @key_content end |
#key_file ⇒ String
Client private key file. Example: ~/.ssh/oci_key
41 42 43 |
# File 'lib/oci/config.rb', line 41 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.
74 75 76 |
# File 'lib/oci/config.rb', line 74 def log_requests @log_requests end |
#logger ⇒ Logger
Defines the logger used for debugging. For example, log to STDOUT by setting this to Logger.new(STDOUT). This property cannot be set from a config file.
67 68 69 |
# File 'lib/oci/config.rb', line 67 def logger @logger end |
#pass_phrase ⇒ String
Pass phrase used for key file, if it is encrypted.
55 56 57 |
# File 'lib/oci/config.rb', line 55 def pass_phrase @pass_phrase end |
#region ⇒ OCI::Regions::REGION_ENUM
A region to use for APIs created with this Config.
60 61 62 |
# File 'lib/oci/config.rb', line 60 def region @region end |
#tenancy ⇒ String
OCID of the tenancy to use for authentication. Example: ocid1.tenancy.oc1..aaaaaaaaba3pv6wkcr4jqae5f15p2b2m2yt2j6rx32uzr4h25vqstifsfdsq
35 36 37 |
# File 'lib/oci/config.rb', line 35 def tenancy @tenancy end |
#timeout ⇒ Integer
The time limit for HTTP request in seconds. Defaults to 0 (times out in 365 days).
80 81 82 |
# File 'lib/oci/config.rb', line 80 def timeout @timeout end |
#user ⇒ String
OCID of the user to use for authentication. Example: ocidv1:user:oc1:phx:1460406592659:aaaaaaaawcbqrkycbolrirg2n3xjl5fabc
23 24 25 |
# File 'lib/oci/config.rb', line 23 def user @user end |
Instance Method Details
#validate ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/oci/config.rb', line 101 def validate %w[user fingerprint tenancy region].each do |name| if !instance_variable_defined?("@#{name}") || instance_variable_get("@#{name}").nil? raise OCI::InvalidConfigError, "The #{name} is missing in configuration." end end 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| if (pattern =~ instance_variable_get("@#{name}")).nil? raise OCI::InvalidConfigError, "The format of #{name} is invalid." end end end |