Sha256: 99cfb9ae09a8026b03daa1b936d6842f3a9f39950b269dd6f7003c29e213dab2

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

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

module Fog
  module Network
    class AzureRM
      # NetworkInterfaces collection class for Network Service
      class NetworkInterfaces < Fog::Collection
        model Fog::Network::AzureRM::NetworkInterface
        attribute :resource_group

        def all
          requires :resource_group
          network_interfaces = []
          network_interface_list = service.list_network_interfaces(resource_group)
          network_interface_list.each do |nic|
            hash = {}
            nic.instance_variables.each do |var|
              hash[var.to_s.delete('@')] = nic.instance_variable_get(var)
            end
            hash['resource_group'] = resource_group
            network_interfaces << hash
          end
          load(network_interfaces)
        end

        def get(identity)
          all.find { |f| f.name == identity }
        rescue Fog::Errors::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.0 lib/fog/azurerm/models/network/network_interfaces.rb