Sha256: ee07c37abdbf6165de1de53173ed5719b1c59622509a0b536fb9d7dda78c3871

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'fog/core/collection'
require 'fog/azurerm/models/network/public_ip'

module Fog
  module Network
    class AzureRM
      # PublicIPs collection class for Network Service
      class PublicIps < Fog::Collection
        model Fog::Network::AzureRM::PublicIp
        attribute :resource_group

        def all
          requires :resource_group
          public_ips = []
          pubip_list = service.list_public_ips(resource_group)
          pubip_list.each do |pip|
            hash = {}
            pip.instance_variables.each do |var|
              hash[var.to_s.delete('@')] = pip.instance_variable_get(var)
            end
            hash['resource_group'] = resource_group
            public_ips << hash
          end
          load(public_ips)
        end

        def get(identity)
          all.find { |f| f.name == identity }
        end

        def check_if_exists(resource_group, name)
          Fog::Logger.debug "Checkng if PublicIP #{name} exists."
          if service.check_for_public_ip(resource_group, name)
            Fog::Logger.debug "PublicIP #{name} exists."
            true
          else
            Fog::Logger.debug "PublicIP #{name} doesn't exists."
            false
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.1 lib/fog/azurerm/models/network/public_ips.rb