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:
Ben Claussen 2021-03-30 10:58:08 -04:00
commit 5fc0a8e9fa
7 changed files with 168 additions and 155 deletions

View file

@ -13,7 +13,7 @@
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
@ -46,14 +46,15 @@ function Get-NetboxIPAMAvailableIP {
[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
) )
process {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips')) $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'
@ -61,4 +62,5 @@ function Get-NetboxIPAMAvailableIP {
$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
}
} }

View file

@ -13,7 +13,7 @@
function New-NetboxIPAMAddress { function New-NetboxIPAMAddress {
<# <#
.SYNOPSIS .SYNOPSIS
Create a new IP address to Netbox Create a new IP address to Netbox
@ -47,6 +47,9 @@ function New-NetboxIPAMAddress {
.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.
@ -71,25 +74,28 @@ function New-NetboxIPAMAddress {
[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
) )
process {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses')) $Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
$Method = 'POST' $Method = 'POST'
@ -111,6 +117,7 @@ function New-NetboxIPAMAddress {
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) { if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
} }
}
} }

View file

@ -12,7 +12,7 @@
#> #>
function Remove-NetboxIPAMAddress { function Remove-NetboxIPAMAddress {
<# <#
.SYNOPSIS .SYNOPSIS
Remove an IP address from Netbox Remove an IP address from Netbox
@ -38,7 +38,7 @@ function Remove-NetboxIPAMAddress {
( (
[Parameter(Mandatory = $true, [Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)] ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id, [int[]]$Id,
[switch]$Force [switch]$Force
) )

View file

@ -19,19 +19,19 @@ function Set-NetboxIPAMAddress {
( (
[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,
@ -42,6 +42,8 @@ function Set-NetboxIPAMAddress {
[string]$Description, [string]$Description,
[string]$Dns_name,
[switch]$Force [switch]$Force
) )
@ -71,7 +73,8 @@ function Set-NetboxIPAMAddress {
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"
} }
} }

View file

@ -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
View file

@ -0,0 +1 @@
theme: jekyll-theme-slate