Sha256: 6fbe3620286c5325e416326a626199dbaae302cd09d09400b20a0d65212a67a0

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module Fog
  module DNS
    class AzureRM
      class Real
        def delete_record_set(record_set_name, dns_resource_group, zone_name, record_type)
          resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}/#{record_type}/#{record_set_name}?api-version=2015-05-04-preview"
          Fog::Logger.debug "Deleting RecordSet #{record_set_name} of type '#{record_type}' in zone #{zone_name}"

          begin
            token = Fog::Credentials::AzureRM.get_token(@tenant_id, @client_id, @client_secret)
            RestClient.delete(
                resource_url,
                accept: 'application/json',
                content_type: 'application/json',
                authorization: token
            )
            Fog::Logger.debug "RecordSet #{record_set_name} Deleted Successfully!"
          rescue RestClient::Exception => e
            body = JSON.parse(e.http_body)
            if body.key?('error')
              body = body['error']
              msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
            else
              msg = "Exception deleting zone: #{body['code']}, #{body['message']}"
            end
            raise msg
          end
        end
      end

      class Mock
        def delete_record_set(record_set_name, dns_resource_group, zone_name, record_type)

        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/requests/dns/delete_record_set.rb