NetboxPS/Functions/Tenancy/ContactRoles/New-NetboxContactRole.ps1
Ben Claussen 9e84ec86b4
v1.8.5 (#53)
* Update New-NetboxContactAssignment name

* Update Get-NetboxAPIDefinition for new path
- Add $Format parameter for json or yaml

* Move Get-NetboxTag file

* Update psproj

* Add Set-NetboxContactRole and Assignment functions

* Update New-NetboxContactAssignment Content_Type parameter values and validation

* Correct variable references in ShouldProcess

* Update version to 1.8.5

Fixes #51 

---------

Co-authored-by: Ben Claussen <benclaussen@gmail.com>
2023-11-09 12:19:20 -05:00

71 lines
1.8 KiB
PowerShell

function New-NetboxContactRole {
<#
.SYNOPSIS
Create a new contact role in Netbox
.DESCRIPTION
Creates a new contact role object in Netbox
.PARAMETER Name
The contact role name, e.g "Network Support"
.PARAMETER Slug
The unique URL for the role. Can only contain hypens, A-Z, a-z, 0-9, and underscores
.PARAMETER Description
Short description of the contact role
.PARAMETER Custom_Fields
A description of the Custom_Fields parameter.
.PARAMETER Raw
Return the unparsed data from the HTTP request
.EXAMPLE
PS C:\> New-NetboxContact -Name 'Leroy Jenkins' -Email 'leroy.jenkins@example.com'
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'Low',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[ValidateLength(1, 100)]
[string]$Name,
[Parameter(Mandatory = $true)]
[ValidateLength(1, 100)]
[ValidatePattern('^[-a-zA-Z0-9_]+$')]
[string]$Slug,
[ValidateLength(0, 200)]
[string]$Description,
[hashtable]$Custom_Fields,
[switch]$Raw
)
process {
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts'))
$Method = 'POST'
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Name, 'Create new contact')) {
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
}
}
}