mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-15 02:35:46 +00:00
Add New-NetboxTenant function
This commit is contained in:
parent
c0e18ec134
commit
b720c03851
1 changed files with 71 additions and 0 deletions
71
Functions/Tenancy/Tenants/New-NetboxTenant.ps1
Normal file
71
Functions/Tenancy/Tenants/New-NetboxTenant.ps1
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
function New-NetboxTenant {
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Create a new tenant in Netbox
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Creates a new tenant object in Netbox
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The tenant name, e.g "Contoso Inc"
|
||||||
|
|
||||||
|
.PARAMETER Slug
|
||||||
|
The unique URL for the tenant. Can only contain hypens, A-Z, a-z, 0-9, and underscores
|
||||||
|
|
||||||
|
.PARAMETER Description
|
||||||
|
Short description of the tenant
|
||||||
|
|
||||||
|
.PARAMETER Custom_Fields
|
||||||
|
Hashtable of custom field values.
|
||||||
|
|
||||||
|
.PARAMETER Raw
|
||||||
|
Return the unparsed data from the HTTP request
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS C:\> New-NetboxTenant -Name 'Contoso Inc' -Slug 'contoso-inc'
|
||||||
|
|
||||||
|
.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', 'tenants'))
|
||||||
|
$Method = 'POST'
|
||||||
|
|
||||||
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||||
|
|
||||||
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess($Address, 'Create new tenant')) {
|
||||||
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue