-
Notifications
You must be signed in to change notification settings - Fork 4k
Adding support for security provider integration in cortex cmdlets. #7261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
maddieclayton
merged 18 commits into
Azure:AzureRM.Network-preview
from
ritwikbasu:nalin-september-release
Sep 21, 2018
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7d40f13
Adding support for security provider integration.
5f248bf
Adding help files.
26a5a16
Fixing build error.
9a45366
Merging with Azure/AzureRM.Network-preview
01aee94
Adding changelog.
d506b0e
Resolving comments.
6d36fa7
Resolving help file comment.
78e2d20
Reverting back unnessary change.
9babcd9
Merging with latest.
28c24d7
Resolving more comments.
8e27d5a
Resovling more comments.
4b8e8c9
Resolving all comments.
6574078
Fixing more comments.
b264e8a
Recording test.
82e5c10
Resolving more comments.
933aa2b
Adding recorede test to cred scan exception.
8d302f3
More.
530e6e9
Correcting help file.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
11,034 changes: 6,320 additions & 4,714 deletions
11,034
...k.Test/SessionRecords/Commands.Network.Test.ScenarioTests.CortexTests/TestCortexCRUD.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
142 changes: 142 additions & 0 deletions
142
...mands.Network/Cortex/HubVnetConnection/UpdateAzureRmHubVirtualNetworkConnectionCommand.cs
This file contains hidden or 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,142 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Azure.Commands.Network | ||
{ | ||
using AutoMapper; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Management.Automation; | ||
using System.Security; | ||
using Microsoft.Azure.Commands.Network.Models; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.Tags; | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.WindowsAzure.Commands.Common; | ||
using MNM = Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using System.Linq; | ||
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
|
||
[Cmdlet("Update", | ||
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHubVnetConnection", | ||
DefaultParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName, | ||
SupportsShouldProcess = true), | ||
OutputType(typeof(PSHubVirtualNetworkConnection))] | ||
public class UpdateAzureRmHubVirtualNetworkConnectionCommand : HubVnetConnectionBaseCmdlet | ||
{ | ||
[Parameter( | ||
Mandatory = true, | ||
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName, | ||
HelpMessage = "The resource group name.")] | ||
[ResourceGroupCompleter] | ||
[ValidateNotNullOrEmpty] | ||
public virtual string ResourceGroupName { get; set; } | ||
|
||
[Alias("VirtualHubName", "ParentVirtualHubName")] | ||
[Parameter( | ||
Mandatory = true, | ||
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName, | ||
HelpMessage = "The parent resource name.")] | ||
[ResourceGroupCompleter] | ||
public string ParentResourceName { get; set; } | ||
|
||
[Alias("ResourceName", "HubVirtualNetworkConnectionName")] | ||
[Parameter( | ||
Mandatory = true, | ||
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName, | ||
HelpMessage = "The resource name.")] | ||
[ValidateNotNullOrEmpty] | ||
public virtual string Name { get; set; } | ||
|
||
[Alias("HubVirtualNetworkConnection")] | ||
[Parameter( | ||
Mandatory = true, | ||
ValueFromPipeline = true, | ||
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionObject, | ||
HelpMessage = "The hubvirtualnetworkconnection resource to modify.")] | ||
public PSHubVirtualNetworkConnection InputObject { get; set; } | ||
|
||
[Alias("HubVirtualNetworkConnectionId")] | ||
[Parameter( | ||
Mandatory = true, | ||
ValueFromPipelineByPropertyName = true, | ||
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionResourceId, | ||
HelpMessage = "The resource id of the hubvirtualnetworkconnection resource to modify.")] | ||
public string ResourceId { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = false, | ||
HelpMessage = "Enable internet security for this connection.")] | ||
public bool? EnableInternetSecurity { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = false, | ||
HelpMessage = "Run cmdlet in the background")] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
|
||
//// Resolve the VirtualHub | ||
if (ParameterSetName.Equals(CortexParameterSetNames.ByHubVirtualNetworkConnectionObject, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
this.ResourceId = this.InputObject.Id; | ||
|
||
if (string.IsNullOrWhiteSpace(this.ResourceId)) | ||
{ | ||
throw new PSArgumentException(Properties.Resources.HubVnetConnectionNotFound); | ||
} | ||
|
||
var parsedResourceId = new ResourceIdentifier(this.ResourceId); | ||
this.ResourceGroupName = parsedResourceId.ResourceGroupName; | ||
this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); | ||
this.Name = parsedResourceId.ResourceName; | ||
} | ||
else if (ParameterSetName.Equals(CortexParameterSetNames.ByHubVirtualNetworkConnectionResourceId, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
var parsedResourceId = new ResourceIdentifier(this.ResourceId); | ||
this.ResourceGroupName = parsedResourceId.ResourceGroupName; | ||
this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); | ||
this.Name = parsedResourceId.ResourceName; | ||
} | ||
|
||
//// Get the virtual hub - this will throw not found if the resource is invalid | ||
PSVirtualHub parentVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName); | ||
|
||
var connectionToModify = parentVirtualHub.VirtualNetworkConnections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)); | ||
if (connectionToModify == null) | ||
{ | ||
throw new PSArgumentException(Properties.Resources.HubVnetConnectionNotFound); | ||
} | ||
|
||
if (this.EnableInternetSecurity.HasValue) | ||
{ | ||
connectionToModify.EnableInternetSecurity = this.EnableInternetSecurity.Value; | ||
} | ||
|
||
ConfirmAction( | ||
Properties.Resources.SettingResourceMessage, | ||
this.Name, | ||
() => | ||
{ | ||
this.CreateOrUpdateVirtualHub(this.ResourceGroupName, this.ParentResourceName, parentVirtualHub, parentVirtualHub.Tag); | ||
var updatedVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName); | ||
|
||
WriteObject(updatedVirtualHub.VirtualNetworkConnections.FirstOrDefault(hubConnection => hubConnection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))); | ||
}); | ||
} | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...ommands.Network/Cortex/VirtualWan/GetAzureRmVirtualWanSupportedSecurityProviderCommand.cs
This file contains hidden or 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,90 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
namespace Microsoft.Azure.Commands.Network | ||
{ | ||
using System; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.Network.Models; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
using Microsoft.Azure.Management.Network; | ||
|
||
[Cmdlet( | ||
VerbsCommon.Get, | ||
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualWanSupportedSecurityProvider", | ||
DefaultParameterSetName = CortexParameterSetNames.ByVirtualWanName), | ||
OutputType(typeof(PSVirtualWanSecurityProvider))] | ||
public class GetAzureRmVirtualWanSupportedSecurityProviderCommand : VirtualWanBaseCmdlet | ||
{ | ||
[Parameter( | ||
ParameterSetName = CortexParameterSetNames.ByVirtualWanName, | ||
Mandatory = true, | ||
HelpMessage = "The resource group name.")] | ||
[ResourceGroupCompleter] | ||
[ValidateNotNullOrEmpty] | ||
public string ResourceGroupName { get; set; } | ||
|
||
[Alias("ResourceName", "VirtualWanName")] | ||
[Parameter( | ||
ParameterSetName = CortexParameterSetNames.ByVirtualWanName, | ||
Mandatory = true, | ||
HelpMessage = "The resource name.")] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Alias("VirtualWan")] | ||
[Parameter( | ||
ParameterSetName = CortexParameterSetNames.ByVirtualWanObject, | ||
Mandatory = true, | ||
ValueFromPipeline = true, | ||
HelpMessage = "The virtual wan object to be modified")] | ||
[ValidateNotNullOrEmpty] | ||
public PSVirtualWan InputObject { get; set; } | ||
|
||
[Alias("VirtualWanId")] | ||
[Parameter( | ||
ParameterSetName = CortexParameterSetNames.ByVirtualWanResourceId, | ||
Mandatory = true, | ||
ValueFromPipelineByPropertyName = true, | ||
HelpMessage = "The Azure resource ID for the virtual wan.")] | ||
public string ResourceId { get; set; } | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
|
||
//// Resolve the virtual wan | ||
if (ParameterSetName.Contains(CortexParameterSetNames.ByVirtualWanObject)) | ||
{ | ||
this.ResourceGroupName = this.InputObject.ResourceGroupName; | ||
this.Name = this.InputObject.Name; | ||
} | ||
else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualWanResourceId)) | ||
{ | ||
var parsedResourceId = new ResourceIdentifier(this.ResourceId); | ||
this.ResourceGroupName = parsedResourceId.ResourceGroupName; | ||
this.Name = parsedResourceId.ResourceName; | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(this.ResourceGroupName) || string.IsNullOrWhiteSpace(this.Name)) | ||
{ | ||
throw new PSArgumentException(Properties.Resources.VirtualWanRequiredForVpnSiteConfiguration); | ||
} | ||
|
||
var supportedSecurityProviders = NetworkClient.NetworkManagementClient.SupportedSecurityProviders(this.ResourceGroupName, this.Name); | ||
WriteObject(supportedSecurityProviders.SupportedProviders); | ||
} | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.