Skip to content

Commit 1288234

Browse files
committed
add log analytics and event hub support for audit cmdlets
1 parent 058a3c6 commit 1288234

23 files changed

+2156
-597
lines changed

src/Synapse/Synapse/Commands/ManagementCommands/Auditing/GetAzureSynapseSqlAudit.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 21 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,29 @@
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+
315
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;
617
using System.Management.Automation;
718

819
namespace Microsoft.Azure.Commands.Synapse
920
{
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
1527
{
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-
}
8428
}
8529
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
15+
using Microsoft.Azure.Commands.Synapse.Models;
16+
using Microsoft.Azure.Commands.Synapse.Models.Auditing;
17+
using Microsoft.Azure.Management.Synapse.Models;
18+
using System.Management.Automation;
19+
20+
namespace Microsoft.Azure.Commands.Synapse
21+
{
22+
[Cmdlet(
23+
VerbsCommon.Get,
24+
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + SynapseConstants.SynapsePrefix + DefinitionsCommon.WorkspaceAuditCmdletsSuffix,
25+
DefaultParameterSetName = DefinitionsCommon.WorkspaceParameterSetName),
26+
OutputType(typeof(WorkspaceAuditModel))]
27+
public class GetAzureSynapseWorkspaceAudit : SynapseWorkspaceAuditCmdlet<ExtendedServerBlobAuditingPolicy, WorkspaceAuditModel, SynapseWorkspaceAuditAdapter>
28+
{
29+
protected override SynapseWorkspaceAuditAdapter InitModelAdapter()
30+
{
31+
return new SynapseWorkspaceAuditAdapter(DefaultProfile.DefaultContext);
32+
}
33+
}
34+
}

src/Synapse/Synapse/Commands/ManagementCommands/Auditing/RemoveAzureSynapseSqlAudit.cs

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)