mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
Remove whitespace
This commit is contained in:
parent
d09e20baee
commit
ddf0a081b4
11 changed files with 253 additions and 253 deletions
|
|
@ -61,7 +61,7 @@ function Get-NetboxIPAMVLAN {
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
switch ($PSCmdlet.ParameterSetName) {
|
switch ($PSCmdlet.ParameterSetName) {
|
||||||
'ById' {
|
'ById' {
|
||||||
foreach ($VLAN_ID in $Id) {
|
foreach ($VLAN_ID in $Id) {
|
||||||
|
|
|
||||||
|
|
@ -144,10 +144,10 @@
|
||||||
} else {
|
} else {
|
||||||
Write-Verbose "Found compatible version [$($script:NetboxConfig.NetboxVersion.'netbox-version')]!"
|
Write-Verbose "Found compatible version [$($script:NetboxConfig.NetboxVersion.'netbox-version')]!"
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:NetboxConfig.Connected = $true
|
$script:NetboxConfig.Connected = $true
|
||||||
Write-Verbose "Successfully connected!"
|
Write-Verbose "Successfully connected!"
|
||||||
|
|
||||||
$script:NetboxConfig.ContentTypes = Get-NetboxContentType -Limit 500
|
$script:NetboxConfig.ContentTypes = Get-NetboxContentType -Limit 500
|
||||||
|
|
||||||
Write-Verbose "Connection process completed"
|
Write-Verbose "Connection process completed"
|
||||||
|
|
|
||||||
|
|
@ -1,88 +1,88 @@
|
||||||
function Get-NetboxContentType {
|
function Get-NetboxContentType {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get a content type definition from Netbox
|
Get a content type definition from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxContentType function.
|
A detailed description of the Get-NetboxContentType function.
|
||||||
|
|
||||||
.PARAMETER Model
|
.PARAMETER Model
|
||||||
A description of the Model parameter.
|
A description of the Model parameter.
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
The database ID of the contact role
|
The database ID of the contact role
|
||||||
|
|
||||||
.PARAMETER App_Label
|
.PARAMETER App_Label
|
||||||
A description of the App_Label parameter.
|
A description of the App_Label parameter.
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A standard search query that will match one or more contact roles.
|
A standard search query that will match one or more contact roles.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Limit the number of results to this number
|
Limit the number of results to this number
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Start the search at this index in results
|
Start the search at this index in results
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxContentType
|
PS C:\> Get-NetboxContentType
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Model,
|
[string]$Model,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint32[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$App_Label,
|
[string]$App_Label,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Query,
|
[string]$Query,
|
||||||
|
|
||||||
[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 ($ContentType_ID in $Id) {
|
foreach ($ContentType_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types', $ContentType_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types', $ContentType_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(@('extras', 'content-types'))
|
$Segments = [System.Collections.ArrayList]::new(@('extras', 'content-types'))
|
||||||
|
|
||||||
$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,107 +1,107 @@
|
||||||
|
|
||||||
function Get-NetboxContactAssignment {
|
function Get-NetboxContactAssignment {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get a contact Assignment from Netbox
|
Get a contact Assignment from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxContactAssignment function.
|
A detailed description of the Get-NetboxContactAssignment function.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The specific name of the contact Assignment. Must match exactly as is defined in Netbox
|
The specific name of the contact Assignment. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
The database ID of the contact Assignment
|
The database ID of the contact Assignment
|
||||||
|
|
||||||
.PARAMETER Content_Type_Id
|
.PARAMETER Content_Type_Id
|
||||||
A description of the Content_Type_Id parameter.
|
A description of the Content_Type_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Content_Type
|
.PARAMETER Content_Type
|
||||||
A description of the Content_Type parameter.
|
A description of the Content_Type parameter.
|
||||||
|
|
||||||
.PARAMETER Object_Id
|
.PARAMETER Object_Id
|
||||||
A description of the Object_Id parameter.
|
A description of the Object_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Contact_Id
|
.PARAMETER Contact_Id
|
||||||
A description of the Contact_Id parameter.
|
A description of the Contact_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Role_Id
|
.PARAMETER Role_Id
|
||||||
A description of the Role_Id parameter.
|
A description of the Role_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Limit the number of results to this number
|
Limit the number of results to this number
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Start the search at this index in results
|
Start the search at this index in results
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxContactAssignment
|
PS C:\> Get-NetboxContactAssignment
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'ByID')]
|
[Parameter(ParameterSetName = 'ByID')]
|
||||||
[uint32[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Content_Type_Id,
|
[uint32]$Content_Type_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Content_Type,
|
[string]$Content_Type,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Object_Id,
|
[uint32]$Object_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Contact_Id,
|
[uint32]$Contact_Id,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint32]$Role_Id,
|
[uint32]$Role_Id,
|
||||||
|
|
||||||
[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 ($ContactAssignment_ID in $Id) {
|
foreach ($ContactAssignment_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignment_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignment_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(@('tenancy', 'contact-assignments'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments'))
|
||||||
|
|
||||||
$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,37 +1,37 @@
|
||||||
|
|
||||||
function New-NetboxContactRole {
|
function New-NetboxContactRole {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new contact role in Netbox
|
Create a new contact role in Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new contact role object in Netbox
|
Creates a new contact role object in Netbox
|
||||||
|
|
||||||
.PARAMETER Content_Type
|
.PARAMETER Content_Type
|
||||||
A description of the Content_Type parameter.
|
A description of the Content_Type parameter.
|
||||||
|
|
||||||
.PARAMETER Object_Id
|
.PARAMETER Object_Id
|
||||||
A description of the Object_Id parameter.
|
A description of the Object_Id parameter.
|
||||||
|
|
||||||
.PARAMETER Contact
|
.PARAMETER Contact
|
||||||
A description of the Contact parameter.
|
A description of the Contact parameter.
|
||||||
|
|
||||||
.PARAMETER Role
|
.PARAMETER Role
|
||||||
A description of the Role parameter.
|
A description of the Role parameter.
|
||||||
|
|
||||||
.PARAMETER Priority
|
.PARAMETER Priority
|
||||||
A description of the Priority parameter.
|
A description of the Priority parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> New-NetboxContactAssignment -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
PS C:\> New-NetboxContactAssignment -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
.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])]
|
||||||
|
|
@ -40,22 +40,22 @@ function New-NetboxContactRole {
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[object]$Content_Type,
|
[object]$Content_Type,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint32]$Object_Id,
|
[uint32]$Object_Id,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint32]$Contact,
|
[uint32]$Contact,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[uint32]$Role,
|
[uint32]$Role,
|
||||||
|
|
||||||
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)]
|
||||||
[string]$Priority,
|
[string]$Priority,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
# https://docs.netbox.dev/en/stable/features/contacts/
|
# https://docs.netbox.dev/en/stable/features/contacts/
|
||||||
$AllowedContentTypes = @{
|
$AllowedContentTypes = @{
|
||||||
|
|
@ -75,11 +75,11 @@ function New-NetboxContactRole {
|
||||||
61 = "virtualization.virtualmachine"
|
61 = "virtualization.virtualmachine"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignment'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignment'))
|
||||||
$Method = 'POST'
|
$Method = 'POST'
|
||||||
|
|
||||||
if ($Content_Type -is [string]) {
|
if ($Content_Type -is [string]) {
|
||||||
# Need to convert this to an integer
|
# Need to convert this to an integer
|
||||||
$Content_Type = ($AllowedContentTypes.GetEnumerator() | Where-Object {
|
$Content_Type = ($AllowedContentTypes.GetEnumerator() | Where-Object {
|
||||||
|
|
@ -92,11 +92,11 @@ function New-NetboxContactRole {
|
||||||
} else {
|
} else {
|
||||||
throw "Invalid content type defined"
|
throw "Invalid content type defined"
|
||||||
}
|
}
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact assignment')) {
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact assignment')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,89 @@
|
||||||
|
|
||||||
function Get-NetboxContactRole {
|
function Get-NetboxContactRole {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get a contact role from Netbox
|
Get a contact role from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A detailed description of the Get-NetboxContactRole function.
|
A detailed description of the Get-NetboxContactRole function.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The specific name of the contact role. Must match exactly as is defined in Netbox
|
The specific name of the contact role. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
The database ID of the contact role
|
The database ID of the contact role
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A standard search query that will match one or more contact roles.
|
A standard search query that will match one or more contact roles.
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Limit the number of results to this number
|
Limit the number of results to this number
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Start the search at this index in results
|
Start the search at this index in results
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxContactRole
|
PS C:\> Get-NetboxContactRole
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[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')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[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 ($ContactRole_ID in $Id) {
|
foreach ($ContactRole_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles', $ContactRole_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles', $ContactRole_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(@('tenancy', 'contact-roles'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-roles'))
|
||||||
|
|
||||||
$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,34 +1,34 @@
|
||||||
|
|
||||||
function New-NetboxContactRole {
|
function New-NetboxContactRole {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new contact role in Netbox
|
Create a new contact role in Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new contact role object in Netbox
|
Creates a new contact role object in Netbox
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The contact role name, e.g "Network Support"
|
The contact role name, e.g "Network Support"
|
||||||
|
|
||||||
.PARAMETER Slug
|
.PARAMETER Slug
|
||||||
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Short description of the contact role
|
Short description of the contact role
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
A description of the Custom_Fields parameter.
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
.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])]
|
||||||
|
|
@ -38,28 +38,28 @@ function New-NetboxContactRole {
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
$Method = 'POST'
|
$Method = 'POST'
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact')) {
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,119 +1,119 @@
|
||||||
|
|
||||||
function Get-NetboxContact {
|
function Get-NetboxContact {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Get a contact from Netbox
|
Get a contact from Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Obtain a contact or contacts from Netbox by ID or query
|
Obtain a contact or contacts from Netbox by ID or query
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The specific name of the Contact. Must match exactly as is defined in Netbox
|
The specific name of the Contact. Must match exactly as is defined in Netbox
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
The database ID of the Contact
|
The database ID of the Contact
|
||||||
|
|
||||||
.PARAMETER Query
|
.PARAMETER Query
|
||||||
A standard search query that will match one or more Contacts.
|
A standard search query that will match one or more Contacts.
|
||||||
|
|
||||||
.PARAMETER Email
|
.PARAMETER Email
|
||||||
Email address of the contact
|
Email address of the contact
|
||||||
|
|
||||||
.PARAMETER Title
|
.PARAMETER Title
|
||||||
Title of the contact
|
Title of the contact
|
||||||
|
|
||||||
.PARAMETER Phone
|
.PARAMETER Phone
|
||||||
Telephone number of the contact
|
Telephone number of the contact
|
||||||
|
|
||||||
.PARAMETER Address
|
.PARAMETER Address
|
||||||
Physical address of the contact
|
Physical address of the contact
|
||||||
|
|
||||||
.PARAMETER Group
|
.PARAMETER Group
|
||||||
The specific group as defined in Netbox.
|
The specific group as defined in Netbox.
|
||||||
|
|
||||||
.PARAMETER GroupID
|
.PARAMETER GroupID
|
||||||
The database ID of the group in Netbox
|
The database ID of the group in Netbox
|
||||||
|
|
||||||
.PARAMETER Limit
|
.PARAMETER Limit
|
||||||
Limit the number of results to this number
|
Limit the number of results to this number
|
||||||
|
|
||||||
.PARAMETER Offset
|
.PARAMETER Offset
|
||||||
Start the search at this index in results
|
Start the search at this index in results
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Get-NetboxContact
|
PS C:\> Get-NetboxContact
|
||||||
|
|
||||||
.NOTES
|
.NOTES
|
||||||
Additional information about the function.
|
Additional information about the function.
|
||||||
#>
|
#>
|
||||||
|
|
||||||
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
[CmdletBinding(DefaultParameterSetName = 'Query')]
|
||||||
param
|
param
|
||||||
(
|
(
|
||||||
[Parameter(ParameterSetName = 'Query',
|
[Parameter(ParameterSetName = 'Query',
|
||||||
Position = 0)]
|
Position = 0)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[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')]
|
||||||
[string]$Email,
|
[string]$Email,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Title,
|
[string]$Title,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Phone,
|
[string]$Phone,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[string]$Group,
|
[string]$Group,
|
||||||
|
|
||||||
[Parameter(ParameterSetName = 'Query')]
|
[Parameter(ParameterSetName = 'Query')]
|
||||||
[uint16]$GroupID,
|
[uint16]$GroupID,
|
||||||
|
|
||||||
[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 ($Contact_ID in $Id) {
|
foreach ($Contact_ID in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $Contact_ID))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $Contact_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(@('tenancy', 'contacts'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
|
|
||||||
$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,49 +1,49 @@
|
||||||
|
|
||||||
function New-NetboxContact {
|
function New-NetboxContact {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new contact in Netbox
|
Create a new contact in Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new contact object in Netbox which can be linked to other objects
|
Creates a new contact object in Netbox which can be linked to other objects
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The contacts full name, e.g "Leroy Jenkins"
|
The contacts full name, e.g "Leroy Jenkins"
|
||||||
|
|
||||||
.PARAMETER Email
|
.PARAMETER Email
|
||||||
Email address of the contact
|
Email address of the contact
|
||||||
|
|
||||||
.PARAMETER Title
|
.PARAMETER Title
|
||||||
Job title or other title related to the contact
|
Job title or other title related to the contact
|
||||||
|
|
||||||
.PARAMETER Phone
|
.PARAMETER Phone
|
||||||
Telephone number
|
Telephone number
|
||||||
|
|
||||||
.PARAMETER Address
|
.PARAMETER Address
|
||||||
Physical address, usually mailing address
|
Physical address, usually mailing address
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Short description of the contact
|
Short description of the contact
|
||||||
|
|
||||||
.PARAMETER Comments
|
.PARAMETER Comments
|
||||||
Detailed comments. Markdown supported.
|
Detailed comments. Markdown supported.
|
||||||
|
|
||||||
.PARAMETER Link
|
.PARAMETER Link
|
||||||
URI related to the contact
|
URI related to the contact
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
A description of the Custom_Fields parameter.
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
.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])]
|
||||||
|
|
@ -53,41 +53,41 @@ function New-NetboxContact {
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateLength(0, 254)]
|
[ValidateLength(0, 254)]
|
||||||
[string]$Email,
|
[string]$Email,
|
||||||
|
|
||||||
[ValidateLength(0, 100)]
|
[ValidateLength(0, 100)]
|
||||||
[string]$Title,
|
[string]$Title,
|
||||||
|
|
||||||
[ValidateLength(0, 50)]
|
[ValidateLength(0, 50)]
|
||||||
[string]$Phone,
|
[string]$Phone,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Link,
|
[string]$Link,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
|
||||||
$Method = 'POST'
|
$Method = 'POST'
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact')) {
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new contact')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
|
|
||||||
function Set-NetboxContact {
|
function Set-NetboxContact {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Update a contact in Netbox
|
Update a contact in Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Updates a contact object in Netbox which can be linked to other objects
|
Updates a contact object in Netbox which can be linked to other objects
|
||||||
|
|
||||||
.PARAMETER Id
|
.PARAMETER Id
|
||||||
A description of the Id parameter.
|
A description of the Id parameter.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The contacts full name, e.g "Leroy Jenkins"
|
The contacts full name, e.g "Leroy Jenkins"
|
||||||
|
|
||||||
.PARAMETER Email
|
.PARAMETER Email
|
||||||
Email address of the contact
|
Email address of the contact
|
||||||
|
|
||||||
.PARAMETER Group
|
.PARAMETER Group
|
||||||
Database ID of assigned group
|
Database ID of assigned group
|
||||||
|
|
||||||
.PARAMETER Title
|
.PARAMETER Title
|
||||||
Job title or other title related to the contact
|
Job title or other title related to the contact
|
||||||
|
|
||||||
.PARAMETER Phone
|
.PARAMETER Phone
|
||||||
Telephone number
|
Telephone number
|
||||||
|
|
||||||
.PARAMETER Address
|
.PARAMETER Address
|
||||||
Physical address, usually mailing address
|
Physical address, usually mailing address
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Short description of the contact
|
Short description of the contact
|
||||||
|
|
||||||
.PARAMETER Comments
|
.PARAMETER Comments
|
||||||
Detailed comments. Markdown supported.
|
Detailed comments. Markdown supported.
|
||||||
|
|
||||||
.PARAMETER Link
|
.PARAMETER Link
|
||||||
URI related to the contact
|
URI related to the contact
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
A description of the Custom_Fields parameter.
|
A description of the Custom_Fields parameter.
|
||||||
|
|
||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
A description of the Force parameter.
|
A description of the Force parameter.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
A description of the Raw parameter.
|
A description of the Raw parameter.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> Set-NetboxContact -Id 10 -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
PS C:\> Set-NetboxContact -Id 10 -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
|
||||||
|
|
||||||
.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])]
|
||||||
|
|
@ -61,53 +61,53 @@ function Set-NetboxContact {
|
||||||
[Parameter(Mandatory = $true,
|
[Parameter(Mandatory = $true,
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[uint32[]]$Id,
|
[uint32[]]$Id,
|
||||||
|
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[ValidateLength(0, 254)]
|
[ValidateLength(0, 254)]
|
||||||
[string]$Email,
|
[string]$Email,
|
||||||
|
|
||||||
[uint32]$Group,
|
[uint32]$Group,
|
||||||
|
|
||||||
[ValidateLength(0, 100)]
|
[ValidateLength(0, 100)]
|
||||||
[string]$Title,
|
[string]$Title,
|
||||||
|
|
||||||
[ValidateLength(0, 50)]
|
[ValidateLength(0, 50)]
|
||||||
[string]$Phone,
|
[string]$Phone,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Address,
|
[string]$Address,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[string]$Comments,
|
[string]$Comments,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Link,
|
[string]$Link,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Force,
|
[switch]$Force,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
begin {
|
begin {
|
||||||
$Method = 'PATCH'
|
$Method = 'PATCH'
|
||||||
}
|
}
|
||||||
|
|
||||||
process {
|
process {
|
||||||
foreach ($ContactId in $Id) {
|
foreach ($ContactId in $Id) {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactId))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactId))
|
||||||
|
|
||||||
$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
|
||||||
|
|
||||||
$CurrentContact = Get-NetboxContact -Id $ContactId
|
$CurrentContact = Get-NetboxContact -Id $ContactId
|
||||||
|
|
||||||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContact.Name, 'Update contact')) {
|
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContact.Name, 'Update contact')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,34 @@
|
||||||
|
|
||||||
function New-NetboxTenant {
|
function New-NetboxTenant {
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Create a new tenant in Netbox
|
Create a new tenant in Netbox
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
Creates a new tenant object in Netbox
|
Creates a new tenant object in Netbox
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The tenant name, e.g "Contoso Inc"
|
The tenant name, e.g "Contoso Inc"
|
||||||
|
|
||||||
.PARAMETER Slug
|
.PARAMETER Slug
|
||||||
The unique URL for the tenant. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
The unique URL for the tenant. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
||||||
|
|
||||||
.PARAMETER Description
|
.PARAMETER Description
|
||||||
Short description of the tenant
|
Short description of the tenant
|
||||||
|
|
||||||
.PARAMETER Custom_Fields
|
.PARAMETER Custom_Fields
|
||||||
Hashtable of custom field values.
|
Hashtable of custom field values.
|
||||||
|
|
||||||
.PARAMETER Raw
|
.PARAMETER Raw
|
||||||
Return the unparsed data from the HTTP request
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS C:\> New-NetboxTenant -Name 'Contoso Inc' -Slug 'contoso-inc'
|
PS C:\> New-NetboxTenant -Name 'Contoso Inc' -Slug 'contoso-inc'
|
||||||
|
|
||||||
.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])]
|
||||||
|
|
@ -38,28 +38,28 @@ function New-NetboxTenant {
|
||||||
ValueFromPipelineByPropertyName = $true)]
|
ValueFromPipelineByPropertyName = $true)]
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[string]$Name,
|
[string]$Name,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[ValidateLength(1, 100)]
|
[ValidateLength(1, 100)]
|
||||||
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
|
||||||
[string]$Slug,
|
[string]$Slug,
|
||||||
|
|
||||||
[ValidateLength(0, 200)]
|
[ValidateLength(0, 200)]
|
||||||
[string]$Description,
|
[string]$Description,
|
||||||
|
|
||||||
[hashtable]$Custom_Fields,
|
[hashtable]$Custom_Fields,
|
||||||
|
|
||||||
[switch]$Raw
|
[switch]$Raw
|
||||||
)
|
)
|
||||||
|
|
||||||
process {
|
process {
|
||||||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'tenants'))
|
||||||
$Method = 'POST'
|
$Method = 'POST'
|
||||||
|
|
||||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
if ($PSCmdlet.ShouldProcess($Address, 'Create new tenant')) {
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new tenant')) {
|
||||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue