Skip to content

Commit 11e985a

Browse files
committed
BUG: 3429965 Rename "IgnoreEtag" switch to "Overwrite"
BUG: 3429965 Rename "IgnoreEtag" switch to "Overwrite"
1 parent 6a3567f commit 11e985a

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/RecordsTests.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,14 @@ function Test-RecordSetEtagMismatch
529529

530530
Assert-Throws { $recordSet | Set-AzureDnsRecordSet } "PreconditionFailed: The condition 'gibberish' in the If-Match header was not satisfied."
531531

532-
$updatedRecordSet = $recordSet | Set-AzureDnsRecordSet -IgnoreEtag
532+
$updatedRecordSet = $recordSet | Set-AzureDnsRecordSet -Overwrite
533533

534534
Assert-AreNotEqual "gibberish" $updatedRecordSet.Etag
535535
Assert-AreNotEqual $recordSet.Etag $updatedRecordSet.Etag
536536

537537
Assert-Throws { $recordSet | Remove-AzureDnsRecordSet -Force } "PreconditionFailed: The condition 'gibberish' in the If-Match header was not satisfied."
538538

539-
Assert-True { $recordSet | Remove-AzureDnsRecordSet -IgnoreEtag -Force -PassThru }
539+
Assert-True { $recordSet | Remove-AzureDnsRecordSet -Overwrite -Force -PassThru }
540540

541541
Remove-AzureDnsZone -Name $zoneName -ResourceGroupName $recordSet.ResourceGroupName -Force
542542
}
@@ -582,7 +582,7 @@ function Test-RecordSetGet
582582
$zone | Remove-AzureDnsRecordSet -Name $recordName2 -RecordType AAAA -Force
583583
$zone | Remove-AzureDnsRecordSet -Name $recordName3 -RecordType MX -Force
584584

585-
$zone | Remove-AzureDnsZone -Force -IgnoreEtag
585+
$zone | Remove-AzureDnsZone -Force -Overwrite
586586
}
587587

588588
<#
@@ -628,5 +628,5 @@ function Test-RecordSetGetWithEndsWith
628628
$zone | Remove-AzureDnsRecordSet -Name $recordName2 -RecordType AAAA -Force
629629
$zone | Remove-AzureDnsRecordSet -Name $recordName3 -RecordType MX -Force
630630

631-
$zone | Remove-AzureDnsZone -Force -IgnoreEtag
631+
$zone | Remove-AzureDnsZone -Force -Overwrite
632632
}

src/ResourceManager/Dns/Commands.Dns.Test/ScenarioTests/ZoneTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function Test-ZoneSetEtagMismatch
124124

125125
Assert-Throws { $createdZone | Set-AzureDnsZone } "PreconditionFailed: The condition 'gibberish' in the If-Match header was not satisfied."
126126

127-
$updatedZone = $createdZone | Set-AzureDnsZone -IgnoreEtag
127+
$updatedZone = $createdZone | Set-AzureDnsZone -Overwrite
128128

129129
Assert-AreNotEqual "gibberish" $updatedZone.Etag
130130
Assert-AreNotEqual $createdZone.Etag $updatedZone.Etag
@@ -157,7 +157,7 @@ function Test-ZoneRemoveEtagMismatch
157157

158158
Assert-Throws { $createdZone | Remove-AzureDnsZone -Force } "PreconditionFailed: The condition 'gibberish' in the If-Match header was not satisfied."
159159

160-
$removed = $createdZone | Remove-AzureDnsZone -IgnoreEtag -Force -PassThru
160+
$removed = $createdZone | Remove-AzureDnsZone -Overwrite -Force -PassThru
161161

162162
Assert-True { $removed }
163163
}

src/ResourceManager/Dns/Commands.Dns/Models/DnsClient.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public DnsZone CreateDnsZone(string name, string resourceGroupName, Hashtable[]
7373
};
7474
}
7575

