-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synapse] Add SQL pool related cmdlets (#13243)
Force merge after CI passed * add new cmdlets for sql pool * add test for sql pool * update help docs * update change log * fix for test Co-authored-by: Wan Yang <[email protected]> Co-authored-by: Yunchi Wang <[email protected]> Co-authored-by: Dingmeng Xue <[email protected]> Co-authored-by: Jin Lei <[email protected]>
- Loading branch information
1 parent
40879b9
commit 9f33a5e
Showing
23 changed files
with
8,214 additions
and
1,399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6,805 changes: 6,214 additions & 591 deletions
6,805
.../Microsoft.Azure.Commands.Synapse.Test.ScenarioTests.SqlPoolTests/TestSynapseSqlPool.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...Synapse/Synapse/Commands/ManagementCommands/SqlPool/GetAzureSynapseSqlPoolRestorePoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Commands.Synapse.Common; | ||
using Microsoft.Azure.Commands.Synapse.Models; | ||
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Synapse | ||
{ | ||
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SqlPool + SynapseConstants.RestorePoint, | ||
DefaultParameterSetName = GetByNameParameterSet)] | ||
[OutputType(typeof(PSRestorePoint))] | ||
public class GetAzureSynapseSqlPoolRestorePoint : SynapseManagementCmdletBase | ||
{ | ||
private const string GetByNameParameterSet = "GetByNameParameterSet"; | ||
private const string GetByParentObjectParameterSet = "GetByParentObjectParameterSet"; | ||
private const string GetByInputObjectParameterSet = "GetByInputObjectParameterSet"; | ||
private const string GetByResourceIdParameterSet = "GetByResourceIdParameterSet"; | ||
|
||
[Parameter(Mandatory = false, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.ResourceGroupName)] | ||
[ResourceGroupCompleter] | ||
[ValidateNotNullOrEmpty] | ||
public string ResourceGroupName { get; set; } | ||
|
||
[Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.WorkspaceName)] | ||
[ResourceNameCompleter(ResourceTypes.Workspace, nameof(ResourceGroupName))] | ||
[ValidateNotNullOrEmpty] | ||
public string WorkspaceName { get; set; } | ||
|
||
[Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.SqlPoolName)] | ||
[Parameter(Mandatory = true, ParameterSetName = GetByParentObjectParameterSet, HelpMessage = HelpMessages.SqlPoolName)] | ||
[ResourceNameCompleter( | ||
ResourceTypes.SqlPool, | ||
nameof(ResourceGroupName), | ||
nameof(WorkspaceName))] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = GetByParentObjectParameterSet, | ||
Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)] | ||
[ValidateNotNull] | ||
public PSSynapseWorkspace WorkspaceObject { get; set; } | ||
|
||
[Parameter(ValueFromPipeline = true, ParameterSetName = GetByInputObjectParameterSet, Mandatory = true, | ||
HelpMessage = HelpMessages.SqlPoolObject)] | ||
[ValidateNotNull] | ||
public PSSynapseSqlPool InputObject { get; set; } | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = GetByResourceIdParameterSet, | ||
Mandatory = true, HelpMessage = HelpMessages.SqlPoolResourceId)] | ||
[ValidateNotNullOrEmpty] | ||
public string ResourceId { get; set; } | ||
|
||
public override void ExecuteCmdlet() | ||
{ | ||
if (this.IsParameterBound(c => c.WorkspaceObject)) | ||
{ | ||
this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName; | ||
this.WorkspaceName = this.WorkspaceObject.Name; | ||
} | ||
|
||
if (this.IsParameterBound(c => c.InputObject)) | ||
{ | ||
var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id); | ||
this.ResourceGroupName = resourceIdentifier.ResourceGroupName; | ||
this.WorkspaceName = resourceIdentifier.ParentResource; | ||
this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); | ||
this.Name = resourceIdentifier.ResourceName; | ||
} | ||
|
||
if (this.IsParameterBound(c => c.ResourceId)) | ||
{ | ||
var resourceIdentifier = new ResourceIdentifier(this.ResourceId); | ||
this.ResourceGroupName = resourceIdentifier.ResourceGroupName; | ||
this.WorkspaceName = resourceIdentifier.ParentResource; | ||
this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); | ||
this.Name = resourceIdentifier.ResourceName; | ||
} | ||
|
||
if (string.IsNullOrEmpty(this.ResourceGroupName)) | ||
{ | ||
this.ResourceGroupName = this.SynapseAnalyticsClient.GetResourceGroupByWorkspaceName(this.WorkspaceName); | ||
} | ||
|
||
var result = this.SynapseAnalyticsClient.ListSqlPoolRestorePoints(this.ResourceGroupName, this.WorkspaceName, this.Name) | ||
.Select(element => new PSRestorePoint(element)); | ||
WriteObject(result, true); | ||
} | ||
} | ||
} |
Oops, something went wrong.