mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
Merge branch 'master' into dev
# Conflicts: # Functions/IPAM/Address/Get-NetboxIPAMAddress.ps1 # Functions/IPAM/Address/New-NetboxIPAMAddress.ps1 # Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1 # Functions/IPAM/Address/Set-NetboxIPAMAddress.ps1
This commit is contained in:
commit
5fc0a8e9fa
7 changed files with 168 additions and 155 deletions
|
|
@ -3,90 +3,90 @@
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint32[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Family,
|
[object]$Family,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Parent,
|
[uint32]$Parent,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[byte]$Mask_Length,
|
[byte]$Mask_Length,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$VRF,
|
[string]$VRF,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$VRF_Id,
|
[uint32]$VRF_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Tenant,
|
[string]$Tenant,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Tenant_Id,
|
[uint32]$Tenant_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Device,
|
[string]$Device,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Device_ID,
|
[uint32]$Device_ID,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Virtual_Machine,
|
[string]$Virtual_Machine,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Virtual_Machine_Id,
|
[uint32]$Virtual_Machine_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Interface_Id,
|
[uint32]$Interface_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Status,
|
[object]$Status,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Limit,
|
[uint16]$Limit,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$Offset,
|
[uint16]$Offset,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($IP_ID in $Id) {
|
foreach ($IP_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IP_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IP_ID))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id'
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
default {
|
default {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
|
@ -13,52 +13,54 @@
|
||||||
|
|
||||||
|
|
||||||
function Get-NetboxIPAMAvailableIP {
|
function Get-NetboxIPAMAvailableIP {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
A convenience method for returning available IP addresses within a prefix
|
A convenience method for returning available IP addresses within a prefix
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
By default, the number of IPs returned will be equivalent to PAGINATE_COUNT. An arbitrary limit
|
By default, the number of IPs returned will be equivalent to PAGINATE_COUNT. An arbitrary limit
|
||||||
(up to MAX_PAGE_SIZE, if set) may be passed, however results will not be paginated
|
(up to MAX_PAGE_SIZE, if set) may be passed, however results will not be paginated
|
||||||
|
|
||||||
.PARAMETER Prefix_ID
|
.PARAMETER Prefix_ID
|
||||||
A description of the Prefix_ID parameter.
|
A description of the Prefix_ID parameter.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
A description of the Limit parameter.
|
A description of the Limit parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.PARAMETER NumberOfIPs
|
.PARAMETER NumberOfIPs
|
||||||
A description of the NumberOfIPs parameter.
|
A description of the NumberOfIPs parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
PS C:\> Get-NetboxIPAMAvaiableIP -Prefix_ID $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[Alias('Id')]
|
[Alias('Id')]
|
||||||
[uint16]$Prefix_ID,
|
[int]$Prefix_ID,
|
||||||
|
|
||||||
[Alias('NumberOfIPs')]
|
[Alias('NumberOfIPs')]
|
||||||
[uint16]$Limit,
|
[int]$Limit,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
|
process {
|
||||||
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
|
||||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
|
||||||
|
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
|
||||||
|
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
|
@ -13,103 +13,110 @@
|
||||||
|
|
||||||
|
|
||||||
function New-NetboxIPAMAddress {
|
function New-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new IP address to Netbox
|
Create a new IP address to Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Create a new IP address to Netbox with a status of Active by default.
|
Create a new IP address to Netbox with a status of Active by default.
|
||||||
|
|
||||||
.PARAMETER Address
|
.PARAMETER Address
|
||||||
IP address in CIDR notation: 192.168.1.1/24
|
IP address in CIDR notation: 192.168.1.1/24
|
||||||
|
|
||||||
.PARAMETER Status
|
.PARAMETER Status
|
||||||
Status of the IP. Defaults to Active
|
Status of the IP. Defaults to Active
|
||||||
|
|
||||||
.PARAMETER Tenant
|
.PARAMETER Tenant
|
||||||
Tenant ID
|
Tenant ID
|
||||||
|
|
||||||
.PARAMETER VRF
|
.PARAMETER VRF
|
||||||
VRF ID
|
VRF ID
|
||||||
|
|
||||||
.PARAMETER Role
|
.PARAMETER Role
|
||||||
Role such as anycast, loopback, etc... Defaults to nothing
|
Role such as anycast, loopback, etc... Defaults to nothing
|
||||||
|
|
||||||
.PARAMETER NAT_Inside
|
.PARAMETER NAT_Inside
|
||||||
ID of IP for NAT
|
ID of IP for NAT
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
Custom field hash table. Will be validated by the API service
|
Custom field hash table. Will be validated by the API service
|
||||||
|
|
||||||
.PARAMETER Interface
|
.PARAMETER Interface
|
||||||
ID of interface to apply IP
|
ID of interface to apply IP
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Description of IP address
|
Description of IP address
|
||||||
|
|
||||||
|
.PARAMETER Dns_name
|
||||||
|
DNS Name of IP address (example : netbox.example.com)
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Do not prompt for confirmation to create IP.
|
Do not prompt for confirmation to create IP.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return raw results from API service
|
Return raw results from API service
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Create-NetboxIPAMAddress
|
PS C:\> Create-NetboxIPAMAddress
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'Low',
|
[CmdletBinding(ConfirmImpact = 'Low',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
[OutputType([pscustomobject])]
|
[OutputType([pscustomobject])]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[object]$Status = 'Active',
|
[object]$Status = 'Active',
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[int]$Tenant,
|
||||||
|
|
||||||
[uint16]$VRF,
|
[int]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint16]$NAT_Inside,
|
[int]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[uint16]$Interface,
|
[int]$Interface,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Dns_name,
|
||||||
|
|
||||||
[switch]$Force,
|
[switch]$Force,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
process {
|
||||||
$Method = 'POST'
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
||||||
|
$Method = 'POST'
|
||||||
# # Value validation
|
|
||||||
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
# # Value validation
|
||||||
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
#
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
# foreach ($Property in $EnumProperties.Keys) {
|
#
|
||||||
# if ($PSBoundParameters.ContainsKey($Property)) {
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
# }
|
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
||||||
# }
|
# }
|
||||||
#
|
# }
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
#
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
|
@ -12,46 +12,46 @@
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function Remove-NetboxIPAMAddress {
|
function Remove-NetboxIPAMAddress {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Remove an IP address from Netbox
|
Remove an IP address from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Removes/deletes an IP address from Netbox by ID and optional other filters
|
Removes/deletes an IP address from Netbox by ID and optional other filters
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
Database ID of the IP address object.
|
Database ID of the IP address object.
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Do not confirm.
|
Do not confirm.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Remove-NetboxIPAMAddress -Id $value1
|
PS C:\> Remove-NetboxIPAMAddress -Id $value1
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(ConfirmImpact = 'High',
|
[CmdletBinding(ConfirmImpact = 'High',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[int[]]$Id,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($IPId in $Id) {
|
foreach ($IPId in $Id) {
|
||||||
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
||||||
|
|
||||||
if ($Force -or $pscmdlet.ShouldProcess($CurrentIP.Address, "Delete")) {
|
if ($Force -or $pscmdlet.ShouldProcess($CurrentIP.Address, "Delete")) {
|
||||||
$URI = BuildNewURI -Segments $Segments
|
$URI = BuildNewURI -Segments $Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Method DELETE
|
InvokeNetboxRequest -URI $URI -Method DELETE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
||||||
|
|
@ -14,46 +14,48 @@
|
||||||
|
|
||||||
function Set-NetboxIPAMAddress {
|
function Set-NetboxIPAMAddress {
|
||||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||||
SupportsShouldProcess = $true)]
|
SupportsShouldProcess = $true)]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint16[]]$Id,
|
[int[]]$Id,
|
||||||
|
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[string]$Status,
|
[string]$Status,
|
||||||
|
|
||||||
[uint16]$Tenant,
|
[int]$Tenant,
|
||||||
|
|
||||||
[uint16]$VRF,
|
[int]$VRF,
|
||||||
|
|
||||||
[object]$Role,
|
[object]$Role,
|
||||||
|
|
||||||
[uint16]$NAT_Inside,
|
[int]$NAT_Inside,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
[ValidateSet('dcim.interface', 'virtualization.vminterface', IgnoreCase = $true)]
|
||||||
[string]$Assigned_Object_Type,
|
[string]$Assigned_Object_Type,
|
||||||
|
|
||||||
[uint16]$Assigned_Object_Id,
|
[uint16]$Assigned_Object_Id,
|
||||||
|
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
|
[string]$Dns_name,
|
||||||
|
|
||||||
[switch]$Force
|
[switch]$Force
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# Write-Verbose "Validating enum properties"
|
# Write-Verbose "Validating enum properties"
|
||||||
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
# $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', 0))
|
||||||
$Method = 'PATCH'
|
$Method = 'PATCH'
|
||||||
#
|
#
|
||||||
# # Value validation
|
# # Value validation
|
||||||
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
||||||
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
||||||
#
|
#
|
||||||
# foreach ($Property in $EnumProperties.Keys) {
|
# foreach ($Property in $EnumProperties.Keys) {
|
||||||
# if ($PSBoundParameters.ContainsKey($Property)) {
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
||||||
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
||||||
|
|
@ -62,30 +64,31 @@ function Set-NetboxIPAMAddress {
|
||||||
# Write-Verbose "User did not provide a value for [$Property]"
|
# Write-Verbose "User did not provide a value for [$Property]"
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# Write-Verbose "Finished enum validation"
|
# Write-Verbose "Finished enum validation"
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($IPId in $Id) {
|
foreach ($IPId in $Id) {
|
||||||
if ($PSBoundParameters.ContainsKey('Assigned_Object_Type') -or $PSBoundParameters.ContainsKey('Assigned_Object_Id')) {
|
if ($PSBoundParameters.ContainsKey('Assigned_Object_Type') -or $PSBoundParameters.ContainsKey('Assigned_Object_Id')) {
|
||||||
if ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) {
|
if ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) {
|
||||||
throw "Assigned_Object_Type is required when specifying Assigned_Object_Id"
|
throw "Assigned_Object_Type is required when specifying Assigned_Object_Id"
|
||||||
} elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) {
|
}
|
||||||
|
elseif ((-not [string]::IsNullOrWhiteSpace($Assigned_Object_Type)) -and [string]::IsNullOrWhiteSpace($Assigned_Object_Id)) {
|
||||||
throw "Assigned_Object_Id is required when specifying Assigned_Object_Type"
|
throw "Assigned_Object_Id is required when specifying Assigned_Object_Type"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
|
||||||
|
|
||||||
Write-Verbose "Obtaining IP from ID $IPId"
|
Write-Verbose "Obtaining IP from ID $IPId"
|
||||||
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentIP.Address, 'Set')) {
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
This module is beta. Use it at your own risk. I have only added functions as I have needed them, so not everything is available.
|
This module is beta. Use it at your own risk. I have only added functions as I have needed them, so not everything is available.
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
This module is a wrapper for the [Netbox](https://github.com/digitalocean/netbox) API.
|
This module is a wrapper for the [Netbox](https://github.com/netbox-community/netbox) API.
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
1. Install module from the `dist` folder
|
1. Install module from the `netboxPS` folder
|
||||||
2. Import module
|
2. Import module
|
||||||
3. Connect to an API endpoint by using `Connect-NetboxAPI`
|
3. Connect to an API endpoint by using `Connect-NetboxAPI -Hostname netbox.example.com`
|
||||||
1
_config.yml
Normal file
1
_config.yml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
theme: jekyll-theme-slate
|
||||||
Loading…
Add table
Reference in a new issue