Module: MgmtConsole::Default

Defined in:
lib/mgmt_console/default.rb

Overview

Default configuration options for Client

Constant Summary collapse

API_ENDPOINT =

Default API endpoint

"https://console.mindjet.com/api/v1".freeze
USER_AGENT =

Default User Agent header string

"Mgmt Console Ruby Gem #{MgmtConsole::VERSION}".freeze
SSL_VERIFY =

Default SSL verify

true.freeze
MEDIA_TYPE =

Default media type

"application/json".freeze
WEB_ENDPOINT =

Default WEB endpoint

"https://console.mindjet.com".freeze
RACK_BUILDER_CLASS =

In Faraday 0.9, Faraday::Builder was renamed to Faraday::RackBuilder

defined?(Faraday::RackBuilder) ? Faraday::RackBuilder : Faraday::Builder
MIDDLEWARE =

Default Faraday middleware stack

RACK_BUILDER_CLASS.new do |builder|
  builder.use MgmtConsole::Response::RaiseError
  builder.use MgmtConsole::Response::FeedParser
  builder.adapter Faraday.default_adapter
end

Class Method Summary collapse

Class Method Details

.access_tokenString

Default access token from ENV

Returns:

  • (String)


45
46
47
# File 'lib/mgmt_console/default.rb', line 45

def access_token
  ENV['MGMT_CONSOLE_ACCESS_TOKEN']
end

.api_endpointString

Default API endpoint from ENV or API_ENDPOINT

Returns:

  • (String)


51
52
53
# File 'lib/mgmt_console/default.rb', line 51

def api_endpoint
  ENV['MGMT_CONSOLE_API_ENDPOINT'] || API_ENDPOINT
end

.auto_paginateString

Default pagination preference from ENV

Returns:

  • (String)


57
58
59
# File 'lib/mgmt_console/default.rb', line 57

def auto_paginate
  ENV['MGMT_CONSOLE_AUTO_PAGINATE']
end

.connection_optionsHash

Default options for Faraday::Connection

Returns:

  • (Hash)


63
64
65
66
67
68
69
70
# File 'lib/mgmt_console/default.rb', line 63

def connection_options
  {
    :headers => {
      :accept => default_media_type,
      :user_agent => user_agent
    }
  }
end

.default_media_typeString

Default media type from ENV or MEDIA_TYPE

Returns:

  • (String)


80
81
82
# File 'lib/mgmt_console/default.rb', line 80

def default_media_type
  ENV['MGMT_CONSOLE_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
end

.middlewareString

Default middleware stack for Faraday::Connection from MIDDLEWARE

Returns:

  • (String)


87
88
89
# File 'lib/mgmt_console/default.rb', line 87

def middleware
  MIDDLEWARE
end

.optionsHash

Configuration options

Returns:

  • (Hash)


39
40
41
# File 'lib/mgmt_console/default.rb', line 39

def options
  Hash[MgmtConsole::Configurable.keys.map{|key| [key, send(key)]}]
end

.passwordString

Default GitHub password for Basic Auth from ENV

Returns:

  • (String)


93
94
95
# File 'lib/mgmt_console/default.rb', line 93

def password
  ENV['MGMT_CONSOLE_PASSWORD']
end

.per_pageFixnum

Default pagination page size from ENV

Returns:

  • (Fixnum)

    Page size



99
100
101
102
103
# File 'lib/mgmt_console/default.rb', line 99

def per_page
  page_size = ENV['MGMT_CONSOLE_PER_PAGE']

  page_size.to_i if page_size
end

.proxyString

Default proxy server URI for Faraday connection from ENV

Returns:

  • (String)


107
108
109
# File 'lib/mgmt_console/default.rb', line 107

def proxy
  ENV['MGMT_CONSOLE_PROXY']
end

.ssl_verifyBoolean

Default ssl verify from ENV or SSL_VERIFY

Returns:

  • (Boolean)


74
75
76
# File 'lib/mgmt_console/default.rb', line 74

def ssl_verify
  ENV['MGMT_CONSOLE_SSL_VERIFY'] || SSL_VERIFY
end

.user_agentString

Default User-Agent header string from ENV or USER_AGENT

Returns:

  • (String)


113
114
115
# File 'lib/mgmt_console/default.rb', line 113

def user_agent
  ENV['MGMT_CONSOLE_USER_AGENT'] || USER_AGENT
end

.web_endpointString

Default web endpoint from ENV or WEB_ENDPOINT

Returns:

  • (String)


119
120
121
# File 'lib/mgmt_console/default.rb', line 119

def web_endpoint
  ENV['MGMT_CONSOLE_WEB_ENDPOINT'] || WEB_ENDPOINT
end