-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Network] Add New-AzExpressRoutePortLOA cmdlet #12465
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
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
62f8ebd
Add New-AzExpressRoutePortLOA cmdlet.
6709909
Add new cmdlet tests.
cbc3790
Remove unused variable.
c75d29a
Added help md files.
2fb7728
Supress static analysis warnings.
763fb8a
Change csproj for the SDK with LOA code.
40e6b69
Added details in changelog
e9e3735
Merge branch 'network-june' of https://github.com/Azure/azure-powersh…
6a3eedf
Revert "Change csproj for the SDK with LOA code."
68a8620
Added null validation for invalid ResourceId
21cb252
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
5872b9a
Update SDK version to the latest
7a26dd8
Add Error Suppresion
4beee1c
Change csproj
dbcc35f
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
2ea89e2
Trigger new build.
fd6ee41
Fix merge conflict markers
82072cb
Trigger CI build.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| # To make sure Network PRs go to the right branch, e.g. network-april | ||
| <<<<<<< HEAD | ||
| /src/Network/ @number213 | ||
|
|
||
| ======= | ||
| /src/Network/ @MikhailTryakhov | ||
| >>>>>>> bcb49468faa053add80c87357c9f56ffb360c730 | ||
| /src/Compute/ @bilaakpan-ms @sandido @dkulkarni-ms @haagha @madewithsmiles @MS-syh2qs @grizzlytheodore | ||
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
128 changes: 128 additions & 0 deletions
128
src/Network/Network/ExpressRoutePort/LOA/NewAzureRmExpressRoutePortLOACommand.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,128 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // 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. | ||
| // ---------------------------------------------------------------------------------- | ||
|
|
||
| using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
| using Microsoft.Azure.Commands.Network.Models; | ||
| using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; | ||
| using Microsoft.Azure.Management.Network; | ||
| using System; | ||
| using System.Management.Automation; | ||
| using System.IO; | ||
| using Microsoft.Azure.Management.Network.Models; | ||
| using System.ComponentModel; | ||
| using System.Security.Cryptography; | ||
|
|
||
| namespace Microsoft.Azure.Commands.Network | ||
| { | ||
| [Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortLOA", SupportsShouldProcess = false, DefaultParameterSetName = ResourceNameParameterSet), OutputType(typeof(bool))] | ||
| public partial class NewAzureRmExpressRoutePortLOA : NetworkBaseCmdlet | ||
| { | ||
| private const string ResourceIdParameterSet = "ResourceIdParameterSet"; | ||
| private const string ResourceNameParameterSet = "ResourceNameParameterSet"; | ||
| private const string ResourceObjectParameterSet = "ResourceObjectParameterSet"; | ||
| private const string DefaultFileName = "LOA.pdf"; | ||
|
|
||
| [Parameter( | ||
| ParameterSetName = ResourceNameParameterSet, | ||
| Mandatory = true, | ||
| HelpMessage = "The express route port name.", | ||
| ValueFromPipelineByPropertyName = false)] | ||
| [ValidateNotNullOrEmpty] | ||
| public string PortName { get; set; } | ||
|
|
||
| [Parameter( | ||
| ParameterSetName = ResourceNameParameterSet, | ||
| Mandatory = true, | ||
| HelpMessage = "The resource group name of the express route port.", | ||
| ValueFromPipelineByPropertyName = false)] | ||
| [ResourceGroupCompleter] | ||
| [ValidateNotNullOrEmpty] | ||
| public string ResourceGroupName { get; set; } | ||
|
|
||
| [Parameter( | ||
| ParameterSetName = ResourceObjectParameterSet, | ||
| Mandatory = true, | ||
| HelpMessage = "The express route port resource.", | ||
| ValueFromPipelineByPropertyName = false)] | ||
| [ValidateNotNullOrEmpty] | ||
| public PSExpressRoutePort ExpressRoutePort { get; set; } | ||
|
|
||
| [Alias("ResourceId")] | ||
| [Parameter( | ||
| ParameterSetName = ResourceIdParameterSet, | ||
| Mandatory = true, | ||
| HelpMessage = "ResourceId of the express route port.", | ||
| ValueFromPipelineByPropertyName = true)] | ||
| [ValidateNotNullOrEmpty] | ||
| public string Id { get; set; } | ||
|
|
||
| [Alias("Name")] | ||
| [Parameter( | ||
| Mandatory = true, | ||
| HelpMessage = "The customer name to whom this Express Route Port is assigned to.", | ||
| ValueFromPipelineByPropertyName = false)] | ||
| [ValidateNotNullOrEmpty] | ||
| public string CustomerName { get; set; } | ||
|
|
||
| [Parameter( | ||
| Mandatory = false, | ||
| HelpMessage = "The output filepath to store the Letter of Authorization to.", | ||
| ValueFromPipelineByPropertyName = false)] | ||
| public string Destination { get; set; } | ||
|
|
||
| [Parameter(Mandatory = false)] | ||
| public SwitchParameter PassThru { get; set; } | ||
|
|
||
| [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] | ||
| public SwitchParameter AsJob { get; set; } | ||
|
|
||
| public override void Execute() | ||
| { | ||
| base.Execute(); | ||
|
|
||
| if (string.Equals(this.ParameterSetName, ResourceObjectParameterSet, StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| ResourceGroupName = ExpressRoutePort.ResourceGroupName; | ||
| PortName = ExpressRoutePort.Name; | ||
| } | ||
| if (string.Equals(this.ParameterSetName, ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| var resourceInfo = new ResourceIdentifier(Id); | ||
| ResourceGroupName = resourceInfo.ResourceGroupName; | ||
| PortName = resourceInfo.ResourceName; | ||
| } | ||
| if(this.ResourceGroupName == null || this.PortName == null){ | ||
| Console.WriteLine("Empty resource group or port name."); | ||
| return; | ||
| } | ||
| GenerateExpressRoutePortsLOARequest generateExpressRoutePortsLOARequest = new GenerateExpressRoutePortsLOARequest(CustomerName); | ||
| var response = this.NetworkClient.NetworkManagementClient.ExpressRoutePorts.GenerateLOA(this.ResourceGroupName, this.PortName, generateExpressRoutePortsLOARequest); | ||
| var decodedDocument = Convert.FromBase64String(response.EncodedContent); | ||
| if (String.IsNullOrEmpty(Destination)) | ||
| { | ||
| Destination = DefaultFileName; | ||
| } | ||
| if (!(Path.IsPathRooted(Destination))) | ||
| { | ||
| Destination = Directory.GetCurrentDirectory() + "\\" + Destination; | ||
| } | ||
| File.WriteAllBytes(Destination, decodedDocument); | ||
| Console.WriteLine("Written Letter of Authorization To: " + Destination); | ||
| if (PassThru) | ||
| { | ||
| WriteObject(true); | ||
| } | ||
| } | ||
| } | ||
| } |
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.