76-
public DnsZone UpdateDnsZone(DnsZone zone, bool ignoreEtag)
76+
public DnsZone UpdateDnsZone(DnsZone zone, bool overwrite)
7777
{
7878
ZoneCreateOrUpdateResponse response = this.DnsManagementClient.Zones.CreateOrUpdate(
7979
zone.ResourceGroupName,
@@ -87,7 +87,7 @@ public DnsZone UpdateDnsZone(DnsZone zone, bool ignoreEtag)
8787
Tags = TagsConversionHelper.CreateTagDictionary(zone.Tags, validate: true),
8888
Properties = new ZoneProperties
8989
{
90-
ETag = ignoreEtag ? "*" : zone.Etag,
90+
ETag = overwrite ? "*" : zone.Etag,
9191
}
9292
}
9393
});
@@ -101,14 +101,14 @@ public DnsZone UpdateDnsZone(DnsZone zone, bool ignoreEtag)
101101
};
102102
}
103103

104-
public bool DeleteDnsZone(DnsZone zone, bool ignoreEtag)
104+
public bool DeleteDnsZone(DnsZone zone, bool overwrite)
105105
{
106106
AzureOperationResponse resp = this.DnsManagementClient.Zones.Delete(
107107
zone.ResourceGroupName,
108108
zone.Name,
109109
new ZoneDeleteParameters
110110
{
111-
IfMatch = ignoreEtag ? null : zone.Etag,
111+
IfMatch = overwrite ? null : zone.Etag,
112112
});
113113

114114
return resp.StatusCode == System.Net.HttpStatusCode.NoContent || resp.StatusCode == System.Net.HttpStatusCode.OK ? true : false;
@@ -179,7 +179,7 @@ public DnsRecordSet CreateDnsRecordSet(string zoneName, string resourceGroupName
179179
return GetPowerShellRecordSet(zoneName, resourceGroupName, response.RecordSet);
180180
}
181181

182-
public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
182+
public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool overwrite)
183183
{
184184
RecordSetCreateOrUpdateResponse response = this.DnsManagementClient.RecordSets.CreateOrUpdate(
185185
recordSet.ResourceGroupName,
@@ -196,7 +196,7 @@ public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
196196
Tags = TagsConversionHelper.CreateTagDictionary(recordSet.Tags, validate: true),
197197
Properties = new RecordSetProperties
198198
{
199-
ETag = ignoreEtag ? "*" : recordSet.Etag,
199+
ETag = overwrite ? "*" : recordSet.Etag,
200200
Ttl = recordSet.Ttl,
201201
AaaaRecords = recordSet.RecordType == RecordType.AAAA ? GetMamlRecords<AaaaRecord, Management.Dns.Models.AaaaRecord>(recordSet.Records) : null,
202202
ARecords = recordSet.RecordType == RecordType.A ? GetMamlRecords<ARecord, Management.Dns.Models.ARecord>(recordSet.Records) : null,
@@ -213,7 +213,7 @@ public DnsRecordSet UpdateDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
213213
return GetPowerShellRecordSet(recordSet.ZoneName, recordSet.ResourceGroupName, response.RecordSet);
214214
}
215215

216-
public bool DeleteDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
216+
public bool DeleteDnsRecordSet(DnsRecordSet recordSet, bool overwrite)
217217
{
218218
AzureOperationResponse response = this.DnsManagementClient.RecordSets.Delete(
219219
recordSet.ResourceGroupName,
@@ -222,7 +222,7 @@ public bool DeleteDnsRecordSet(DnsRecordSet recordSet, bool ignoreEtag)
222222
recordSet.RecordType,
223223
new RecordSetDeleteParameters
224224
{
225-
IfMatch = ignoreEtag ? "*" : recordSet.Etag
225+
IfMatch = overwrite ? "*" : recordSet.Etag
226226
});
227227

228228
return response.StatusCode == System.Net.HttpStatusCode.NoContent || response.StatusCode == System.Net.HttpStatusCode.OK ? true : false;

src/ResourceManager/Dns/Commands.Dns/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Dns/Commands.Dns/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<value>Cannot add a record of type {0} to a record set of type {1}. The types must match.</value>
134134
</data>
135135
<data name="Error_EtagNotSpecified" xml:space="preserve">
136-
<value>The ETag property of the {0} object is empty or "*". In order to perform this operation with optimistic concurrency checks, please set the Etag property (you may need to Get the {0} first). In order to perform the operation without optimistic concurrency checks, please specify the -IgnoreEtag switch. </value>
136+
<value>The ETag property of the {0} object is empty or "*". In order to perform this operation with optimistic concurrency checks, please set the Etag property (you may need to Get the {0} first). In order to perform the operation without optimistic concurrency checks, please specify the -Overwrite switch. </value>
137137
</data>
138138
<data name="Error_NameAndEndsWith" xml:space="preserve">
139139
<value>Name parameter cannot be used with EndsWith.</value>

src/ResourceManager/Dns/Commands.Dns/Records/RemoveAzureDnsRecordSet.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class RemoveAzureDnsRecordSet : DnsBaseCmdlet
5454
public DnsRecordSet RecordSet { get; set; }
5555

5656
[Parameter(Mandatory = false, HelpMessage = "Do not use the ETag field of the RecordSet parameter for optimistic concurrency checks.", ParameterSetName = "Object")]
57-
public SwitchParameter IgnoreEtag { get; set; }
57+
public SwitchParameter Overwrite { get; set; }
5858

5959
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
6060
public SwitchParameter Force { get; set; }
@@ -91,22 +91,22 @@ public override void ExecuteCmdlet()
9191
}
9292
else if (this.ParameterSetName == "Object")
9393
{
94-
if ((string.IsNullOrWhiteSpace(this.RecordSet.Etag) || this.RecordSet.Etag == "*") && !this.IgnoreEtag.IsPresent)
94+
if ((string.IsNullOrWhiteSpace(this.RecordSet.Etag) || this.RecordSet.Etag == "*") && !this.Overwrite.IsPresent)
9595
{
9696
throw new PSArgumentException(string.Format(ProjectResources.Error_EtagNotSpecified, typeof(DnsRecordSet).Name));
9797
}
9898

9999
recordSetToDelete = this.RecordSet;
100100
}
101101

102-
bool ignoreEtag = this.IgnoreEtag.IsPresent || this.ParameterSetName != "Object";
102+
bool overwrite = this.Overwrite.IsPresent || this.ParameterSetName != "Object";
103103

104104
ConfirmAction(
105105
Force.IsPresent,
106106
string.Format(ProjectResources.Confirm_RemoveRecordSet, recordSetToDelete.Name, recordSetToDelete.ZoneName),
107107
ProjectResources.Progress_RemovingRecordSet,
108108
this.Name,
109-
() => { deleted = DnsClient.DeleteDnsRecordSet(recordSetToDelete, ignoreEtag); });
109+
() => { deleted = DnsClient.DeleteDnsRecordSet(recordSetToDelete, overwrite); });
110110

111111
if (deleted)
112112
{

src/ResourceManager/Dns/Commands.Dns/Records/SetAzureDnsRecordSet.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ public class SetAzureDnsRecordSet : DnsBaseCmdlet
3131
public DnsRecordSet RecordSet { get; set; }
3232

3333
[Parameter(Mandatory = false, HelpMessage = "Do not use the ETag field of the RecordSet parameter for optimistic concurrency checks.", ParameterSetName = "Object")]
34-
public SwitchParameter IgnoreEtag { get; set; }
34+
public SwitchParameter Overwrite { get; set; }
3535

3636
public override void ExecuteCmdlet()
3737
{
38-
if ((string.IsNullOrWhiteSpace(this.RecordSet.Etag) || this.RecordSet.Etag == "*") && !this.IgnoreEtag.IsPresent)
38+
if ((string.IsNullOrWhiteSpace(this.RecordSet.Etag) || this.RecordSet.Etag == "*") && !this.Overwrite.IsPresent)
3939
{
4040
throw new PSArgumentException(string.Format(ProjectResources.Error_EtagNotSpecified, typeof(DnsRecordSet).Name));
4141
}
4242

43-
DnsRecordSet result = this.DnsClient.UpdateDnsRecordSet(this.RecordSet, this.IgnoreEtag.IsPresent);
43+
DnsRecordSet result = this.DnsClient.UpdateDnsRecordSet(this.RecordSet, this.Overwrite.IsPresent);
4444

4545
WriteVerbose(ProjectResources.Success);
4646

src/ResourceManager/Dns/Commands.Dns/Zones/RemoveAzureDnsZone.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class RemoveAzureDnsZone : DnsBaseCmdlet
4040
public DnsZone Zone { get; set; }
4141

4242
[Parameter(Mandatory = false, HelpMessage = "Do not use the ETag field of the Zone parameter for optimistic concurrency checks.", ParameterSetName = "Object")]
43-
public SwitchParameter IgnoreEtag { get; set; }
43+
public SwitchParameter Overwrite { get; set; }
4444

4545
[Parameter(Mandatory = false, HelpMessage = "Do not ask for confirmation.")]
4646
public SwitchParameter Force { get; set; }
@@ -66,20 +66,20 @@ public override void ExecuteCmdlet()
6666
{
6767
zoneToDelete = this.Zone;
6868

69-
if ((string.IsNullOrWhiteSpace(this.Zone.Etag) || this.Zone.Etag == "*") && !this.IgnoreEtag.IsPresent)
69+
if ((string.IsNullOrWhiteSpace(this.Zone.Etag) || this.Zone.Etag == "*") && !this.Overwrite.IsPresent)
7070
{
7171
throw new PSArgumentException(string.Format(ProjectResources.Error_EtagNotSpecified, typeof(DnsZone).Name));
7272
}
7373
}
7474

75-
bool ignoreEtag = this.IgnoreEtag.IsPresent || this.ParameterSetName != "Object";
75+
bool overwrite = this.Overwrite.IsPresent || this.ParameterSetName != "Object";
7676

7777
ConfirmAction(
7878
Force.IsPresent,
7979
string.Format(ProjectResources.Confirm_RemoveZone, zoneToDelete.Name),
8080
ProjectResources.Progress_RemovingZone,
8181
this.Name,
82-
() => { deleted = DnsClient.DeleteDnsZone(zoneToDelete, ignoreEtag); });
82+
() => { deleted = DnsClient.DeleteDnsZone(zoneToDelete, overwrite); });
8383

8484
if (deleted)
8585
{

src/ResourceManager/Dns/Commands.Dns/Zones/SetAzureDnsZone.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class SetAzureDnsZone : DnsBaseCmdlet
4343
public DnsZone Zone { get; set; }
4444

4545
[Parameter(Mandatory = false, HelpMessage = "Do not use the ETag field of the RecordSet parameter for optimistic concurrency checks.", ParameterSetName = "Object")]
46-
public SwitchParameter IgnoreEtag { get; set; }
46+
public SwitchParameter Overwrite { get; set; }
4747

4848
public override void ExecuteCmdlet()
4949
{
@@ -62,16 +62,16 @@ public override void ExecuteCmdlet()
6262
}
6363
else if (this.ParameterSetName == "Object")
6464
{
65-
if ((string.IsNullOrWhiteSpace(this.Zone.Etag) || this.Zone.Etag == "*") && !this.IgnoreEtag.IsPresent)
65+
if ((string.IsNullOrWhiteSpace(this.Zone.Etag) || this.Zone.Etag == "*") && !this.Overwrite.IsPresent)
6666
{
6767
throw new PSArgumentException(string.Format(ProjectResources.Error_EtagNotSpecified, typeof(DnsZone).Name));
6868
}
6969

7070
zoneToUpdate = this.Zone;
7171
}
7272

73-
bool ignoreEtag = this.IgnoreEtag.IsPresent || this.ParameterSetName != "Object";
74-
result = this.DnsClient.UpdateDnsZone(zoneToUpdate, ignoreEtag);
73+
bool overwrite = this.Overwrite.IsPresent || this.ParameterSetName != "Object";
74+
result = this.DnsClient.UpdateDnsZone(zoneToUpdate, overwrite);
7575

7676
WriteVerbose(ProjectResources.Success);
7777
WriteObject(result);

0 commit comments

Comments
 (0)