Class: NetboxClientRuby::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/netbox_client_ruby/connection.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  request_encoding: :json
}.freeze

Class Method Summary collapse

Class Method Details

.auth_configObject



21
22
23
# File 'lib/netbox_client_ruby/connection.rb', line 21

def self.auth_config
  netbox_config.auth
end

.headersObject



13
14
15
16
17
18
19
# File 'lib/netbox_client_ruby/connection.rb', line 13

def self.headers
  headers = {}
  auth_token = auth_config.token
  headers['Authorization'] = "Token #{auth_token}".freeze if auth_token
  headers['X-Session-Key'] = NetboxClientRuby::Secrets.session_key if NetboxClientRuby::Secrets.session_key
  headers
end

.netbox_configObject



25
26
27
# File 'lib/netbox_client_ruby/connection.rb', line 25

def self.netbox_config
  NetboxClientRuby.config.netbox
end

.new(options = {}) ⇒ Object



9
10
11
# File 'lib/netbox_client_ruby/connection.rb', line 9

def self.new(options = {})
  build_faraday(**DEFAULT_OPTIONS.merge(options))
end