Ejemplo n.º 1
0
        internal static ZoneListResult DeserializeZoneListResult(JsonElement element)
        {
            Optional <IReadOnlyList <DnsZoneData> > value = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DnsZoneData> array = new List <DnsZoneData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DnsZoneData.DeserializeDnsZoneData(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new ZoneListResult(Optional.ToList(value), nextLink.Value));
        }
Ejemplo n.º 2
0
        public async Task ListRecordSetPtrs()
        {
            #region Snippet:Managing_RecordSetPtrs_ListAllRecordSetPtrs
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string rgName = "myRgName";
            ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // create a DnsZone
            string            dnsZoneName       = "sample.com";
            DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
            DnsZoneData       data = new DnsZoneData("Global")
            {
            };
            ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            DnsZoneResource dnsZone = lro.Value;
            // With ListAsync(), we can get a list of the RecordSetPtrs
            RecordSetPtrCollection recordSetPtrCollection = dnsZone.GetRecordSetPtrs();
            AsyncPageable <RecordSetPtrResource> response = recordSetPtrCollection.GetAllAsync();
            await foreach (RecordSetPtrResource recordSetPtr in response)
            {
                Console.WriteLine(recordSetPtr.Data.Name);
            }
            #endregion Snippet:Managing_RecordSetPtrs_ListAllRecordSetPtrs
        }
Ejemplo n.º 3
0
        public async Task DeleteRecordSetPtr()
        {
            #region Snippet:Managing_RecordSetPtrs_DeleteRecordSetPtr
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string rgName = "myRgName";
            ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // create a DnsZone
            string            dnsZoneName       = "sample.com";
            DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
            DnsZoneData       data = new DnsZoneData("Global")
            {
            };
            ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            DnsZoneResource dnsZone = lro.Value;
            // Now we get the DnsZone collection from the resource group
            RecordSetPtrCollection recordSetPtrCollection = dnsZone.GetRecordSetPtrs();
            string recordSetPtrName           = "ptr";
            RecordSetPtrResource recordSetPtr = await recordSetPtrCollection.GetAsync(recordSetPtrName);

            await recordSetPtr.DeleteAsync(WaitUntil.Completed);

            #endregion Snippet:Managing_RecordSetPtrs_DeleteRecordSetPtr
        }
Ejemplo n.º 4
0
        public async Task <DnsZoneResource> CreateADnsZone(string dnsZoneName, ResourceGroupResource rg)
        {
            DnsZoneCollection collection = rg.GetDnsZones();
            DnsZoneData       data       = new DnsZoneData("Global")
            {
            };
            var dns = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            return(dns.Value);
        }
Ejemplo n.º 5
0
        public async Task CreateADnsZone()
        {
            #region Snippet:Managing_DnsZones_CreateADnsZones
            ArmClient            armClient    = new ArmClient(new DefaultAzureCredential());
            SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();

            // first we need to get the resource group
            string rgName = "myRgName";
            ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);

            // Now we get the DnsZone collection from the resource group
            DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
            // Use the same location as the resource group
            string      dnsZoneName = "sample.com";
            DnsZoneData data        = new DnsZoneData("Global")
            {
            };
            ArmOperation <DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data);

            DnsZoneResource dnsZone = lro.Value;
            #endregion Snippet:Managing_DnsZones_CreateADnsZones
        }