/// <summary> /// Convert a Management.Sql.LegacySdk.Models.ManagedInstance to AzureSqlDatabaseManagedInstanceModel /// </summary> /// <param name="resp">The management client managed instance response to convert</param> /// <returns>The converted managed instance model</returns> private static AzureSqlManagedInstanceOperationModel CreateManagedInstanceOperationModelFromResponse(Management.Sql.Models.ManagedInstanceOperation resp) { AzureSqlManagedInstanceOperationModel managedInstanceOperation = new AzureSqlManagedInstanceOperationModel(); // Extract the resource group name from the ID. // ID is in the form: // /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Sql/managedInstances/managedInstanceName string[] segments = resp.Id.Split('/'); managedInstanceOperation.ResourceGroupName = segments[4]; managedInstanceOperation.ManagedInstanceName = resp.ManagedInstanceName; managedInstanceOperation.Id = resp.Id; managedInstanceOperation.Name = resp.Name; managedInstanceOperation.Description = resp.Description; managedInstanceOperation.ErrorCode = resp.ErrorCode; managedInstanceOperation.ErrorDescription = resp.ErrorDescription; managedInstanceOperation.ErrorSeverity = resp.ErrorSeverity; managedInstanceOperation.EstimatedCompletionTime = resp.EstimatedCompletionTime; managedInstanceOperation.IsCancellable = resp.IsCancellable; managedInstanceOperation.Operation = resp.Operation; managedInstanceOperation.OperationFriendlyName = resp.OperationFriendlyName; managedInstanceOperation.PercentComplete = resp.PercentComplete; managedInstanceOperation.StartTime = resp.StartTime; managedInstanceOperation.State = resp.State; managedInstanceOperation.IsUserError = resp.IsUserError; return(managedInstanceOperation); }
/// <summary> /// Convert a Management.Sql.LegacySdk.Models.ManagedInstance to AzureSqlDatabaseManagedInstanceModel /// </summary> /// <param name="resp">The management client managed instance response to convert</param> /// <returns>The converted managed instance model</returns> private static AzureSqlManagedInstanceOperationModel CreateManagedInstanceOperationModelFromResponse(Management.Sql.Models.ManagedInstanceOperation resp) { AzureSqlManagedInstanceOperationModel managedInstanceOperation = new AzureSqlManagedInstanceOperationModel(); // Extract the resource group name from the ID. // ID is in the form: // /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Sql/managedInstances/managedInstanceName string[] segments = resp.Id.Split('/'); managedInstanceOperation.ResourceGroupName = segments[4]; managedInstanceOperation.ManagedInstanceName = resp.ManagedInstanceName; managedInstanceOperation.Id = resp.Id; managedInstanceOperation.Name = resp.Name; managedInstanceOperation.Description = resp.Description; managedInstanceOperation.ErrorCode = resp.ErrorCode; managedInstanceOperation.ErrorDescription = resp.ErrorDescription; managedInstanceOperation.ErrorSeverity = resp.ErrorSeverity; managedInstanceOperation.EstimatedCompletionTime = resp.EstimatedCompletionTime; managedInstanceOperation.IsCancellable = resp.IsCancellable; managedInstanceOperation.Operation = resp.Operation; managedInstanceOperation.OperationFriendlyName = resp.OperationFriendlyName; managedInstanceOperation.PercentComplete = resp.PercentComplete; managedInstanceOperation.StartTime = resp.StartTime; 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); }