Sha256: 536ec938d2b454aa88c758b131082ffc9f683b7fd8320bd1a282dcc1c5e1ca01

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

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

module Fog
  module Account
    class Softlayer
      class Mock
        # Create a Brand
        # @param [Hash] attributes
        # @return [Excon::Response]
        def create_brand(attributes)
          raise ArgumentError, "Fog::Account::Softlayer#create_brand expects argument of type Hash" unless attributes.kind_of?(Hash)
          response = Excon::Response.new
          required = %w{keyName longName name account}
          if Fog::Softlayer.valid_request?(required, attributes)
            response.status = 201
            response.body = { :id => Fog::Softlayer.mock_vm_id.to_i, :catalogId => 14 }.merge(attributes)
            @brands << response.body
          else
            response.status = 500
            response.body = {
              "code" => "SoftLayer_Exception_MissingCreationProperty",
              "error" => "Properties #{required.join(', ')} ALL must be set to create an instance of 'SoftLayer_Brand'."
            }
          end
          response
        end
      end

      class Real
        def create_brand(attributes)
          request(:brand, :create_object, :body => attributes, :http_method => :POST)
        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/requests/account/create_brand.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/account/create_brand.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-softlayer-1.1.4/lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.1.4 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.1.3 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.1.2 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.1.1 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.1.0 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.0.3 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.0.2 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.0.1 lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-1.0.0 lib/fog/softlayer/requests/account/create_brand.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/lib/fog/softlayer/requests/account/create_brand.rb
fog-softlayer-0.4.7 lib/fog/softlayer/requests/account/create_brand.rb