Sha256: 2987d9bf8ac0486e00b8f756701de07d2cd92e15955a5e7134f3f7c229669432

Contents?: true

Size: 912 Bytes

Versions: 6

Compression:

Stored size: 912 Bytes

Contents

require 'faraday_middleware'
require 'her'

require 'rancher/api/configuration'
require 'rancher/api/middlewares'
require 'rancher/api/version'

module Rancher
  module Api
    class << self
      attr_writer :configuration
    end

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

    def self.reset
      @configuration = Configuration.new
    end

    def self.configure
      yield(configuration)

      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

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

      require 'rancher/api/models'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rancher-api-0.3.5 lib/rancher/api.rb
rancher-api-0.3.3 lib/rancher/api.rb
rancher-api-0.3.2 lib/rancher/api.rb
rancher-api-0.3.1 lib/rancher/api.rb
rancher-api-0.3.0 lib/rancher/api.rb
rancher-api-0.2.0 lib/rancher/api.rb