SHARE
TWEET

Untitled

a guest Apr 24th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Cluster {
  2.     [ValidatePattern("^[A-z]+$")]
  3.     [string] $Service
  4.     [ValidateSet("TEST", "STAGE", "CANARY", "PROD")]
  5.     [string] $FlightingRing
  6.     [ValidateSet("EastUS", "WestUS", "NorthEurope")]
  7.     [string] $Region
  8.     [ValidateRange(0, 255)]
  9.     [int] $Index
  10. }
  11.  
  12. function New-Cluster {
  13.     [OutputType([Cluster])]
  14.     Param(
  15.         [Parameter(Mandatory, ParameterSetName = "Id", Position = 0)]
  16.         [ValidateNotNullOrEmpty()]
  17.         [string] $Id,
  18.         [Parameter(Mandatory, ParameterSetName = "Components")]
  19.         [string] $Service,
  20.         [Parameter(Mandatory, ParameterSetName = "Components")]
  21.         [string] $FlightingRing,
  22.         [Parameter(Mandatory, ParameterSetName = "Components")]
  23.         [string] $Region,
  24.         [Parameter(Mandatory, ParameterSetName = "Components")]
  25.         [int] $Index
  26.     )
  27.  
  28.     if ($Id) {
  29.         $Service, $FlightingRing, $Region, $Index = $Id -split "-"
  30.     }
  31.  
  32.     [Cluster]@{
  33.         Service       = $Service
  34.         FlightingRing = $FlightingRing
  35.         Region        = $Region
  36.         Index         = $Index
  37.     }
  38. }
  39.  
  40. Export-ModuleMember New-Cluster
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top