-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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>
- Loading branch information
1 parent
44dcb25
commit 9e84ec8
Showing
12 changed files
with
426 additions
and
126 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
Functions/Tenancy/ContactAssignment/Set-NetboxContactAssignment.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
|
||
function Set-NetboxContactAssignment { | ||
<# | ||
.SYNOPSIS | ||
Update a contact role assignment in Netbox | ||
.DESCRIPTION | ||
Updates a contact role assignment in Netbox | ||
.PARAMETER Content_Type | ||
The content type for this assignment. | ||
.PARAMETER Object_Id | ||
ID of the object to assign. | ||
.PARAMETER Contact | ||
ID of the contact to assign. | ||
.PARAMETER Role | ||
ID of the contact role to assign. | ||
.PARAMETER Priority | ||
Priority of the contact assignment. | ||
.PARAMETER Raw | ||
Return the unparsed data from the HTTP request | ||
.EXAMPLE | ||
PS C:\> Set-NetboxContactAssignment -Id 11 -Content_Type 'dcim.location' -Object_id 10 -Contact 15 -Role 10 -Priority 'Primary' | ||
.NOTES | ||
Valid content types: https://docs.netbox.dev/en/stable/features/contacts/#contacts_1 | ||
#> | ||
|
||
[CmdletBinding(ConfirmImpact = 'Low', | ||
SupportsShouldProcess = $true)] | ||
[OutputType([pscustomobject])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true, | ||
ValueFromPipelineByPropertyName = $true)] | ||
[uint64[]]$Id, | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = $true)] | ||
[ValidateSet('circuits.circuit', 'circuits.provider', 'circuits.provideraccount', 'dcim.device', 'dcim.location', 'dcim.manufacturer', 'dcim.powerpanel', 'dcim.rack', 'dcim.region', 'dcim.site', 'dcim.sitegroup', 'tenancy.tenant', 'virtualization.cluster', 'virtualization.clustergroup', 'virtualization.virtualmachine', IgnoreCase = $true)] | ||
[string]$Content_Type, | ||
|
||
[uint64]$Object_Id, | ||
|
||
[uint64]$Contact, | ||
|
||
[uint64]$Role, | ||
|
||
[ValidateSet('primary', 'secondary', 'tertiary', 'inactive', IgnoreCase = $true)] | ||
[string]$Priority, | ||
|
||
[switch]$Raw | ||
) | ||
|
||
begin { | ||
$Method = 'Patch' | ||
} | ||
|
||
process { | ||
foreach ($ContactAssignmentId in $Id) { | ||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contact-assignments', $ContactAssignmentId)) | ||
|
||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force' | ||
|
||
$URI = BuildNewURI -Segments $URIComponents.Segments | ||
|
||
$CurrentContactAssignment = Get-NetboxContactAssignment -Id $ContactAssignmentId -ErrorAction Stop | ||
|
||
if ($PSCmdlet.ShouldProcess($CurrentContactAssignment.Id, 'Update contact assignment')) { | ||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
|
||
function Set-NetboxContactRole { | ||
<# | ||
.SYNOPSIS | ||
Update a contact role in Netbox | ||
.DESCRIPTION | ||
Updates a contact role 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)] | ||
[uint64[]]$Id, | ||
|
||
[Parameter(ValueFromPipelineByPropertyName = $true)] | ||
[ValidateLength(1, 100)] | ||
[string]$Name, | ||
|
||
[ValidateLength(1, 100)] | ||
[ValidatePattern('^[-a-zA-Z0-9_]+$')] | ||
[string]$Slug, | ||
|
||
[ValidateLength(0, 200)] | ||
[string]$Description, | ||
|
||
[hashtable]$Custom_Fields, | ||
|
||
[switch]$Raw | ||
) | ||
|
||
begin { | ||
$Method = 'PATCH' | ||
} | ||
|
||
process { | ||
foreach ($ContactRoleId in $Id) { | ||
$Segments = [System.Collections.ArrayList]::new(@('tenancy', 'contacts', $ContactRoleId)) | ||
|
||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force' | ||
|
||
$URI = BuildNewURI -Segments $URIComponents.Segments | ||
|
||
$CurrentContactRole = Get-NetboxContactRole -Id $ContactRoleId -ErrorAction Stop | ||
|
||
if ($Force -or $PSCmdlet.ShouldProcess($CurrentContactRole.Name, 'Update contact role')) { | ||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.