-
Notifications
You must be signed in to change notification settings - Fork 31
[2203] Add PS Cmdlets for VPN Admin API #151
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 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74fd3a5
Add PS Cmdlets for VPN Admin API
iancaragol 65f84e4
Merge branch 'dev' into vpncmd
iancaragol e1f7832
Update recording files and add new tests
iancaragol 9af0dce
Merge branch 'vpncmd' of https://github.com/iancaragol/azurestack-pow…
iancaragol ffc9db8
Remove psd1, fix Connection test, add changelog message
iancaragol e352d47
Update module version from 1.0.2 to 1.1
iancaragol 56bcd2e
Merge branch 'dev' into vpncmd
iancaragol 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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ obj | |
| generated | ||
| internal | ||
| exports | ||
| src/**/utils | ||
| src/**/tools | ||
| src/**/resources | ||
| .gitignore | ||
|
|
||
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,25 @@ | ||
| @{ | ||
| GUID = '70926bce-bc6d-44d9-9c7c-04173e27f5c9' | ||
| RootModule = 'Azs.Network.Admin.psm1' | ||
| ModuleVersion = '1.0.2' | ||
| CompatiblePSEditions = 'Core', 'Desktop' | ||
| Author = 'Microsoft Corporation' | ||
| CompanyName = 'Microsoft Corporation' | ||
| Copyright = 'Microsoft Corporation. All rights reserved.' | ||
| Description = 'Microsoft AzureStack PowerShell: Network Admin cmdlets' | ||
| PowerShellVersion = '5.1' | ||
| DotNetFrameworkVersion = '4.7.2' | ||
| RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.8'}, @{ModuleName = 'Az.Resources'; ModuleVersion = '0.12.0'}) | ||
| RequiredAssemblies = './bin/Azs.Network.Admin.private.dll' | ||
| FormatsToProcess = './Azs.Network.Admin.format.ps1xml' | ||
| FunctionsToExport = 'Get-AzsLoadBalancer', 'Get-AzsNetworkAdminOverview', 'Get-AzsNetworkQuota', 'Get-AzsPublicIPAddress', 'Get-AzsVirtualNetwork', 'Get-AzsVirtualNetworkGatewayConnection', 'New-AzsNetworkQuota', 'Remove-AzsNetworkQuota', 'Set-AzsNetworkQuota', '*' | ||
| AliasesToExport = '*' | ||
| PrivateData = @{ | ||
| PSData = @{ | ||
| Tags = 'AzureStack', 'ResourceManager', 'ARM', 'PSModule' | ||
| LicenseUri = 'https://aka.ms/azps-license' | ||
| ProjectUri = 'https://github.com/Azure/azurestack-powershell' | ||
| ReleaseNotes = 'AzureStack Hub Admin module generated with https://github.com/Azure/autorest.powershell' | ||
| } | ||
| } | ||
| } | ||
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,41 @@ | ||
| # Custom | ||
| This directory contains custom implementation for non-generated cmdlets for the `Azs.Network.Admin` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Azs.Network.Admin.custom.psm1`. This file should not be modified. | ||
|
|
||
| ## Info | ||
| - Modifiable: yes | ||
| - Generated: partial | ||
| - Committed: yes | ||
| - Packaged: yes | ||
|
|
||
| ## Details | ||
| For `Azs.Network.Admin` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*. | ||
|
|
||
| For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Azs.Network.Admin.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder. | ||
|
|
||
| For script cmdlets, these are loaded via the `Azs.Network.Admin.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build. | ||
|
|
||
| ## Purpose | ||
| This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder. | ||
|
|
||
| ## Usage | ||
| The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters: | ||
| - Break | ||
| - DefaultProfile | ||
| - HttpPipelineAppend | ||
| - HttpPipelinePrepend | ||
| - Proxy | ||
| - ProxyCredential | ||
| - ProxyUseDefaultCredentials | ||
|
|
||
| These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Azs.Network.Admin`. For C#, follow the usage seen in the `ProcessRecordAsync` method. | ||
|
|
||
| ### Attributes | ||
| For processing the cmdlets, we've created some additional attributes: | ||
| - `Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.DescriptionAttribute` | ||
| - Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts. | ||
| - `Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.DoNotExportAttribute` | ||
| - Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Azs.Network.Admin`. | ||
| - `Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.InternalExportAttribute` | ||
| - Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Azs.Network.Admin`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder. | ||
| - `Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.ProfileAttribute` | ||
| - Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules. |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be checked in, it gets generated and modified with the metadata specified in the readme.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I removed it