/// <summary>
        /// Returns a deep copy of this record set
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            var clone = new PSPrivateDnsRecordSet
            {
                Name              = this.Name,
                Id                = this.Id,
                ZoneName          = this.ZoneName,
                ResourceGroupName = this.ResourceGroupName,
                Ttl               = this.Ttl,
                Etag              = this.Etag,
                RecordType        = this.RecordType,
                IsAutoRegistered  = this.IsAutoRegistered
            };

            if (this.Records != null)
            {
                clone.Records = this.Records.Select(record => record.Clone()).Cast <PSPrivateDnsRecordBase>().ToList();
            }

            if (this.Metadata != null)
            {
                clone.Metadata = (Hashtable)this.Metadata.Clone();
            }

            return(clone);
        }
Beispiel #2
0
        public PSPrivateDnsRecordSet UpdatePrivateDnsRecordSet(PSPrivateDnsRecordSet recordSet, bool overwrite)
        {
            var getRecordSet = GetPrivateDnsRecordSet(recordSet.Name, recordSet.ZoneName, recordSet.ResourceGroupName,
                                                      recordSet.RecordType);

            if (getRecordSet?.IsAutoRegistered == true)
            {
                throw new PSArgumentException(ProjectResources.Error_RecordSetIsAutoRegistered);
            }

            var response = this.PrivateDnsManagementClient.RecordSets.CreateOrUpdate(
                recordSet.ResourceGroupName,
                recordSet.ZoneName,
                recordSet.RecordType,
                recordSet.Name,
                new RecordSet
            {
                Ttl         = recordSet.Ttl,
                Metadata    = TagsConversionHelper.CreateTagDictionary(recordSet.Metadata, true),
                AaaaRecords =
                    recordSet.RecordType == RecordType.AAAA
                            ? GetMamlRecords <AaaaRecord, Sdk.AaaaRecord>(recordSet.Records)
                            : null,
                ARecords =
                    recordSet.RecordType == RecordType.A
                            ? GetMamlRecords <ARecord, Sdk.ARecord>(recordSet.Records)
                            : null,
                MxRecords =
                    recordSet.RecordType == RecordType.MX
                            ? GetMamlRecords <MxRecord, Sdk.MxRecord>(recordSet.Records)
                            : null,
                SrvRecords =
                    recordSet.RecordType == RecordType.SRV
                            ? GetMamlRecords <SrvRecord, Sdk.SrvRecord>(recordSet.Records)
                            : null,
                TxtRecords =
                    recordSet.RecordType == RecordType.TXT
                            ? GetMamlRecords <TxtRecord, Sdk.TxtRecord>(recordSet.Records)
                            : null,
                PtrRecords =
                    recordSet.RecordType == RecordType.PTR
                            ? GetMamlRecords <PtrRecord, Sdk.PtrRecord>(recordSet.Records)
                            : null,
                SoaRecord =
                    recordSet.RecordType == RecordType.SOA
                            ? GetMamlRecords <SoaRecord, Sdk.SoaRecord>(recordSet.Records).SingleOrDefault()
                            : null,
                CnameRecord =
                    recordSet.RecordType == RecordType.CNAME
                            ? GetMamlRecords <CnameRecord, Sdk.CnameRecord>(recordSet.Records).SingleOrDefault()
                            : null,
            },
                ifMatch: overwrite ? "*" : recordSet.Etag);

            return(GetPowerShellRecordSet(recordSet.ZoneName, recordSet.ResourceGroupName, response));
        }
Beispiel #3
0
 public bool DeletePrivateDnsRecordSet(PSPrivateDnsRecordSet recordSet, bool overwrite)
 {
     this.PrivateDnsManagementClient.RecordSets.Delete(
         recordSet.ResourceGroupName,
         recordSet.ZoneName,
         recordSet.RecordType,
         recordSet.Name,
         ifMatch: overwrite ? "*" : recordSet.Etag);
     return(true);
 }