Sha256: 0bedcca29e4a51af64597ebcfe8f840589af7d20807b0ff40f5ee8056e1a07cb

Contents?: true

Size: 975 Bytes

Versions: 4

Compression:

Stored size: 975 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.setup!
      configure do |_x|
      end
    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

4 entries across 4 versions & 1 rubygems

Version Path
rancher-api-0.4.0 lib/rancher/api.rb
rancher-api-0.3.8 lib/rancher/api.rb
rancher-api-0.3.7 lib/rancher/api.rb
rancher-api-0.3.6 lib/rancher/api.rb