Module: PuppetRestClient::PE::Config
- Included in:
- PuppetRestClient::PE
- Defined in:
- lib/puppet-rest/pe/config.rb
Constant Summary collapse
- DEFAULT_SERVER_URL =
The default Chef server URL
'http://localhost:8140'
- DEFAULT_USER_AGENT =
The default Spice User-Agent header
"PuppetRestClient #{PuppetRestClient::VERSION}"
- DEFAULT_CONNECTION_OPTIONS =
Default connection options
{}
- DEFAULT_CLIENT_NAME =
Default client name
''
- DEFAULT_CLIENT_KEY =
Default key file
''
- DEFAULT_ENVIRONMENT =
'production'
- DEFAULT_ACCEPT =
'pson'
- DEFAULT_API_VERSION =
Default puppetpe rest api version v1, v2 leave blank 2015.2 or greater pass in ‘puppet/v3’
nil
- VALID_OPTIONS_KEYS =
An array of valid config options
[ :server_url, :environment, :api_version, :client_name, :client_key, :user_agent, :connection_options, :middleware, :accept ]
- DEFAULT_MIDDLEWARE =
Default middleware stack
Proc.new do |builder| builder.use PuppetRestClient::Response::ParseJSON builder.use PuppetRestClient::Response::ClientError builder.adapter Faraday.default_adapter end
Class Method Summary collapse
-
.extended(base) ⇒ Object
Reset all config options to default when the module is extended.
Instance Method Summary collapse
-
#options ⇒ Object
Create an options hash from valid options keys.
-
#reset ⇒ Object
Reset all config options to their defaults.
-
#setup {|PuppetRestClient| ... } ⇒ Object
Convenience method to configure PuppetRestClient in a block.
Class Method Details
.extended(base) ⇒ Object
Reset all config options to default when the module is extended
53 54 55 |
# File 'lib/puppet-rest/pe/config.rb', line 53 def self.extended(base) base.reset end |
Instance Method Details
#options ⇒ Object
Create an options hash from valid options keys
72 73 74 75 76 |
# File 'lib/puppet-rest/pe/config.rb', line 72 def = {} VALID_OPTIONS_KEYS.each{|k| [k] = send(k)} end |
#reset ⇒ Object
Reset all config options to their defaults
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/puppet-rest/pe/config.rb', line 79 def reset self.user_agent = DEFAULT_USER_AGENT self.environment = DEFAULT_ENVIRONMENT self.api_version = DEFAULT_API_VERSION self.server_url = DEFAULT_SERVER_URL self.client_name = DEFAULT_CLIENT_NAME self.client_key = DEFAULT_CLIENT_KEY self. = DEFAULT_CONNECTION_OPTIONS self.middleware = DEFAULT_MIDDLEWARE self.accept = DEFAULT_ACCEPT self end |
#setup {|PuppetRestClient| ... } ⇒ Object
Convenience method to configure PuppetRestClient in a block
66 67 68 69 |
# File 'lib/puppet-rest/pe/config.rb', line 66 def setup yield self self end |