Sha256: 18072116ae1f2eaa6130a9d6170c35af5f47ad0dd6cc2b6d34cc86f4c9a66fe9

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module Fog
  module DNS
    class AzureRM
      class Real

        def delete_zone(zone_name, dns_resource_group)
          Fog::Logger.debug "Deleting Zone #{zone_name} ..."
          resource_url = "#{AZURE_RESOURCE}/subscriptions/#{@subscription_id}/resourceGroups/#{dns_resource_group}/providers/Microsoft.Network/dnsZones/#{zone_name}?api-version=2015-05-04-preview"
          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 "Zone #{zone_name} deleted successfully."
            true
          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_zone(zone_name, dns_resource_group)

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.1 lib/fog/azurerm/requests/dns/delete_zone.rb
fog-azure-rm-0.0.0 lib/fog/azurerm/requests/dns/delete_zone.rb