first working types

This commit is contained in:
2022-12-06 17:20:45 +03:00
parent a1b03b81c0
commit 7d0d1b53ae
14 changed files with 129 additions and 75 deletions

View File

@@ -10,19 +10,25 @@ function Get-FirstFreeIP {
[ValidateScript({ $_ -match "^\d+$" })]
[ValidateNotNullOrEmpty()]
[string]
$Id
$Id,
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
[ValidateNotNullOrEmpty()]
[PS.IPAM.Subnetwork]
$SubnetObject
)
process {
$_params = @{
Controller = "subnets"
Method = "GET"
Controller = [PS.IPAM.controllers]::subnets
Method = [PS.IPAM.methods]::GET
}
switch ($PSCmdlet.ParameterSetName) {
"ByID" { $_subnetId = $Id }
"ByID" { $_subnetId = $Id; break }
"ByCIDR" {
$_subnetId = (Get-Subnet -CIDR $CIDR).id
if (!$_subnetId) { throw "Cannot find subnet!" }
break
}
"BySubnetObject" { $_subnetId = $SubnetObject.Id; break }
}
$_identifiers = @($_subnetId,"first_free")
$_params.Add("Identifiers",$_identifiers)