Skip to content

Commit 3d69ed0

Browse files
committed
Change api-version for policy and locks
1 parent c3de34e commit 3d69ed0

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/Constants.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ public static class Constants
5757
/// <summary>
5858
/// The default policy API version.
5959
/// </summary>
60-
public static readonly string PolicyApiVersion = "2015-10-01-preview";
60+
public static readonly string PolicyApiVersion = "2016-04-01";
61+
62+
/// <summary>
63+
/// The default Lock API version.
64+
/// </summary>
65+
public static readonly string LockApiVersion = "2015-01-01";
6166

6267
/// <summary>
6368
/// The move action.

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/GetAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,11 @@ private async Task<JObject> GetResource()
8080
{
8181
var resourceId = this.GetResourceId(this.LockName);
8282

83-
var apiVersion = await this
84-
.DetermineApiVersion(resourceId: resourceId)
85-
.ConfigureAwait(continueOnCapturedContext: false);
86-
8783
return await this
8884
.GetResourcesClient()
8985
.GetResource<JObject>(
9086
resourceId: resourceId,
91-
apiVersion: apiVersion,
87+
apiVersion: this.LockApiVersion,
9288
cancellationToken: this.CancellationToken.Value)
9389
.ConfigureAwait(continueOnCapturedContext: false);
9490
}
@@ -100,10 +96,6 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
10096
{
10197
var resourceCollectionId = this.GetResourceId(this.LockName);
10298

103-
var apiVersion = await this
104-
.DetermineApiVersion(resourceId: resourceCollectionId)
105-
.ConfigureAwait(continueOnCapturedContext: false);
106-
10799
var filter = this.AtScope
108100
? "$filter=atScope()"
109101
: null;
@@ -112,7 +104,7 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
112104
.GetResourcesClient()
113105
.ListObjectColleciton<JObject>(
114106
resourceCollectionId: resourceCollectionId,
115-
apiVersion: apiVersion,
107+
apiVersion: this.LockApiVersion,
116108
cancellationToken: this.CancellationToken.Value,
117109
odataQuery: filter)
118110
.ConfigureAwait(continueOnCapturedContext: false);

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/NewAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,20 @@ protected override void OnProcessRecord()
7474
resourceId,
7575
() =>
7676
{
77-
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
7877
var resourceBody = this.GetResourceBody();
7978

8079
var operationResult = this.GetResourcesClient()
8180
.PutResource(
8281
resourceId: resourceId,
83-
apiVersion: apiVersion,
82+
apiVersion: this.LockApiVersion,
8483
resource: resourceBody,
8584
cancellationToken: this.CancellationToken.Value)
8685
.Result;
8786

8887
var managementUri = this.GetResourcesClient()
8988
.GetResourceManagementRequestUri(
9089
resourceId: resourceId,
91-
apiVersion: apiVersion);
90+
apiVersion: this.LockApiVersion);
9291

9392
var activity = string.Format("PUT {0}", managementUri.PathAndQuery);
9493
var result = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: true)

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/RemoveAzureResourceLockCmdlet.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,10 @@ protected override void OnProcessRecord()
5656
resourceId,
5757
() =>
5858
{
59-
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
60-
6159
var operationResult = this.GetResourcesClient()
6260
.DeleteResource(
6361
resourceId: resourceId,
64-
apiVersion: apiVersion,
62+
apiVersion: this.LockApiVersion,
6563
cancellationToken: this.CancellationToken.Value)
6664
.Result;
6765

@@ -73,7 +71,7 @@ protected override void OnProcessRecord()
7371
var managementUri = this.GetResourcesClient()
7472
.GetResourceManagementRequestUri(
7573
resourceId: resourceId,
76-
apiVersion: apiVersion);
74+
apiVersion: this.LockApiVersion);
7775

7876
var activity = string.Format("DELETE {0}", managementUri.PathAndQuery);
7977

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Lock/ResourceLockManagementCmdletBase.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
6565
/// <summary>
6666
/// Gets or sets the scope.
6767
/// </summary>
68-
[Alias("Id", "ResourceId")]
6968
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.ScopeLevelLock, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The scope. e.g. to specify a database '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaserName}', to specify a resoruce group: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'")]
7069
[ValidateNotNullOrEmpty]
7170
public string Scope { get; set; }
@@ -105,10 +104,21 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
105104
/// <summary>
106105
/// The Id of the lock.
107106
/// </summary>
107+
[Alias("Id", "ResourceId")]
108108
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.LockIdParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the lock.")]
109109
[ValidateNotNullOrEmpty]
110110
public string LockId { get; set; }
111111

112+
/// <summary>
113+
/// Determines the api version to be used
114+
/// </summary>
115+
public string LockApiVersion { get; set; }
116+
117+
public ResourceLockManagementCmdletBase()
118+
{
119+
this.LockApiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.LockApiVersion : this.ApiVersion;
120+
}
121+
112122
/// <summary>
113123
/// Gets the resource Id from the supplied PowerShell parameters.
114124
/// </summary>

0 commit comments

Comments
 (0)