Skip to content

Commit

Permalink
Merge pull request #2 from levhayr/ignite_team
Browse files Browse the repository at this point in the history
Update DNS cmdlet code to use the SDK 1.1.1-preview
  • Loading branch information
vladca committed Apr 12, 2015
2 parents 8cadd6b + e4b2c64 commit a4b5fde
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/ResourceManager/Dns/Commands.Dns/Commands.Dns.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Dns, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.1.0-preview\lib\net40\Microsoft.Azure.Management.Dns.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Dns.1.1.1-preview\lib\net40\Microsoft.Azure.Management.Dns.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.0\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand Down
34 changes: 17 additions & 17 deletions src/ResourceManager/Dns/Commands.Dns/Models/DnsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,22 @@ public List<DnsZone> ListDnsZones(string resourceGroupName, string endsWith)
.ToList();
}

public DnsRecordSet CreateDnsRecordSet(string zoneName, string resourceGroupName, string relativeRecordName, uint ttl, RecordType recordType, Hashtable[] tags, bool overwrite)
public DnsRecordSet CreateDnsRecordSet(string zoneName, string resourceGroupName, string relativeRecordSetName, uint ttl, RecordType recordType, Hashtable[] tags, bool overwrite)
{
RecordCreateOrUpdateResponse response = this.DnsManagementClient.Records.CreateOrUpdate(
RecordSetCreateOrUpdateResponse response = this.DnsManagementClient.RecordSets.CreateOrUpdate(
resourceGroupName,
zoneName,
relativeRecordName,
relativeRecordSetName,
recordType,
new RecordCreateOrUpdateParameters
new RecordSetCreateOrUpdateParameters
{
IfNoneMatch = overwrite ? null : "*",
RecordSet = new RecordSet
{
Name = relativeRecordName,
Name = relativeRecordSetName,
Location = DnsResourceLocation,
Tags = TagsConversionHelper.CreateTagDictionary(tags, validate: true),
Properties = new RecordProperties
Properties = new RecordSetProperties
{
ETag = null,
Ttl = ttl,
Expand All @@ -181,20 +181,20 @@ public DnsRecordSet CreateDnsRecordSet(string zoneName, string resourceGroupName

public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
{
RecordCreateOrUpdateResponse response = this.DnsManagementClient.Records.CreateOrUpdate(
RecordSetCreateOrUpdateResponse response = this.DnsManagementClient.RecordSets.CreateOrUpdate(
recordSet.ResourceGroupName,
recordSet.ZoneName,
recordSet.Name,
recordSet.RecordType,
new RecordCreateOrUpdateParameters
new RecordSetCreateOrUpdateParameters
{
IfNoneMatch = null,
RecordSet = new RecordSet
{
Name = recordSet.Name,
Location = DnsResourceLocation,
Tags = TagsConversionHelper.CreateTagDictionary(recordSet.Tags, validate: true),
Properties = new RecordProperties
Properties = new RecordSetProperties
{
ETag = ignoreEtag ? "*" : recordSet.Etag,
Ttl = recordSet.Ttl,
Expand All @@ -215,12 +215,12 @@ public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)

public bool DeleteDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
{
AzureOperationResponse response = this.DnsManagementClient.Records.Delete(
AzureOperationResponse response = this.DnsManagementClient.RecordSets.Delete(
recordSet.ResourceGroupName,
recordSet.ZoneName,
recordSet.Name,
recordSet.RecordType,
new RecordDeleteParameters
new RecordSetDeleteParameters
{
IfMatch = ignoreEtag ? "*" : recordSet.Etag
});
Expand All @@ -230,18 +230,18 @@ public bool DeleteDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)

public DnsRecordSet GetDnsRecordSet(string name, string zoneName, string resourceGroupName, RecordType recordType)
{
RecordGetResponse getResponse = this.DnsManagementClient.Records.Get(resourceGroupName, zoneName, name, recordType);
RecordSetGetResponse getResponse = this.DnsManagementClient.RecordSets.Get(resourceGroupName, zoneName, name, recordType);
return GetPowerShellRecordSet(zoneName, resourceGroupName, getResponse.RecordSet);
}

public List<DnsRecordSet> ListRecordSets(string zoneName, string resourceGroupName, RecordType recordType, string endsWith)
{
RecordListParameters recordListParameters = new RecordListParameters
RecordSetListParameters recordListParameters = new RecordSetListParameters
{
Filter = endsWith == null ? null : string.Format("endswith(Name,'{0}')", endsWith)
};

RecordListResponse listResponse = this.DnsManagementClient.Records.List(resourceGroupName, zoneName, recordType, recordListParameters);
RecordSetListResponse listResponse = this.DnsManagementClient.RecordSets.List(resourceGroupName, zoneName, recordType, recordListParameters);
return listResponse
.RecordSets
.Select(recordSetInResponse => GetPowerShellRecordSet(zoneName, resourceGroupName, recordSetInResponse))
Expand All @@ -250,12 +250,12 @@ public List<DnsRecordSet> ListRecordSets(string zoneName, string resourceGroupNa

public List<DnsRecordSet> ListRecordSets(string zoneName, string resourceGroupName, string endsWith)
{
RecordListParameters recordListParameters = new RecordListParameters
RecordSetListParameters recordListParameters = new RecordSetListParameters
{
Filter = endsWith == null ? null : string.Format("endswith(Name,'{0}')", endsWith)
};

RecordListResponse listResponse = this.DnsManagementClient.Records.ListAll(resourceGroupName, zoneName, recordListParameters);
RecordSetListResponse listResponse = this.DnsManagementClient.RecordSets.ListAll(resourceGroupName, zoneName, recordListParameters);
return listResponse
.RecordSets
.Select(recordSetInResponse => GetPowerShellRecordSet(zoneName, resourceGroupName, recordSetInResponse))
Expand All @@ -264,7 +264,7 @@ public List<DnsRecordSet> ListRecordSets(string zoneName, string resourceGroupNa

private static DnsRecordSet GetPowerShellRecordSet(string zoneName, string resourceGroupName, Management.Dns.Models.RecordSet mamlRecordSet)
{
// e.g. "/subscriptions/<guid>/resourceGroups/<rg>/providers/microsoft.dns/dnszones/<zone>/A/<record>"
// e.g. "/subscriptions/<guid>/resourceGroups/<rg>/providers/microsoft.dns/dnszones/<zone>/A/<recordset>"
string recordTypeAsString = mamlRecordSet.Id.Split('/').Reverse().Skip(1).First();

RecordType recordType = (RecordType)Enum.Parse(typeof(RecordType), recordTypeAsString, ignoreCase: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Microsoft.Azure.Commands.Dns
[Cmdlet(VerbsCommon.Remove, "AzureDnsRecordConfig"), OutputType(typeof(DnsRecordSet))]
public class RemoveAzureDnsRecordConfig : DnsBaseCmdlet
{
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The record set in which to add the record.")]
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The record set from which to remove the record.")]
[ValidateNotNullOrEmpty]
public DnsRecordSet RecordSet { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Dns/Commands.Dns/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.0.21-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Dns" version="1.1.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Dns" version="1.1.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.14.1-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit a4b5fde

Please sign in to comment.