|
1 |
| -using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; |
2 |
| -using Microsoft.Azure.Commands.Synapse.Common; |
| 1 | +// ---------------------------------------------------------------------------------- |
| 2 | +// |
| 3 | +// Copyright Microsoft Corporation |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// Unless required by applicable law or agreed to in writing, software |
| 9 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | +// See the License for the specific language governing permissions and |
| 12 | +// limitations under the License. |
| 13 | +// ---------------------------------------------------------------------------------- |
| 14 | + |
3 | 15 | using Microsoft.Azure.Commands.Synapse.Models;
|
4 |
| -using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; |
5 |
| -using Microsoft.WindowsAzure.Commands.Utilities.Common; |
| 16 | +using Microsoft.Azure.Commands.Synapse.Models.Auditing; |
6 | 17 | using System.Management.Automation;
|
7 | 18 |
|
8 | 19 | namespace Microsoft.Azure.Commands.Synapse
|
9 | 20 | {
|
10 |
| - [Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + SynapseConstants.SqlPool + SynapseConstants.AuditSetting, |
11 |
| - DefaultParameterSetName = GetByNameParameterSet)] |
12 |
| - [Alias("Get-AzSynapseSqlPoolAudit")] |
13 |
| - [OutputType(typeof(SqlPoolAuditModel))] |
14 |
| - public class GetAzureSynapseSqlPoolAudit : SynapseManagementCmdletBase |
| 21 | + [Cmdlet( |
| 22 | + VerbsCommon.Get, |
| 23 | + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + DefinitionsCommon.SqlPoolAuditCmdletsSuffix, |
| 24 | + DefaultParameterSetName = DefinitionsCommon.SqlPoolParameterSetName), |
| 25 | + OutputType(typeof(SqlPoolAuditModel))] |
| 26 | + public class GetAzureSynapseSqlPoolAudit : SynapseSqlPoolAuditCmdlet |
15 | 27 | {
|
16 |
| - private const string GetByNameParameterSet = "GetByNameParameterSet"; |
17 |
| - private const string GetByParentObjectParameterSet = "GetByParentObjectParameterSet"; |
18 |
| - private const string GetByInputObjectParameterSet = "GetByInputObjectParameterSet"; |
19 |
| - private const string GetByResourceIdParameterSet = "GetByResourceIdParameterSet"; |
20 |
| - |
21 |
| - [Parameter(Mandatory = false, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.ResourceGroupName)] |
22 |
| - [ResourceGroupCompleter] |
23 |
| - [ValidateNotNullOrEmpty] |
24 |
| - public string ResourceGroupName { get; set; } |
25 |
| - |
26 |
| - [Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.WorkspaceName)] |
27 |
| - [ResourceNameCompleter(ResourceTypes.Workspace, nameof(ResourceGroupName))] |
28 |
| - [ValidateNotNullOrEmpty] |
29 |
| - public string WorkspaceName { get; set; } |
30 |
| - |
31 |
| - [Parameter(Mandatory = true, ParameterSetName = GetByNameParameterSet, HelpMessage = HelpMessages.SqlPoolName)] |
32 |
| - [Parameter(Mandatory = true, ParameterSetName = GetByParentObjectParameterSet, HelpMessage = HelpMessages.SqlPoolName)] |
33 |
| - [ResourceNameCompleter( |
34 |
| - ResourceTypes.SqlPool, |
35 |
| - nameof(ResourceGroupName), |
36 |
| - nameof(WorkspaceName))] |
37 |
| - [ValidateNotNullOrEmpty] |
38 |
| - public string Name { get; set; } |
39 |
| - |
40 |
| - [Parameter(ValueFromPipeline = true, ParameterSetName = GetByParentObjectParameterSet, |
41 |
| - Mandatory = true, HelpMessage = HelpMessages.WorkspaceObject)] |
42 |
| - [ValidateNotNull] |
43 |
| - public PSSynapseWorkspace WorkspaceObject { get; set; } |
44 |
| - |
45 |
| - [Parameter(ValueFromPipeline = true, ParameterSetName = GetByInputObjectParameterSet, Mandatory = true, |
46 |
| - HelpMessage = HelpMessages.SqlPoolObject)] |
47 |
| - [ValidateNotNull] |
48 |
| - public PSSynapseSqlPool InputObject { get; set; } |
49 |
| - |
50 |
| - [Parameter(ValueFromPipelineByPropertyName = false, ParameterSetName = GetByResourceIdParameterSet, |
51 |
| - Mandatory = true, HelpMessage = HelpMessages.SqlPoolResourceId)] |
52 |
| - [ValidateNotNullOrEmpty] |
53 |
| - public string ResourceId { get; set; } |
54 |
| - |
55 |
| - public override void ExecuteCmdlet() |
56 |
| - { |
57 |
| - if (this.IsParameterBound(c => c.WorkspaceObject)) |
58 |
| - { |
59 |
| - this.ResourceGroupName = new ResourceIdentifier(this.WorkspaceObject.Id).ResourceGroupName; |
60 |
| - this.WorkspaceName = this.WorkspaceObject.Name; |
61 |
| - } |
62 |
| - |
63 |
| - if (this.IsParameterBound(c => c.InputObject)) |
64 |
| - { |
65 |
| - var resourceIdentifier = new ResourceIdentifier(this.InputObject.Id); |
66 |
| - this.ResourceGroupName = resourceIdentifier.ResourceGroupName; |
67 |
| - this.WorkspaceName = resourceIdentifier.ParentResource; |
68 |
| - this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); |
69 |
| - this.Name = resourceIdentifier.ResourceName; |
70 |
| - } |
71 |
| - |
72 |
| - if (this.IsParameterBound(c => c.ResourceId)) |
73 |
| - { |
74 |
| - var resourceIdentifier = new ResourceIdentifier(this.ResourceId); |
75 |
| - this.ResourceGroupName = resourceIdentifier.ResourceGroupName; |
76 |
| - this.WorkspaceName = resourceIdentifier.ParentResource; |
77 |
| - this.WorkspaceName = this.WorkspaceName.Substring(this.WorkspaceName.LastIndexOf('/') + 1); |
78 |
| - this.Name = resourceIdentifier.ResourceName; |
79 |
| - } |
80 |
| - |
81 |
| - var result = SynapseAnalyticsClient.GetSqlPoolAudit(this.ResourceGroupName, this.WorkspaceName, this.Name); |
82 |
| - WriteObject(result); |
83 |
| - } |
84 | 28 | }
|
85 | 29 | }
|
0 commit comments