Sha256: 129ec2e951348a1b1179ed03d1d5e97ea8879b20d160032ec88ba41a2759f5a5

Contents?: true

Size: 1.23 KB

Versions: 12

Compression:

Stored size: 1.23 KB

Contents

module Fog
  module Compute
    class Google
      class GlobalAddresses < Fog::Collection
        model Fog::Compute::Google::GlobalAddress

        def all(options = {})
          data = service.list_global_addresses(options).to_h[:items] || []
          load(data)
        end

        def get(identity)
          if identity
            address = service.get_global_address(identity).to_h
            return new(address)
          end
        rescue ::Google::Apis::ClientError => e
          raise e unless e.status_code == 404
          nil
        end

        def get_by_ip_address(ip_address)
          data = service.list_global_addresses(:filter => "address eq #{ip_address}")
          if data.nil? || data.items.nil?
            nil
          else
            new(data.items.first.to_h)
          end
        end

        def get_by_name(ip_name)
          data = service.list_global_addresses(:filter => "name eq #{ip_name}")
          if data.nil? || data.items.nil?
            nil
          else
            new(data.items.first.to_h)
          end
        end

        def get_by_ip_address_or_name(ip_address_or_name)
          get_by_ip_address(ip_address_or_name) || get_by_name(ip_address_or_name)
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
gitlab-fog-google-1.14.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.13.0 lib/fog/compute/google/models/global_addresses.rb
gitlab-fog-google-1.13.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.12.1 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.12.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.11.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.10.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.9.1 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.9.0 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.8.2 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.8.1 lib/fog/compute/google/models/global_addresses.rb
fog-google-1.8.0 lib/fog/compute/google/models/global_addresses.rb