Module: Rancher::Api

Defined in:
lib/rancher/api.rb,
lib/rancher/api/logger.rb,
lib/rancher/api/version.rb,
lib/rancher/api/models/host.rb,
lib/rancher/api/configuration.rb,
lib/rancher/api/helpers/model.rb,
lib/rancher/api/models/machine.rb,
lib/rancher/api/models/project.rb,
lib/rancher/api/models/service.rb,
lib/rancher/api/models/instance.rb,
lib/rancher/api/models/registry.rb,
lib/rancher/api/models/ipaddress.rb,
lib/rancher/api/models/environment.rb,
lib/rancher/api/models/instance/action.rb,
lib/rancher/api/models/registrycredential.rb,
lib/rancher/api/models/machine/driver_config.rb,
lib/rancher/api/middlewares/json_parser_middleware.rb

Defined Under Namespace

Modules: Helpers Classes: Configuration, Environment, Host, Instance, Ipaddress, JsonParserMiddleware, Logger, Machine, Project, Registry, Registrycredential, Service

Constant Summary collapse

VERSION =
'0.7.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



20
21
22
# File 'lib/rancher/api.rb', line 20

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rancher/api.rb', line 28

def self.configure
  yield(configuration)

  api = Her::API.setup url: configuration.url do |c|
    # Request
    c.request :json

    c.use Her::Middleware::AcceptJSON
    c.use Faraday::Request::BasicAuthentication, configuration.access_key, configuration.secret_key

    # Response
    c.use Rancher::Api::JsonParserMiddleware
    c.use Her::Middleware::DefaultParseJSON
    c.use Faraday::Response::Logger, ActiveSupport::Logger.new(STDOUT) if configuration.verbose

    # Adapter
    c.use Faraday::Adapter::NetHttp
  end

  require 'rancher/api/models'
  api
end

.resetObject



24
25
26
# File 'lib/rancher/api.rb', line 24

def self.reset
  @configuration = Configuration.new
end

.setup!Object



15
16
17
18
# File 'lib/rancher/api.rb', line 15

def self.setup!
  configure do |_x|
  end
end