/// <summary>
 /// Creates or updates a record set within a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Record sets of type SOA can be
 /// updated but not created (they are created when the DNS zone is created).
 /// Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR',
 /// 'SOA', 'SRV', 'TXT'
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the CreateOrUpdate operation.
 /// </param>
 /// <param name='ifMatch'>
 /// The etag of the record set. Omit this value to always overwrite the current
 /// record set. Specify the last-seen etag value to prevent accidentally
 /// overwritting any concurrent changes.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Set to '*' to allow a new record set to be created, but to prevent updating
 /// an existing record set. Other values will be ignored.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RecordSetInner> CreateOrUpdateAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, RecordSetInner parameters, string ifMatch = default(string), string ifNoneMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch, ifNoneMatch, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Lists the record sets of a specified type in a Private DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='privateZoneName'>
 /// The name of the Private DNS zone (without a terminating dot).
 /// </param>
 /// <param name='recordType'>
 /// The type of record sets to enumerate. Possible values include: 'A', 'AAAA',
 /// 'CNAME', 'MX', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 /// <param name='top'>
 /// The maximum number of record sets to return. If not specified, returns up
 /// to 100 record sets.
 /// </param>
 /// <param name='recordsetnamesuffix'>
 /// The suffix label of the record set name to be used to filter the record set
 /// enumeration. If this parameter is specified, the returned enumeration will
 /// only contain records that end with ".&lt;recordsetnamesuffix&gt;".
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IPage <RecordSet> > ListByTypeAsync(this IRecordSetsOperations operations, string resourceGroupName, string privateZoneName, RecordType recordType, int?top = default(int?), string recordsetnamesuffix = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListByTypeWithHttpMessagesAsync(resourceGroupName, privateZoneName, recordType, top, recordsetnamesuffix, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Lists all record sets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='top'>
 /// The maximum number of record sets to return. If not specified, returns up
 /// to 100 record sets.
 /// </param>
 /// <param name='recordSetNameSuffix'>
 /// The suffix label of the record set name that has to be used to filter the
 /// record set enumerations. If this parameter is specified, Enumeration will
 /// return only records that end with .&lt;recordSetNameSuffix&gt;
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IPage <RecordSetInner> > ListAllByDnsZoneAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, int?top = default(int?), string recordSetNameSuffix = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListAllByDnsZoneWithHttpMessagesAsync(resourceGroupName, zoneName, top, recordSetNameSuffix, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Lists all RecordSets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the zone.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the zone from which to enumerate RecordSets.
 /// </param>
 /// <param name='top'>
 /// Query parameters. If null is passed returns the default number of zones.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IPage <RecordSet> > ListAllInResourceGroupAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string top = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListAllInResourceGroupWithHttpMessagesAsync(resourceGroupName, zoneName, top, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Gets a record set.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Possible values include: 'A',
 /// 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <RecordSetInner> GetAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Lists all record sets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='nextPageLink'>
 /// The NextLink from the previous successful call to List operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IPage <RecordSetInner> > ListAllByDnsZoneNextAsync(this IRecordSetsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.ListAllByDnsZoneNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #7
0
 public static async Task <RecordSet> GetOrDefaultAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType)
 {
     try
     {
         return(await operations.GetAsync(resourceGroupName, zoneName, relativeRecordSetName, RecordType.TXT));
     }
     catch
     {
         return(null);
     }
 }
        private async Task <RecordSet> GetOrCreateRecordSetAsync(IRecordSetsOperations recordSetClient, RecordType type, string resourceGroup, string zoneName, string name, string value)
        {
            RecordSet set = null !;

            try
            {
                set = await recordSetClient.GetAsync(resourceGroup, zoneName, name, type);
            }
            catch (CloudException e)
            {
                if (e.Response.StatusCode != System.Net.HttpStatusCode.NotFound)
                {
                    throw;
                }
            }

            if (set == null)
            {
                set = new RecordSet(name: name, tTL: 1);
                switch (type)
                {
                case RecordType.TXT:
                    set.TxtRecords = new List <TxtRecord>();
                    break;

                default:
                    throw new Exception("Record type is unsupported: " + type.ToString());
                }
            }


            switch (type)
            {
            case RecordType.TXT:
                set.TxtRecords.Add(new TxtRecord(new[] { value }));
                break;

            default:
                throw new Exception("Record type is unsupported: " + type.ToString());
            }

            return(set);
        }
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     PrivateZones        = new PrivateZonesOperations(this);
     VirtualNetworkLinks = new VirtualNetworkLinksOperations(this);
     RecordSets          = new RecordSetsOperations(this);
     BaseUri             = new System.Uri("https://management.azure.com");
     ApiVersion          = "2018-09-01";
     AcceptLanguage      = "en-US";
     LongRunningOperationRetryTimeout = 30;
     GenerateClientRequestId          = true;
     SerializationSettings            = new JsonSerializerSettings
     {
         Formatting            = Newtonsoft.Json.Formatting.Indented,
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     SerializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = Newtonsoft.Json.DateTimeZoneHandling.Utc,
         NullValueHandling     = Newtonsoft.Json.NullValueHandling.Ignore,
         ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
     DeserializationSettings.Converters.Add(new TransformationJsonConverter());
     DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
 }
 /// <summary>
 /// Deletes a record set from a DNS zone. This operation cannot be undone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Record sets of type SOA cannot
 /// be deleted (they are deleted when the DNS zone is deleted). Possible values
 /// include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV',
 /// 'TXT'
 /// </param>
 /// <param name='ifMatch'>
 /// The etag of the record set. Omit this value to always delete the current
 /// record set. Specify the last-seen etag value to prevent accidentally
 /// deleting any concurrent changes.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteAsync(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, string ifMatch = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, ifMatch, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <summary>
 /// Lists all RecordSets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group that contains the zone.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the zone from which to enumerate RecordSets.
 /// </param>
 /// <param name='top'>
 /// Query parameters. If null is passed returns the default number of zones.
 /// </param>
 public static IPage <RecordSet> ListAllInResourceGroup(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string top = default(string))
 {
     return(Task.Factory.StartNew(s => ((IRecordSetsOperations)s).ListAllInResourceGroupAsync(resourceGroupName, zoneName, top), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Lists all record sets in a Private DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='privateZoneName'>
 /// The name of the Private DNS zone (without a terminating dot).
 /// </param>
 /// <param name='top'>
 /// The maximum number of record sets to return. If not specified, returns up
 /// to 100 record sets.
 /// </param>
 /// <param name='recordsetnamesuffix'>
 /// The suffix label of the record set name to be used to filter the record set
 /// enumeration. If this parameter is specified, the returned enumeration will
 /// only contain records that end with ".&lt;recordsetnamesuffix&gt;".
 /// </param>
 public static IPage <RecordSet> List(this IRecordSetsOperations operations, string resourceGroupName, string privateZoneName, int?top = default(int?), string recordsetnamesuffix = default(string))
 {
     return(operations.ListAsync(resourceGroupName, privateZoneName, top, recordsetnamesuffix).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Lists all record sets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='top'>
 /// The maximum number of record sets to return. If not specified, returns up
 /// to 100 record sets.
 /// </param>
 /// <param name='recordSetNameSuffix'>
 /// The suffix label of the record set name that has to be used to filter the
 /// record set enumerations. If this parameter is specified, Enumeration will
 /// return only records that end with .&lt;recordSetNameSuffix&gt;
 /// </param>
 public static IPage <RecordSet> ListAllByDnsZone(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, int?top = default(int?), string recordSetNameSuffix = default(string))
 {
     return(operations.ListAllByDnsZoneAsync(resourceGroupName, zoneName, top, recordSetNameSuffix).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Gets a record set.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Possible values include: 'A',
 /// 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 public static RecordSet Get(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType)
 {
     return(operations.GetAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Deletes a record set from a DNS zone. This operation cannot be undone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Record sets of type SOA cannot
 /// be deleted (they are deleted when the DNS zone is deleted). Possible values
 /// include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV',
 /// 'TXT'
 /// </param>
 /// <param name='ifMatch'>
 /// The etag of the record set. Omit this value to always delete the current
 /// record set. Specify the last-seen etag value to prevent accidentally
 /// deleting any concurrent changes.
 /// </param>
 public static void Delete(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, string ifMatch = default(string))
 {
     operations.DeleteAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, ifMatch).GetAwaiter().GetResult();
 }
 /// <summary>
 /// Updates a RecordSet within a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the zone without a terminating dot.
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the RecordSet, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record. Possible values include: 'A', 'AAAA', 'CNAME',
 /// 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update operation.
 /// </param>
 /// <param name='ifMatch'>
 /// The etag of Zone.
 /// </param>
 /// <param name='ifNoneMatch'>
 /// Defines the If-None-Match condition. Set to '*' to force
 /// Create-If-Not-Exist. Other values will be ignored.
 /// </param>
 public static RecordSet Update(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, RecordSet parameters, string ifMatch = default(string), string ifNoneMatch = default(string))
 {
     return(Task.Factory.StartNew(s => ((IRecordSetsOperations)s).UpdateAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch, ifNoneMatch), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Lists all RecordSets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='nextPageLink'>
 /// The NextLink from the previous successful call to List operation.
 /// </param>
 public static IPage <RecordSet> ListAllInResourceGroupNext(this IRecordSetsOperations operations, string nextPageLink)
 {
     return(Task.Factory.StartNew(s => ((IRecordSetsOperations)s).ListAllInResourceGroupNextAsync(nextPageLink), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Lists all record sets in a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='nextPageLink'>
 /// The NextLink from the previous successful call to List operation.
 /// </param>
 public static IPage <RecordSet> ListAllByDnsZoneNext(this IRecordSetsOperations operations, string nextPageLink)
 {
     return(operations.ListAllByDnsZoneNextAsync(nextPageLink).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Updates a record set within a DNS zone.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the DNS zone (without a terminating dot).
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the record set, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record in this record set. Possible values include: 'A',
 /// 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update operation.
 /// </param>
 /// <param name='ifMatch'>
 /// The etag of the record set. Omit this value to always overwrite the current
 /// record set. Specify the last-seen etag value to prevent accidentally
 /// overwritting concurrent changes.
 /// </param>
 public static RecordSet Update(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType, RecordSet parameters, string ifMatch = default(string))
 {
     return(operations.UpdateAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType, parameters, ifMatch).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Gets a RecordSet.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='zoneName'>
 /// The name of the zone without a terminating dot.
 /// </param>
 /// <param name='relativeRecordSetName'>
 /// The name of the RecordSet, relative to the name of the zone.
 /// </param>
 /// <param name='recordType'>
 /// The type of DNS record. Possible values include: 'A', 'AAAA', 'CNAME',
 /// 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'
 /// </param>
 public static RecordSet Get(this IRecordSetsOperations operations, string resourceGroupName, string zoneName, string relativeRecordSetName, RecordType recordType)
 {
     return(Task.Factory.StartNew(s => ((IRecordSetsOperations)s).GetAsync(resourceGroupName, zoneName, relativeRecordSetName, recordType), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }