Skip to content

[Release.1.3.2] Change api-version for policy and locks #2079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,17 @@ public static class Constants
/// <summary>
/// The default policy API version.
/// </summary>
public static readonly string PolicyApiVersion = "2015-10-01-preview";
public static readonly string PolicyApiVersion = "2016-04-01";

/// <summary>
/// The default Lock API version.
/// </summary>
public static readonly string LockApiVersion = "2015-01-01";

/// <summary>
/// The default deployment operation API version.
/// </summary>
public static readonly string DeploymentOperationApiVersion = "2016-02-01";

/// <summary>
/// The move action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ protected override void OnProcessRecord()
this.SubscriptionId = DefaultContext.Subscription.Id;
}

if(!string.IsNullOrEmpty(this.ApiVersion))
{
this.WriteWarning("The parameter ApiVersion in Get-AzureRmResourceGroupDeploymentOperation cmdlet is being deprecated and will be removed in a future release.");
}

this.RunCmdlet();
}

Expand All @@ -89,9 +84,7 @@ private async Task<ResponseWithContinuation<JObject[]>> GetResources()
{
var resourceId = this.GetResourceId();

var apiVersion = await this
.DetermineApiVersion(resourceId: resourceId)
.ConfigureAwait(continueOnCapturedContext: false);
var apiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.DeploymentOperationApiVersion : this.ApiVersion;

return await this
.GetResourcesClient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,11 @@ private async Task<JObject> GetResource()
{
var resourceId = this.GetResourceId(this.LockName);

var apiVersion = await this
.DetermineApiVersion(resourceId: resourceId)
.ConfigureAwait(continueOnCapturedContext: false);

return await this
.GetResourcesClient()
.GetResource<JObject>(
resourceId: resourceId,
apiVersion: apiVersion,
apiVersion: this.LockApiVersion,
cancellationToken: this.CancellationToken.Value)
.ConfigureAwait(continueOnCapturedContext: false);
}
Expand All @@ -100,10 +96,6 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
{
var resourceCollectionId = this.GetResourceId(this.LockName);

var apiVersion = await this
.DetermineApiVersion(resourceId: resourceCollectionId)
.ConfigureAwait(continueOnCapturedContext: false);

var filter = this.AtScope
? "$filter=atScope()"
: null;
Expand All @@ -112,7 +104,7 @@ private async Task<ResponseWithContinuation<JObject[]>> ListResourcesTypeCollect
.GetResourcesClient()
.ListObjectColleciton<JObject>(
resourceCollectionId: resourceCollectionId,
apiVersion: apiVersion,
apiVersion: this.LockApiVersion,
cancellationToken: this.CancellationToken.Value,
odataQuery: filter)
.ConfigureAwait(continueOnCapturedContext: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,20 @@ protected override void OnProcessRecord()
resourceId,
() =>
{
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;
var resourceBody = this.GetResourceBody();

var operationResult = this.GetResourcesClient()
.PutResource(
resourceId: resourceId,
apiVersion: apiVersion,
apiVersion: this.LockApiVersion,
resource: resourceBody,
cancellationToken: this.CancellationToken.Value)
.Result;

var managementUri = this.GetResourcesClient()
.GetResourceManagementRequestUri(
resourceId: resourceId,
apiVersion: apiVersion);
apiVersion: this.LockApiVersion);

var activity = string.Format("PUT {0}", managementUri.PathAndQuery);
var result = this.GetLongRunningOperationTracker(activityName: activity, isResourceCreateOrUpdate: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ protected override void OnProcessRecord()
resourceId,
() =>
{
var apiVersion = this.DetermineApiVersion(resourceId: resourceId).Result;

var operationResult = this.GetResourcesClient()
.DeleteResource(
resourceId: resourceId,
apiVersion: apiVersion,
apiVersion: this.LockApiVersion,
cancellationToken: this.CancellationToken.Value)
.Result;

Expand All @@ -73,7 +71,7 @@ protected override void OnProcessRecord()
var managementUri = this.GetResourcesClient()
.GetResourceManagementRequestUri(
resourceId: resourceId,
apiVersion: apiVersion);
apiVersion: this.LockApiVersion);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
/// <summary>
/// Gets or sets the scope.
/// </summary>
[Alias("Id", "ResourceId")]
[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}'")]
[ValidateNotNullOrEmpty]
public string Scope { get; set; }
Expand Down Expand Up @@ -105,10 +104,21 @@ public abstract class ResourceLockManagementCmdletBase : ResourceManagerCmdletBa
/// <summary>
/// The Id of the lock.
/// </summary>
[Alias("Id", "ResourceId")]
[Parameter(ParameterSetName = ResourceLockManagementCmdletBase.LockIdParameterSet, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the lock.")]
[ValidateNotNullOrEmpty]
public string LockId { get; set; }

/// <summary>
/// Determines the api version to be used
/// </summary>
public string LockApiVersion { get; set; }

public ResourceLockManagementCmdletBase()
{
this.LockApiVersion = string.IsNullOrWhiteSpace(this.ApiVersion) ? Constants.LockApiVersion : this.ApiVersion;
}

/// <summary>
/// Gets the resource Id from the supplied PowerShell parameters.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public override void ExecuteCmdlet()
DeploymentDebugLogLevel = GetDeploymentDebugLogLevel(DeploymentDebugLogLevel)
};

if(!string.IsNullOrEmpty(parameters.DeploymentDebugLogLevel))
{
WriteWarning("The DeploymentDebug setting has been enabled. This can potentially log secrets like passwords used in resource property or listKeys operations when you retrieve the deployment operations through Get-AzureRmResourceGroupDeploymentOperation");
}

if(this.Mode == DeploymentMode.Complete)
{
this.ConfirmAction(
Expand Down