Sha256: 3353063c543198eb57cdb30d4a59fa1d32f191e9de225ca937b0ca84836aaa8e

Contents?: true

Size: 1.73 KB

Versions: 14

Compression:

Stored size: 1.73 KB

Contents

#
# Author:: Matheus Francisco Barra Mina (<mfbmina@gmail.com>)
# © Copyright IBM Corporation 2015.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

require 'fog/softlayer/compute/shared'

module Fog
  module Account
    class Softlayer < Fog::Service
      # Client credentials
      requires :softlayer_username, :softlayer_api_key

      model_path 'fog/softlayer/models/account'
      collection    :brands
      model         :brand

      request_path 'fog/softlayer/requests/account'
      request :create_brand
      request :get_account_owned_brands
      request :get_brand
      request :get_brand_owned_accounts

      # The Mock Service allows you to run a fake instance of the Service
      # which makes no real connections.
      #
      #
      class Mock
        include Fog::Softlayer::Compute::Shared

        def initialize(options={})
          @brands = []
          @accounts = [{'id' => 1}]
          super(options)
        end

        def credentials
          { :provider           => 'softlayer',
            :softlayer_username => @softlayer_username,
            :softlayer_api_key  => @softlayer_api_key
          }
        end
      end

      ##
      # Makes real connections to Softlayer.
      #
      class Real
        include Fog::Softlayer::Slapi
        include Fog::Softlayer::Compute::Shared

        def initialize(options={})
          @softlayer_api_key = options[:softlayer_api_key]
          @softlayer_username = options[:softlayer_username]
        end

        def request(service, path, options = {})
          options = {:username => @softlayer_username, :api_key => @softlayer_api_key}.merge(options)
          Fog::Softlayer::Slapi.slapi_request(service, path, options)
        end
      end
    end
  end
end

Version data entries

14 entries across 12 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/account.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/account.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/account.rb
fog-softlayer-1.1.4 lib/fog/softlayer/account.rb
fog-softlayer-1.1.3 lib/fog/softlayer/account.rb
fog-softlayer-1.1.2 lib/fog/softlayer/account.rb
fog-softlayer-1.1.1 lib/fog/softlayer/account.rb
fog-softlayer-1.1.0 lib/fog/softlayer/account.rb
fog-softlayer-1.0.3 lib/fog/softlayer/account.rb
fog-softlayer-1.0.2 lib/fog/softlayer/account.rb
fog-softlayer-1.0.1 lib/fog/softlayer/account.rb
fog-softlayer-1.0.0 lib/fog/softlayer/account.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/lib/fog/softlayer/account.rb
fog-softlayer-0.4.7 lib/fog/softlayer/account.rb