Sha256: 8e439890ba3e47dcd19780006e43492748fe8626b04222455a7ba2bd00cddfee

Contents?: true

Size: 990 Bytes

Versions: 38

Compression:

Stored size: 990 Bytes

Contents

require 'fog/core/collection'
require 'fog/linode/models/compute/ip'

module Fog
  module Compute
    class Linode
      class Ips < Fog::Collection
        model Fog::Compute::Linode::Ip
        attribute :server

        def all
          requires :server
          load ips(server.id)
        end

        def get(id)
          requires :server
          new ips(server.id, id).first
        rescue Fog::Compute::Linode::NotFound
          nil
        end

        def new(attributes = {})
          requires :server
          super({ :server => server }.merge!(attributes))
        end

        private
        def ips(linode_id, id=nil)
          connection.linode_ip_list(linode_id, id).body['DATA'].map { |ip| map_ip ip }
        end
        
        def map_ip(ip)
          ip = ip.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v  }
          ip.merge! :id => ip[:ipaddressid], :ip => ip[:ipaddress], :public => ip[:ispublic]==1
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 13 rubygems

Version Path
fog-1.2.0 lib/fog/linode/models/compute/ips.rb
ktheory-fog-1.1.2 lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
fog-1.1.2 lib/fog/linode/models/compute/ips.rb
fog_tractical-1.1.4 lib/fog/linode/models/compute/ips.rb
fog_tractical-1.1.3 lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
fog-1.1.1 lib/fog/linode/models/compute/ips.rb
fog-1.1.0 lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.15.0 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
tag-fog-1.0.1 lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.14.1 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
brightbox-cli-0.14.0 lib/brightbox-cli/vendor/fog/lib/fog/linode/models/compute/ips.rb
fog-1.0.0 lib/fog/linode/models/compute/ips.rb