first working types
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
function Get-Address {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[OutputType({[types]::address})]
|
||||
[OutputType([PS.IPAM.address])]
|
||||
param (
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
@@ -35,29 +35,29 @@ function Get-Address {
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [controllers]::addresses
|
||||
Method = [methods]::GET
|
||||
Type = [types]::address
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Type = [PS.IPAM.types]::address
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_identifiers = @($id) }
|
||||
"ByIP" { $_identifiers = ("search",$IP) }
|
||||
"ByHostName" { $_identifiers = ("search_hostname",$HostName) }
|
||||
"ByTag" { $_identifiers = ("tags",$TagId,[controllers]::addresses) }
|
||||
"ByTag" { $_identifiers = ("tags",$TagId,[PS.IPAM.controllers]::addresses) }
|
||||
"BySubnetId" {
|
||||
if ($IP) {
|
||||
$_identifiers = ($IP,$SubnetId)
|
||||
} else {
|
||||
$_params.Item("Controller") = [controllers]::subnets
|
||||
$_identifiers = ($SubnetId,[controllers]::addresses)
|
||||
$_params.Item("Controller") = [PS.IPAM.controllers]::subnets
|
||||
$_identifiers = ($SubnetId,[PS.IPAM.controllers]::addresses)
|
||||
}
|
||||
}
|
||||
"BySubnetCIDR" {
|
||||
$_params.Item("Controller") = [controllers]::subnets
|
||||
$_params.Item("Controller") = [PS.IPAM.controllers]::subnets
|
||||
$_subnetId = (Get-Subnet -CIDR $SubnetCIDR).id
|
||||
if (!$_subnetId) { throw "Cannot find subnet!" }
|
||||
|
||||
$_identifiers = ($_subnetId,[controllers]::addresses)
|
||||
$_identifiers = ($_subnetId,[PS.IPAM.controllers]::addresses)
|
||||
}
|
||||
}
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
function Get-L2Domain {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||
[OutputType([PS.IPAM.Domain])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0)]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id
|
||||
)
|
||||
process {
|
||||
[string[]]$visiblePropertiesList = @('Id','Name','Description')
|
||||
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
|
||||
|
||||
$_params = @{
|
||||
Controller = "l2domains"
|
||||
Method = "GET"
|
||||
Controller = [PS.IPAM.controllers]::l2domains
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Type = [PS.IPAM.types]::Domain
|
||||
}
|
||||
$_identifiers = @($Id)
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" {
|
||||
$_identifiers = @($Id)
|
||||
}
|
||||
}
|
||||
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
Invoke-Request @_params | `
|
||||
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
|
||||
Invoke-Request @_params
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function Get-L2Domain
|
||||
@@ -1,5 +1,6 @@
|
||||
function Get-Subnet {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||
[OutputType([PS.IPAM.Subnetwork])]
|
||||
param (
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByCIDR")]
|
||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||
@@ -52,13 +53,10 @@ function Get-Subnet {
|
||||
$Recurse
|
||||
)
|
||||
process {
|
||||
[string[]]$visiblePropertiesList = @('Id','Subnet','Mask','Description')
|
||||
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
|
||||
|
||||
$_params = @{
|
||||
Controller = "subnets"
|
||||
Method = "GET"
|
||||
Type = "subnet"
|
||||
Controller = [PS.IPAM.controllers]::subnets
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Type = [PS.IPAM.types]::Subnetwork
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByCIDR" {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
function Get-Tag {
|
||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||
[OutputType({[types]::tag})]
|
||||
[OutputType([PS.IPAM.Tag])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
@@ -18,16 +18,24 @@ function Get-Tag {
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [controllers]::addresses
|
||||
Method = [methods]::GET
|
||||
Type = [types]::tag
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Type = [PS.IPAM.types]::tag
|
||||
}
|
||||
$_identifiers = @("tags")
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_identifiers += $Id }
|
||||
"ByID" { $_identifiers += $Id; break }
|
||||
"ByAddressObject" {
|
||||
if ($InputObject.TagId) {
|
||||
$_identifiers += $InputObject.TagId
|
||||
if ($AddressObject.TagId) {
|
||||
$_identifiers += $AddressObject.TagId
|
||||
} else {
|
||||
return $null
|
||||
}
|
||||
break
|
||||
}
|
||||
"BySubnetObject" {
|
||||
if ($SubnetObject.TagId) {
|
||||
$_identifiers += $SubnetObject.TagId
|
||||
} else {
|
||||
return $null
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
function Get-Vlan {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[OutputType([PS.IPAM.Vlan])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
@@ -15,31 +16,40 @@ function Get-Vlan {
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$L2DomainId
|
||||
$L2DomainId,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PS.IPAM.Subnetwork]
|
||||
$SubnetObject
|
||||
)
|
||||
process {
|
||||
[string[]]$visiblePropertiesList = @('Id','Name','Description')
|
||||
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
|
||||
|
||||
$_params = @{
|
||||
Controller = "vlan"
|
||||
Method = "GET"
|
||||
Controller = [PS.IPAM.controllers]::vlan
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Type = [PS.IPAM.types]::Vlan
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_identifiers = @($Id) }
|
||||
"ByNumber" { $_identifiers = @("search",$Number) }
|
||||
"ByID" { $_identifiers = @($Id); break }
|
||||
"ByNumber" { $_identifiers = @("search",$Number); break }
|
||||
"ByL2Domain"{
|
||||
$_params.Item("Controller") = "l2domains"
|
||||
$_params.Item("Controller") = [PS.IPAM.controllers]::l2domains
|
||||
|
||||
$_l2domainId = $L2DomainId
|
||||
|
||||
$_identifiers = @($_l2domainId,"vlans")
|
||||
$_identifiers = @($_l2domainId,[PS.IPAM.subcontrollers]::vlans)
|
||||
break
|
||||
}
|
||||
"BySubnetObject" {
|
||||
if ($SubnetObject.VlanId) {
|
||||
$_identifiers = @($SubnetObject.VlanId); break
|
||||
} else {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
}
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
Invoke-Request @_params | Select-Object @{n="id";e={$_.vlanId}},* | Select-Object -ExcludeProperty vlanId | `
|
||||
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
|
||||
Invoke-Request @_params
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function Get-Vlan
|
||||
Reference in New Issue
Block a user