Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cluster {
- [ValidatePattern("^[A-z]+$")]
- [string] $Service
- [ValidateSet("TEST", "STAGE", "CANARY", "PROD")]
- [string] $FlightingRing
- [ValidateSet("EastUS", "WestUS", "NorthEurope")]
- [string] $Region
- [ValidateRange(0, 255)]
- [int] $Index
- }
- function New-Cluster {
- [OutputType([Cluster])]
- Param(
- [Parameter(Mandatory, ParameterSetName = "Id", Position = 0)]
- [ValidateNotNullOrEmpty()]
- [string] $Id,
- [Parameter(Mandatory, ParameterSetName = "Components")]
- [string] $Service,
- [Parameter(Mandatory, ParameterSetName = "Components")]
- [string] $FlightingRing,
- [Parameter(Mandatory, ParameterSetName = "Components")]
- [string] $Region,
- [Parameter(Mandatory, ParameterSetName = "Components")]
- [int] $Index
- )
- if ($Id) {
- $Service, $FlightingRing, $Region, $Index = $Id -split "-"
- }
- [Cluster]@{
- Service = $Service
- FlightingRing = $FlightingRing
- Region = $Region
- Index = $Index
- }
- }
- Export-ModuleMember New-Cluster
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement