Sha256: b000d91c976c7ef77b9fdace180e78703da0467482b753a9ca31f47da3cd93bd

Contents?: true

Size: 934 Bytes

Versions: 9

Compression:

Stored size: 934 Bytes

Contents

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

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

9 entries across 9 versions & 2 rubygems

Version Path
fog-softlayer-1.0.1 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-1.0.0 lib/fog/softlayer/models/network/datacenters.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-softlayer-0.4.7/lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.7 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.6 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.5 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.4 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.3 lib/fog/softlayer/models/network/datacenters.rb
fog-softlayer-0.4.2 lib/fog/softlayer/models/network/datacenters.rb