Sha256: c2a7f96d74e123653a6a4727fd025801e0a6fceb72613a18c6c8475655a63538

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require "fog/core/collection"
require "fog/azurerm/models/dns/record_set"

module Fog
  module DNS
    class AzureRM
      class RecordSets < Fog::Collection

        attribute :resource_group
        attribute :zone_name
        attribute :type

        model Fog::DNS::AzureRM::RecordSet

        def all
          requires :resource_group
          requires :zone_name
          record_sets = []
          exclude = false
          service.list_record_sets(resource_group, zone_name).each do |r|
            hash = {}
            r.each do |k, v|
              if (k == 'name' && v == '@')
                exclude = true
              end
              hash[k] = v
              hash['zone_name'] = zone_name
              hash['resource_group'] = resource_group
            end
            record_sets << hash if !exclude
            exclude = false
          end
          load(record_sets)
        end

        def get(identity, type)
          all.find { |f| f.name == identity && f.type == "Microsoft.Network/dnszones/#{type}"}
        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/dns/record_sets.rb