Module: Controls::Configurable
Overview
Instance Attribute Summary collapse
-
#api_endpoint ⇒ String
The endpoint to connect to.
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#connection_options ⇒ Hash
The current connection options (headers, etc.).
-
#default_media_type ⇒ String
The default media type to send with requests.
-
#middleware ⇒ Faraday::Connection
The middleware used to send requests.
-
#netrc ⇒ Boolean
Whether to use the netrc credentials to authentcicate with the **controls**insight API.
-
#netrc_file ⇒ String
The path of the .netrc file to look for credentials in.
-
#password ⇒ Object
writeonly
Sets the attribute password.
-
#user_agent ⇒ String
The user agent to send with API requests.
-
#username ⇒ String
The username to use for authentication.
-
#web_endpoint ⇒ String
The endpoint to connect to.
Class Method Summary collapse
-
.keys ⇒ Array<Symbol>
A list of configurable keys.
Instance Method Summary collapse
- #configure {|self| ... } ⇒ Object
- #netrc? ⇒ Boolean
-
#setup ⇒ self
Configures Configurable to use options found in Default.
Instance Attribute Details
#api_endpoint ⇒ String
Returns the endpoint to connect to. default: nexpose.local:3780/insight/controls/api/1.0.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 def api_endpoint @api_endpoint end |
#api_version ⇒ Object
Returns the value of attribute api_version.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 def api_version @api_version end |
#connection_options ⇒ Hash
Returns the current connection options (headers, etc.).
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#default_media_type ⇒ String
Returns the default media type to send with requests. default: application/json.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#middleware ⇒ Faraday::Connection
Returns the middleware used to send requests.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#netrc ⇒ Boolean
Returns whether to use the netrc credentials to authentcicate with the **controls**insight API.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#netrc_file ⇒ String
Returns the path of the .netrc file to look for credentials in. default: ~/.netrc.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#password=(value) ⇒ Object (writeonly)
Sets the attribute password
31 32 33 |
# File 'lib/controls/configurable.rb', line 31 def password=(value) @password = value end |
#user_agent ⇒ String
Returns the user agent to send with API requests. example: “controls/v1.0.0.beta (ruby; 2.0.0p247; [x86_64-darwin12.4.0]; Faraday v0.8.8)”.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#username ⇒ String
Returns the username to use for authentication.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
#web_endpoint ⇒ String
Returns the endpoint to connect to. default: nexpose.local:3780/insight/controls.
25 26 27 |
# File 'lib/controls/configurable.rb', line 25 attr_accessor :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :user_agent, :username, :web_endpoint |
Class Method Details
.keys ⇒ Array<Symbol>
Returns a list of configurable keys.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/controls/configurable.rb', line 35 def keys @keys ||= [ :api_endpoint, :api_version, :connection_options, :default_media_type, :middleware, :netrc, :netrc_file, :password, :user_agent, :username, :web_endpoint ] end |
Instance Method Details
#configure {|self| ... } ⇒ Object
53 54 55 |
# File 'lib/controls/configurable.rb', line 53 def configure yield self end |
#netrc? ⇒ Boolean
57 58 59 |
# File 'lib/controls/configurable.rb', line 57 def netrc? !!@netrc end |
#setup ⇒ self
Configures Controls::Configurable to use options found in Default
65 66 67 68 69 70 71 |
# File 'lib/controls/configurable.rb', line 65 def setup Controls::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", Controls::Default.[key]) end self end |