Fixes, added session class
This commit is contained in:
@@ -3,29 +3,25 @@ function Get-Address {
|
||||
[OutputType([PS.IPAM.address])]
|
||||
param (
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByIP")]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="BySubnetId")]
|
||||
[ValidateScript({[ipaddress] $_})]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[ipaddress]
|
||||
$IP,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByHostName")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$HostName,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByTag")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$TagId,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetId")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$SubnetId,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetCIDR")]
|
||||
[ValidateScript({[ipaddress] $_.Split("/")[0] -and $_.Split("/")[1] -match "\d{1,2}"})]
|
||||
@@ -36,7 +32,7 @@ function Get-Address {
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::address
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
|
||||
@@ -7,9 +7,8 @@ function Get-FirstFreeIP {
|
||||
[string]
|
||||
$CIDR,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
@@ -19,7 +18,7 @@ function Get-FirstFreeIP {
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::subnets
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_subnetId = $Id; break }
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
function Get-L2Domain {
|
||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[OutputType([PS.IPAM.Domain])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[int]
|
||||
$Id
|
||||
@@ -11,16 +10,11 @@ function Get-L2Domain {
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::l2domains
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::Domain
|
||||
}
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" {
|
||||
$_identifiers = @($Id)
|
||||
}
|
||||
}
|
||||
|
||||
$_identifiers = @($Id)
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
Invoke-Request @_params
|
||||
|
||||
@@ -2,9 +2,8 @@ function Get-Nameserver {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id
|
||||
)
|
||||
process {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
function Get-Section {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[CmdletBinding(DefaultParameterSetName="NoParams")]
|
||||
[OutputType([PS.IPAM.Section])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByName")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
@@ -12,12 +12,10 @@ function Get-Section {
|
||||
$Name
|
||||
)
|
||||
process {
|
||||
[string[]]$visiblePropertiesList = @('Id','Name','Description')
|
||||
$visibleProperties = [System.Management.Automation.PSPropertySet]::new('DefaultDisplayPropertySet',$visiblePropertiesList)
|
||||
|
||||
$_params = @{
|
||||
Controller = "sections"
|
||||
Controller = [PS.IPAM.controllers]::sections
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::Section
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_identifiers = @($Id) }
|
||||
@@ -25,8 +23,7 @@ function Get-Section {
|
||||
}
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
Invoke-Request @_params | `
|
||||
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
|
||||
Invoke-Request @_params
|
||||
}
|
||||
}
|
||||
Export-ModuleMember Get-Section
|
||||
@@ -8,16 +8,14 @@ function Get-Subnet {
|
||||
[string]
|
||||
$CIDR,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySectionId")]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=2,ParameterSetName="ByVlanNumber")]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="ByVlanId")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$SectionId,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySectionName")]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=3,ParameterSetName="ByVlanNumber")]
|
||||
@@ -26,25 +24,21 @@ function Get-Subnet {
|
||||
[string]
|
||||
$SectionName,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVrfId")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$VrfId,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVlanId")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$VlanId,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByVlanNumber")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$VlanNumber,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=1,ParameterSetName="ByVlanNumber")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$VlanDomain,
|
||||
[int]
|
||||
$VlanDomainId,
|
||||
[parameter(Mandatory=$false,ParameterSetName="ByID")]
|
||||
[switch]
|
||||
$Slaves,
|
||||
@@ -55,7 +49,7 @@ function Get-Subnet {
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::subnets
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::Subnetwork
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
|
||||
@@ -3,9 +3,8 @@ function Get-Tag {
|
||||
[OutputType([PS.IPAM.Tag])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
@@ -19,7 +18,7 @@ function Get-Tag {
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::tag
|
||||
}
|
||||
$_identifiers = @("tags")
|
||||
|
||||
@@ -3,29 +3,30 @@ function Get-Vlan {
|
||||
[OutputType([PS.IPAM.Vlan])]
|
||||
param (
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByNumber")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Number,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByL2Domain")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$L2DomainId,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="BySubnetObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PS.IPAM.Subnetwork]
|
||||
$SubnetObject
|
||||
$SubnetObject,
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByDomainObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PS.IPAM.Domain]
|
||||
$DomainObject
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = [PS.IPAM.controllers]::vlan
|
||||
Method = [PS.IPAM.methods]::GET
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::Vlan
|
||||
}
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
@@ -46,6 +47,9 @@ function Get-Vlan {
|
||||
return $null
|
||||
}
|
||||
}
|
||||
"DomainObject" {
|
||||
Get-Vlan -L2DomainId $DomainObject.Id
|
||||
}
|
||||
}
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
function Get-Vrf {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
[OutputType([PS.IPAM.Vrf])]
|
||||
param (
|
||||
[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 = "vrf"
|
||||
Controller = [PS.IPAM.controllers]::vrf
|
||||
Method = "GET"
|
||||
Type = [PS.IPAM.types]::vrf
|
||||
}
|
||||
if ($Id) { $_identifiers = @($Id) }
|
||||
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
Invoke-Request @_params | Select-Object @{n="id";e={$_.vrfId}},* | Select-Object -ExcludeProperty vrfId | `
|
||||
Add-Member -MemberType MemberSet -Name PSStandardMembers -Value $visibleProperties -PassThru
|
||||
Invoke-Request @_params
|
||||
}
|
||||
}
|
||||
Export-ModuleMember -Function Get-Vrf
|
||||
@@ -7,9 +7,8 @@ function New-Address {
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of subnet address belongs to",
|
||||
Position=0)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$SubnetId,
|
||||
[parameter(
|
||||
Mandatory=$true,
|
||||
@@ -72,9 +71,8 @@ function New-Address {
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of subnet address belongs to",
|
||||
Position=7)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$TagId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
@@ -90,9 +88,8 @@ function New-Address {
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of PowerDNS PTR record",
|
||||
Position=7)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$PTRId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
@@ -117,9 +114,8 @@ function New-Address {
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of device address belongs to",
|
||||
Position=12)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$DeviceId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
@@ -137,7 +133,7 @@ function New-Address {
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = "addresses"
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = "POST"
|
||||
}
|
||||
|
||||
|
||||
@@ -29,25 +29,30 @@ function New-Session {
|
||||
"Authorization" = "Basic $_auth"
|
||||
}
|
||||
|
||||
$_response = Invoke-RestMethod -Method Post -Uri $_uri -Headers $_headers -ErrorAction SilentlyContinue
|
||||
$_response = Invoke-RestMethod -Method POST -Uri $_uri -Headers $_headers
|
||||
|
||||
if ($_response.success -ne $true) { return $_response.error }
|
||||
|
||||
$script:ipamAuthType = "Credentials"
|
||||
$script:ipamAuth = $true
|
||||
$script:ipamToken = $_response.data.token
|
||||
$script:ipamAppID = $AppID
|
||||
$script:ipamURL = $URL
|
||||
$script:ipamCredentials = $Credentials
|
||||
$script:ipamExpires = Get-Date $_response.data.expires
|
||||
$script:psipamSession = [PS.IPAM.Session]::new(
|
||||
[ps.ipam.authType]::credentials,
|
||||
$_response.data.token,
|
||||
$AppID,
|
||||
$URL,
|
||||
(Get-Date $_response.data.expires),
|
||||
$Credentials
|
||||
)
|
||||
break
|
||||
}
|
||||
"Token" {
|
||||
$script:ipamAuthType = "Token"
|
||||
$script:ipamAuth = $true
|
||||
$script:ipamToken = $Token
|
||||
$script:ipamAppID = $AppID
|
||||
$script:ipamURL = $URL
|
||||
$script:ipamExpires = "Never"
|
||||
$script:psipamSession = [PS.IPAM.Session]::new(
|
||||
[ps.ipam.authType]::token,
|
||||
$Token,
|
||||
$AppID,
|
||||
$URL,
|
||||
$null,
|
||||
$null
|
||||
)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,30 +2,23 @@ function Remove-Address {
|
||||
[CmdletBinding(DefaultParameterSetName="ByID")]
|
||||
param (
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByID")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0,ParameterSetName="ByIP")]
|
||||
[ValidateScript({[ipaddress] $_ })]
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$IP,
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,Position=1,ParameterSetName="ByIP")]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$SubnetId
|
||||
[PS.IPAM.Address]
|
||||
$AddressObject
|
||||
)
|
||||
process {
|
||||
$_params = @{
|
||||
Controller = "addresses"
|
||||
Controller = [PS.IPAM.controllers]::addresses
|
||||
Method = "DELETE"
|
||||
}
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_identifiers = @($Id) }
|
||||
"ByIP" { $_identifiers = @($IP,$SubnetId) }
|
||||
"ByID" { $_identifiers = @($Id);break }
|
||||
"ByAddressObject" { $_identifiers = @($AddressObject.Id);break }
|
||||
}
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
|
||||
@@ -1,127 +1,61 @@
|
||||
function Set-Address {
|
||||
[CmdletBinding()]
|
||||
[CmdletBinding(DefaultParameterSetName="ById")]
|
||||
param (
|
||||
[parameter(
|
||||
Mandatory=$true,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of subnet address belongs to",
|
||||
Position=0)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,HelpMessage="Id of subnet address belongs to",Position=0,ParameterSetName="ById")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$Id,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Defines if address is presented as gateway",
|
||||
Position=1)]
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true,Position=0,ParameterSetName="ByAddressObject")]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[PS.IPAM.Address]
|
||||
$AddressObject,
|
||||
[parameter(Mandatory=$false,HelpMessage="Defines if address is presented as gateway",Position=1)]
|
||||
[bool]
|
||||
$Gateway,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Address description",
|
||||
Position=2)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Address description",Position=2)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Description,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Address hostname",
|
||||
Position=3)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Address hostname",Position=3)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Hostname,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Mac address",
|
||||
Position=4)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Mac address",Position=4)]
|
||||
[ValidateScript({ $_.Replace(":","") -match "^$('([A-F0-9]{2})' * 6)$" })]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$MAC,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Address owner",
|
||||
Position=5)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Address owner",Position=5)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Owner,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of subnet address belongs to",
|
||||
Position=6)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[parameter(Mandatory=$false,HelpMessage="Id of subnet address belongs to",Position=6)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$TagId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Controls if PTR should not be created",
|
||||
Position=7)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Controls if PTR should not be created",Position=7)]
|
||||
[bool]
|
||||
$PTRIgnore,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of PowerDNS PTR record",
|
||||
Position=8)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[parameter(Mandatory=$false,HelpMessage="Id of PowerDNS PTR record",Position=8)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$PTRId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Note",
|
||||
Position=9)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Note",Position=9)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Note,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Exclude this address from status update scans (ping)",
|
||||
Position=10)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Exclude this address from status update scans (ping)",Position=10)]
|
||||
[bool]
|
||||
$ExcludePing,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Id of device address belongs to",
|
||||
Position=11)]
|
||||
[ValidateScript({ $_ -match "^\d+$" })]
|
||||
[parameter(Mandatory=$false,HelpMessage="Id of device address belongs to",Position=11)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
[int]
|
||||
$DeviceId,
|
||||
[parameter(
|
||||
Mandatory=$false,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
HelpMessage="Port",
|
||||
Position=12)]
|
||||
[parameter(Mandatory=$false,HelpMessage="Port",Position=12)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Port,
|
||||
|
||||
[parameter(Mandatory=$false,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
|
||||
[parameter(Mandatory=$false)]
|
||||
[ValidateScript({ $_ -is [Hashtable] -or $_ -is [PSCustomObject] })]
|
||||
$CustomFields
|
||||
)
|
||||
@@ -130,21 +64,25 @@ function Set-Address {
|
||||
Controller = "addresses"
|
||||
Method = "PATCH"
|
||||
}
|
||||
$_identifiers = @($Id)
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
"ByID" { $_id = $Id;break }
|
||||
"ByAddressObject" { $_id = $AddressObject.id;break }
|
||||
}
|
||||
$_identifiers = @($_id)
|
||||
|
||||
$_params.Add("Identifiers",$_identifiers)
|
||||
|
||||
$_body = @{ }
|
||||
if ($Gateway) { $_body.Add("is_gateway", [int]$Gateway) }
|
||||
if ($Gateway) { $_body.Add("is_gateway", $Gateway) }
|
||||
if ($Description) { $_body.Add("description", $Description) }
|
||||
if ($Hostname) { $_body.Add("hostname", $Hostname) }
|
||||
if ($MAC) { $_body.Add("mac", $MAC) }
|
||||
if ($Owner) { $_body.Add("owner", $Owner) }
|
||||
if ($TagId) { $_body.Add("tag", $TagId) }
|
||||
if ($PTRIgnore) { $_body.Add("PTRignore", [int]$PTRIgnore) }
|
||||
if ($PTRIgnore) { $_body.Add("PTRignore", $PTRIgnore) }
|
||||
if ($PTRId) { $_body.add("PTR", $PTRId)}
|
||||
if ($Note) { $_body.Add("note", $Note) }
|
||||
if ($ExcludePing) { $_body.Add("excludePing", [int]$ExcludePing) }
|
||||
if ($ExcludePing) { $_body.Add("excludePing", $ExcludePing) }
|
||||
if ($DeviceId) { $_body.Add("deviceId", $DeviceId) }
|
||||
if ($Port) { $_body.Add("port", $Port) }
|
||||
|
||||
@@ -165,7 +103,7 @@ function Set-Address {
|
||||
Invoke-Request @_params
|
||||
}
|
||||
finally {
|
||||
Get-Address -Id $Id
|
||||
Get-Address -Id $_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user