Sha256: 7d803d3826a676c561fa668bd170f5b2635024f8fce1a58acb42bb2d72de19a0

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

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

module Fog
  module Compute
    class ProfitBricks
      class LoadBalancers < Fog::Collection
        include Fog::Helpers::ProfitBricks::DataHelper
        model Fog::Compute::ProfitBricks::LoadBalancer

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

          load_balancers = result.body['items'].each {|volume| volume['datacenter_id'] = datacenter_id}
          result.body['items'] = load_balancers

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

        def get(datacenter_id, load_balancer_id)
          response  = service.get_load_balancer(datacenter_id, load_balancer_id)
          load_balancer = response.body

          Excon::Errors
          load_balancer['datacenter_id'] = datacenter_id
          new(flatten(load_balancer))
        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/load_balancers.rb