Resources/Documents.ps1
function Set-ITGlueDocuments { [CmdletBinding(DefaultParameterSetName = 'update')] Param ( [Parameter(ParameterSetName = 'update')] [int64]$organization_id, [Parameter(ParameterSetName = 'update')] [Parameter(Mandatory = $true)] [int64]$id, [Parameter(ParameterSetName = 'update')] [Parameter(ParameterSetName = 'bulk_update')] [Parameter(Mandatory = $true)] $data ) $resource_uri = ('/documents/{0}' -f $id) if ($organization_id) { $resource_uri = ('/organizations/{0}/relationships/documents/{1}' -f $organization_id, $id) } $body = @{} $body += @{'data' = $data} $body = ConvertTo-Json -InputObject $body -Depth $ITGlue_JSON_Conversion_Depth try { $ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password) $rest_output = Invoke-RestMethod -method 'PATCH' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers ` -body $body -ErrorAction Stop -ErrorVariable $web_error } catch { Write-Error $_ } finally { [void] $ITGlue_Headers.Remove('x-api-key') # Quietly clean up scope so the API key doesn't persist } $data = @{} $data = $rest_output return $data } |