Sha256: 38ed500bafe949c372e04bcfcc86430023aebd2a0f19fad8c859a9ac467abd0c

Contents?: true

Size: 964 Bytes

Versions: 35

Compression:

Stored size: 964 Bytes

Contents

#
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
# © Copyright IBM Corporation 2014.
#
# LICENSE: MIT (http://opensource.org/licenses/MIT)
#

require 'fog/core/collection'
require 'fog/softlayer/models/network/datacenter'

module Fog
  module Network
    class Softlayer
      class Datacenters < Fog::Collection
        attribute :filters

        model Fog::Network::Softlayer::Datacenter

        def initialize(attributes)
          self.filters ||= {}
          super
        end

        def all(filters = filters)
          self.filters = filters
          load(service.get_datacenters.body)
        end

        def get(id)
          data = service.request(:location_datacenter, "#{id}/get_object").body
            new.merge_attributes(data)
        rescue Fog::Network::Softlayer::NotFound
          nil
        end

        def by_name(name)
          all.map { |dc| dc if dc.name == name }.compact.first
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
fog-softlayer-0.4.2.pre lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.1 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.0 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.30 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.29 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.28 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.27 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.26 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.25 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.24 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.23 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.22 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.21 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.20 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.19 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.18 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.17 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.16 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.15 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.3.14 lib/fog/softlayer/models/network/datacenters.rb