Skip to content

Commit

Permalink
Added operation parameters and operation steps in MI operations PS cm…
Browse files Browse the repository at this point in the history
…dlet (#12437)

* Added operation parameters and operation steps in `Get-AzSqlInstanceOperation`

* Starting validation.

* Fixing build

Co-authored-by: Jovana Toroman <[email protected]>
  • Loading branch information
toki95 and jtoroman authored Sep 3, 2020
1 parent 88a7820 commit 8639a13
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
## Version 2.9.1
* Fixed potential server name case insensitive error in `New-AzSqlServer` and `Set-AzSqlServer`
* Fixed wrong database name returned on existing database error in `New-AzSqlDatabaseSecondary`
* Added operation parameters and steps in `Get-AzSqlInstanceOperation`

## Version 2.9.0
* Added support for Service principal and guest users in Set-AzSqlInstanceActiveDirectoryAdministrator cmdlet`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,15 @@ public class AzureSqlManagedInstanceOperationModel
/// Gets whether the operation can be cancelled.
/// </summary>
public bool? IsCancellable { get; set; }

/// <summary>
/// Gets the operation parameters.
/// </summary>
public Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationParametersPair OperationParameters { get; set; }

/// <summary>
/// Gets the operation steps.
/// </summary>
public Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationSteps OperationSteps { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,48 @@ private static AzureSqlManagedInstanceOperationModel CreateManagedInstanceOperat
managedInstanceOperation.State = resp.State;
managedInstanceOperation.IsUserError = resp.IsUserError;

if (resp.OperationParameters != null)
{
Management.Sql.Models.UpsertManagedServerOperationParameters currentParameters = new Management.Sql.Models.UpsertManagedServerOperationParameters();
if (resp.OperationParameters.CurrentParameters != null)
{
currentParameters.Family = resp.OperationParameters.CurrentParameters.Family;
currentParameters.Tier = resp.OperationParameters.CurrentParameters.Tier;
currentParameters.VCores = resp.OperationParameters.CurrentParameters.VCores;
currentParameters.StorageSizeInGB = resp.OperationParameters.CurrentParameters.StorageSizeInGB;
}

Management.Sql.Models.UpsertManagedServerOperationParameters requestedParameters = new Management.Sql.Models.UpsertManagedServerOperationParameters();
if (resp.OperationParameters.RequestedParameters != null)
{
requestedParameters.Family = resp.OperationParameters.RequestedParameters.Family;
requestedParameters.Tier = resp.OperationParameters.RequestedParameters.Tier;
requestedParameters.VCores = resp.OperationParameters.RequestedParameters.VCores;
requestedParameters.StorageSizeInGB = resp.OperationParameters.RequestedParameters.StorageSizeInGB;
}

managedInstanceOperation.OperationParameters = new Management.Sql.Models.ManagedInstanceOperationParametersPair(currentParameters, requestedParameters);
}
else
{
managedInstanceOperation.OperationParameters = new Management.Sql.Models.ManagedInstanceOperationParametersPair();
}

IList<Management.Sql.Models.UpsertManagedServerOperationStep> stepsList = new List<Management.Sql.Models.UpsertManagedServerOperationStep>();
if (resp.OperationSteps != null && resp.OperationSteps.StepsList != null)
{
foreach (Management.Sql.Models.UpsertManagedServerOperationStep step in resp.OperationSteps.StepsList)
{
stepsList.Add(new Management.Sql.Models.UpsertManagedServerOperationStep(step.Order, step.Name, step.Status));
}

managedInstanceOperation.OperationSteps = new Management.Sql.Models.ManagedInstanceOperationSteps(resp.OperationSteps.TotalSteps, resp.OperationSteps.CurrentStep, stepsList);
}
else
{
managedInstanceOperation.OperationSteps = new Management.Sql.Models.ManagedInstanceOperationSteps();
}

return managedInstanceOperation;
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/Sql/Sql/help/Get-AzSqlInstanceOperation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ IsUserError :
EstimatedCompletionTime :
Description :
IsCancellable : False
OperationParameters : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationParametersPair
OperationSteps : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationSteps
Id : /subscriptions/a8c9a924-06c0-4bde-9788-e7b1370969e1/resourceGroups/ps3753/providers/Microsoft.Sql/managedInstances/ps3698/operations/79f2c91b-0080-4c14-b9b4-d9991c6e82dd
ResourceGroupName : ps3753
Expand All @@ -72,6 +74,8 @@ IsUserError :
EstimatedCompletionTime :
Description :
IsCancellable : False
OperationParameters : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationParametersPair
OperationSteps : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationSteps
```

This command gets all operations a SQL managed instance.
Expand All @@ -96,6 +100,8 @@ IsUserError :
EstimatedCompletionTime :
Description :
IsCancellable : False
OperationParameters : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationParametersPair
OperationSteps : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationSteps
```

This command gets operation with name '5870c6d8-6703-4b27-8ae4-687b4ca7caea' on a SQL managed instance.
Expand All @@ -121,6 +127,8 @@ IsUserError :
EstimatedCompletionTime :
Description :
IsCancellable : False
OperationParameters : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationParametersPair
OperationSteps : Microsoft.Azure.Management.Sql.Models.ManagedInstanceOperationSteps
```

This command gets operation with id '/subscriptions/a8c9a924-06c0-4bde-9788-e7b1370969e1/resourceGroups/ps3753/providers/Microsoft.Sql/managedInstances/ps3698/operations/5870c6d8-6703-4b27-8ae4-687b4ca7caea'.
Expand Down

0 comments on commit 8639a13

Please sign in to comment.