Sha256: 3594b2ddd5442d8c00944c7b18639acdac32c6852d540a7f9f8352b4968f0a78

Contents?: true

Size: 1.14 KB

Versions: 23

Compression:

Stored size: 1.14 KB

Contents

require 'fog/core/collection'
require 'fog/google/models/compute/address'

module Fog
  module Compute
    class Google
      class Addresses < Fog::Collection
        model Fog::Compute::Google::Address

        def all(filters = {})
          if filters[:region]
            data = service.list_addresses(filters[:region]).body['items'] || []
          else
            data = []
            service.list_aggregated_addresses.body['items'].each_value do |region|
              data.concat(region['addresses']) if region['addresses']
            end
          end
          load(data)
        end

        def get(identity, region)
          if address = service.get_address(identity, region).body
            new(address)
          end
        rescue Fog::Errors::NotFound
          nil
        end

        def get_by_ip_address(ip_address)
          addresses = service.list_aggregated_addresses(:filter => "address eq .*#{ip_address}").body['items']
          address = addresses.each_value.select { |region| region.key?('addresses') }

          return nil if address.empty?
          new(address.first['addresses'].first)
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/google/models/compute/addresses.rb
fog-google-0.0.5 lib/fog/google/models/compute/addresses.rb
fog-google-0.0.4 lib/fog/google/models/compute/addresses.rb
fog-google-0.0.3 lib/fog/google/models/compute/addresses.rb
fog-google-0.0.2 lib/fog/google/models/compute/addresses.rb
fog-1.29.0 lib/fog/google/models/compute/addresses.rb
fog-1.28.0 lib/fog/google/models/compute/addresses.rb
fog-1.27.0 lib/fog/google/models/compute/addresses.rb
fog-1.26.0 lib/fog/google/models/compute/addresses.rb
fog-1.25.0 lib/fog/google/models/compute/addresses.rb
nsidc-fog-1.24.1 lib/fog/google/models/compute/addresses.rb
fog-1.24.0 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.11 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.10 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.9 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.8 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.7 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.6 lib/fog/google/models/compute/addresses.rb
fog-1.23.0 lib/fog/google/models/compute/addresses.rb
ns-fog-1.22.4 lib/fog/google/models/compute/addresses.rb