Skip to content

[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 7 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ obj
generated
internal
exports
src/**/utils
src/**/tools
src/**/resources
.gitignore
Expand Down
41 changes: 41 additions & 0 deletions src/Azs.Network.Admin/custom/README.md
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.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
Module Name: Azs.Network.Admin
Module Guid: 818c880d-2aa0-4aa3-961c-cc58c4ef12b2
Module Guid: 70926bce-bc6d-44d9-9c7c-04173e27f5c9
Download Help Link: https://docs.microsoft.com/en-us/powershell/module/azs.network.admin
Help Version: 1.0.0.0
Locale: en-US
---

# Azs.Network.Admin Module
## Description
Preview release of the Network operators module which allows operators to monitor network resources and manage network quotas.
Microsoft AzureStack PowerShell: Network Admin cmdlets

## Azs.Network.Admin Cmdlets
### [Get-AzsLoadBalancer](Get-AzsLoadBalancer.md)
Expand All @@ -26,6 +26,9 @@ List of public IP addresses.
### [Get-AzsVirtualNetwork](Get-AzsVirtualNetwork.md)
Get a list of all virtual networks.

### [Get-AzsVirtualNetworkGatewayConnection](Get-AzsVirtualNetworkGatewayConnection.md)
Returns a list of all Virtual Network Gateway Connections.

### [New-AzsNetworkQuota](New-AzsNetworkQuota.md)
Create or update a quota.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,34 @@ Get a list of all load balancers.

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------
### Example 1: Default Get
```powershell
Get-AzsLoadBalancer
To view examples, please use the -Online parameter with Get-Help or navigate to: https://docs.microsoft.com/en-us/powershell/module/azs.network.admin/get-azsloadbalancer
PS C:\> Get-AzsLoadBalancer

Id : /subscriptions/3ff3b1de-e7f5-43ad-b057-ace4767e7d01/resourceGroups/AppServiceLH01/providers/Microsoft.Network/loadBalancers/aps-sql-lb
Location :
Name : aps-sql-lb
ProvisioningState : Succeeded
PublicIPAddress : {}
SubscriptionId : 3ff3b1de-e7f5-43ad-b057-ace4767e7d01
Tag : Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.Models.Api20150615.ResourceTags
TenantResourceUri : /subscriptions/3ff3b1de-e7f5-43ad-b057-ace4767e7d01/resourceGroups/AppServiceLH01/providers/Microsoft.Network/loadBalancers/aps-sql-lb
Type : Microsoft.Network.Admin/adminLoadBalancers

Id : /subscriptions/3ff3b1de-e7f5-43ad-b057-ace4767e7d01/resourceGroups/AppServiceLH01/providers/Microsoft.Network/loadBalancers/FrontEndServersLoadBalanc
er
Location :
Name : FrontEndServersLoadBalancer
ProvisioningState : Succeeded
PublicIPAddress : {100.81.128.40}
SubscriptionId : 3ff3b1de-e7f5-43ad-b057-ace4767e7d01
Tag : Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.Models.Api20150615.ResourceTags
TenantResourceUri : /subscriptions/3ff3b1de-e7f5-43ad-b057-ace4767e7d01/resourceGroups/AppServiceLH01/providers/Microsoft.Network/loadBalancers/FrontEndServersLoadBalanc
er
Type : Microsoft.Network.Admin/adminLoadBalancers
```


Returns all of the virtual networks.

## PARAMETERS

Expand All @@ -45,7 +66,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -Filter
Expand All @@ -61,7 +81,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -InlineCount
Expand All @@ -77,7 +96,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -OrderBy
Expand All @@ -93,7 +111,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -Skip
Expand All @@ -109,7 +126,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -SubscriptionId
Expand All @@ -126,7 +142,6 @@ Position: Named
Default value: (Get-AzContext).Subscription.Id
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -Top
Expand All @@ -142,7 +157,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### CommonParameters
Expand All @@ -154,9 +168,9 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

### Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.Models.Api20150615.ILoadBalancer

## ALIASES

## NOTES

ALIASES

## RELATED LINKS

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,49 @@ Get an overview of the state of the network resource provider.

## EXAMPLES

### -------------------------- EXAMPLE 1 --------------------------
### Example 1: Default Get
```powershell
Get-AzsNetworkAdminOverview
To view examples, please use the -Online parameter with Get-Help or navigate to: https://docs.microsoft.com/en-us/powershell/module/azs.network.admin/get-azsnetworkadminoverview
PS C:\> Get-AzsNetworkAdminOverview

BackendIPUsageInUseResourceCount : 40
BackendIPUsageTotalResourceCount : 282
Id : /subscriptions/3ff3b1de-e7f5-43ad-b057-ace4767e7d01/providers/Microsoft.Network.Admin/adminOverview/
LoadBalancerMuxHealthErrorResourceCount : 0
LoadBalancerMuxHealthHealthyResourceCount : 2
LoadBalancerMuxHealthTotalResourceCount : 2
LoadBalancerMuxHealthUnknownCount : 0
LoadBalancerMuxHealthWarningResourceCount : 0
Location :
MacAddressUsageInUseResourceCount : 95
MacAddressUsageTotalResourceCount : 4063232
Name :
ProvisioningState : Succeeded
PublicIPAddressUsageInUseResourceCount : 65
PublicIPAddressUsageTotalResourceCount : 1023
Tag : Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.Models.Api20150615.ResourceTags
Type : Microsoft.Network.Admin/adminOverview
VirtualGatewayHealthErrorResourceCount : 0
VirtualGatewayHealthHealthyResourceCount : 2
VirtualGatewayHealthTotalResourceCount : 3
VirtualGatewayHealthUnknownCount : 1
VirtualGatewayHealthWarningResourceCount : 0
VirtualNetworkHealthErrorResourceCount : 0
VirtualNetworkHealthHealthyResourceCount : 0
VirtualNetworkHealthTotalResourceCount : 31
VirtualNetworkHealthUnknownCount : 31
VirtualNetworkHealthWarningResourceCount : 0
```

Returns an overview of Network Admin.

### Example 2: Get a specific value
```powershell
PS C:\> (Get-AzsNetworkAdminOverview).BackendIPUsageTotalResourceCount

282
```

Returns the total resource count of the backend IPs.

## PARAMETERS

Expand All @@ -51,7 +87,6 @@ Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### -InputObject
Expand All @@ -68,7 +103,6 @@ Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Dynamic: False
```

### -SubscriptionId
Expand All @@ -85,7 +119,6 @@ Position: Named
Default value: (Get-AzContext).Subscription.Id
Accept pipeline input: False
Accept wildcard characters: False
Dynamic: False
```

### CommonParameters
Expand All @@ -99,14 +132,16 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

### Microsoft.Azure.PowerShell.Cmdlets.NetworkAdmin.Models.Api20150615.IAdminOverview

## ALIASES

## NOTES

### COMPLEX PARAMETER PROPERTIES
ALIASES

COMPLEX PARAMETER PROPERTIES

To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.

#### INPUTOBJECT <INetworkAdminIdentity>: Identity Parameter

INPUTOBJECT <INetworkAdminIdentity>: Identity Parameter
- `[Id <String>]`: Resource identity path
- `[Location <String>]`: Location of the resource.
- `[ResourceName <String>]`: Name of the resource.
Expand Down
Loading