Sha256: c4e76ddb585a6537cbe4dc976ec29762e87f7442531317cfdb939966b71c28a3

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

require File.expand_path('../lan', __FILE__)
require File.expand_path('../../helpers/compute/data_helper', __dir__)

module Fog
  module Compute
    class ProfitBricks
      class Lans < Fog::Collection
        include Fog::Helpers::ProfitBricks::DataHelper
        model Fog::Compute::ProfitBricks::Lan

        def all(datacenter_id)
          result = service.get_all_lans(datacenter_id)

          lans = result.body['items'].each {|lan|
            lan['datacenter_id'] = datacenter_id
          }

          result.body['items'] = lans

          load(result.body['items'].each {|lan| flatten(lan)})
        end

        def get(datacenter_id, lan_id)
          lan = service.get_lan(datacenter_id, lan_id).body

          Excon::Errors
          lan['datacenter_id'] = datacenter_id

          new(flatten(lan))
        rescue Excon::Errors::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-profitbricks-2.0.1 lib/fog/profitbricks/models/compute/lans.rb