Skip to content

Commit 28e217c

Browse files
author
Hovsep Mkrtchyan
committed
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
2 parents 1950a42 + 98c119a commit 28e217c

23 files changed

+2195
-28
lines changed

src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
<Reference Include="System.Xml.Linq" />
133133
</ItemGroup>
134134
<ItemGroup>
135+
<Compile Include="DataCollection\DisableAzureDataCollection.cs" />
136+
<Compile Include="DataCollection\EnableAzureDataCollection.cs" />
135137
<Compile Include="Environment\RemoveAzureRMEnvironment.cs" />
136138
<Compile Include="Environment\GetAzureRMEnvironment.cs" />
137139
<Compile Include="Environment\SetAzureRMEnvironment.cs" />
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 System.Management.Automation;
16+
using Microsoft.Azure.Commands.Profile.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common;
18+
using System.Security.Permissions;
19+
20+
namespace Microsoft.Azure.Commands.Profile
21+
{
22+
[Cmdlet(VerbsLifecycle.Disable, "AzureDataCollection")]
23+
public class DisableAzureDataCollectionCommand : EnableAzureDataCollectionCommand
24+
{
25+
protected override void ProcessRecord()
26+
{
27+
SetDataCollectionProfile(false);
28+
}
29+
}
30+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 System.Management.Automation;
16+
using Microsoft.Azure.Commands.Profile.Models;
17+
using Microsoft.Azure.Commands.ResourceManager.Common;
18+
using System.Security.Permissions;
19+
20+
namespace Microsoft.Azure.Commands.Profile
21+
{
22+
[Cmdlet(VerbsLifecycle.Enable, "AzureDataCollection")]
23+
public class EnableAzureDataCollectionCommand : AzureRMCmdlet
24+
{
25+
protected override void ProcessRecord()
26+
{
27+
SetDataCollectionProfile(true);
28+
}
29+
30+
protected void SetDataCollectionProfile(bool enable)
31+
{
32+
var profile = GetDataCollectionProfile();
33+
profile.EnableAzureDataCollection = enable;
34+
SaveDataCollectionProfile();
35+
}
36+
}
37+
}

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Commands.Resources.Rest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@
111111
<Compile Include="Entities\Locks\LockLevel.cs" />
112112
<Compile Include="Entities\Locks\LockProperties.cs" />
113113
<Compile Include="Entities\Operations\AzureAsyncOperationResource.cs" />
114+
<Compile Include="Entities\Policy\PolicyAssignment.cs" />
115+
<Compile Include="Entities\Policy\PolicyAssignmentProperties.cs" />
114116
<Compile Include="Entities\Policy\PolicyDefinition.cs" />
115117
<Compile Include="Entities\Policy\PolicyDefinitionProperties.cs" />
116118
<Compile Include="Entities\Policy\PolicyRule.cs" />
@@ -140,10 +142,15 @@
140142
<Compile Include="Implementation\InvokeAzureResourceActionCmdlet.cs" />
141143
<Compile Include="Implementation\MoveAzureResourceCmdlet.cs" />
142144
<Compile Include="Implementation\NewAzureResourceLockCmdlet.cs" />
145+
<Compile Include="Implementation\Policy\GetAzurePolicyAssignment.cs" />
143146
<Compile Include="Implementation\Policy\GetAzurePolicyDefinition.cs" />
147+
<Compile Include="Implementation\Policy\NewAzurePolicyAssignment.cs" />
144148
<Compile Include="Implementation\Policy\NewAzurePolicyDefinition.cs" />
149+
<Compile Include="Implementation\Policy\PolicyAssignmentCmdletBase.cs" />
145150
<Compile Include="Implementation\Policy\PolicyDefinitionCmdletBase.cs" />
151+
<Compile Include="Implementation\Policy\RemoveAzurePolicyAssignment.cs" />
146152
<Compile Include="Implementation\Policy\RemoveAzurePolicyDefinition.cs" />
153+
<Compile Include="Implementation\Policy\SetAzurePolicyAssignment.cs" />
147154
<Compile Include="Implementation\Policy\SetAzurePolicyDefinition.cs" />
148155
<Compile Include="Implementation\RemoveAzureResourceCmdlet.cs" />
149156
<Compile Include="Implementation\RemoveAzureResourceLockCmdlet.cs" />

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Components/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public static class Constants
7474
/// </summary>
7575
public static readonly string MicrosoftAuthorizationPolicyDefinitionType = Constants.MicrosoftAuthorizationNamespace + "/policydefinitions";
7676

77+
/// <summary>
78+
/// The policy definition resource type.
79+
/// </summary>
80+
public static readonly string MicrosoftAuthorizationPolicyAssignmentType = Constants.MicrosoftAuthorizationNamespace + "/policyassignments";
81+
7782
/// <summary>
7883
/// The type name of the generic resource.
7984
/// </summary>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
16+
{
17+
using Newtonsoft.Json;
18+
19+
/// <summary>
20+
/// The policy assignment object.
21+
/// </summary>
22+
public class PolicyAssignment
23+
{
24+
/// <summary>
25+
/// The policy assignment properties.
26+
/// </summary>
27+
[JsonProperty(Required = Required.Default)]
28+
public PolicyAssignmentProperties Properties { get; set; }
29+
30+
/// <summary>
31+
/// The policy assignment name.
32+
/// </summary>
33+
[JsonProperty(Required = Required.Default)]
34+
public string Name { get; set; }
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
16+
{
17+
using Newtonsoft.Json;
18+
19+
/// <summary>
20+
/// The policy assignment properties.
21+
/// </summary>
22+
public class PolicyAssignmentProperties
23+
{
24+
/// <summary>
25+
/// The scope.
26+
/// </summary>
27+
[JsonProperty(Required = Required.Always)]
28+
public string Scope { get; set; }
29+
30+
/// <summary>
31+
/// The display name.
32+
/// </summary>
33+
[JsonProperty(Required = Required.Default)]
34+
public string DisplayName { get; set; }
35+
36+
/// <summary>
37+
/// The policy definition id.
38+
/// </summary>
39+
[JsonProperty(Required = Required.Always)]
40+
public string PolicyDefinitionId { get; set; }
41+
}
42+
}

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Entities/Policy/PolicyDefinition.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
2121
/// </summary>
2222
public class PolicyDefinition
2323
{
24+
/// <summary>
25+
/// The policy definition name.
26+
/// </summary>
27+
[JsonProperty(Required = Required.Default)]
28+
public string Name { get; set; }
29+
2430
/// <summary>
2531
/// The policy definition properties.
2632
/// </summary>

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Entities/Policy/PolicyDefinitionProperties.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Entities.Policy
1616
{
1717
using Newtonsoft.Json;
18+
using Newtonsoft.Json.Linq;
1819

1920
/// <summary>
2021
/// The policy definition properties.
@@ -37,6 +38,6 @@ public class PolicyDefinitionProperties
3738
/// The policy rule.
3839
/// </summary>
3940
[JsonProperty(Required = Required.Always)]
40-
public PolicyRule PolicyRule { get; set; }
41+
public JObject PolicyRule { get; set; }
4142
}
4243
}

0 commit comments

Comments
 (0)