diff --git a/Functions/Tenancy/ContactAssignment/Set-NetboxContactAssignment.ps1 b/Functions/Tenancy/ContactAssignment/Set-NetboxContactAssignment.ps1 new file mode 100644 index 0000000..5925ccc --- /dev/null +++ b/Functions/Tenancy/ContactAssignment/Set-NetboxContactAssignment.ps1 @@ -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 + } + } + } +} + + + + diff --git a/Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1 b/Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1 new file mode 100644 index 0000000..955ab44 --- /dev/null +++ b/Functions/Tenancy/ContactRoles/Set-NetboxContactRole.ps1 @@ -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 + } + } + } +} + + + +