Implement ITG API

This commit is contained in:
Chris Payne
2025-07-08 22:03:13 -04:00
parent bd4c1fa88a
commit fa18f7a3d4
2 changed files with 48 additions and 0 deletions

41
tools/itglue.ps1 Normal file
View File

@@ -0,0 +1,41 @@
function Invoke-ITGlueProvision {
param (
[Parameter(Mandatory = $true)]
[string]$CompanyName,
[Parameter(Mandatory = $true)]
[hashtable]$Credentials
)
if (-not $Credentials.ITGUrl -or -not $Credentials.ITGKey) {
Write-Host "[WARN] Missing ITGUrl or ITGKey in credentials. Skipping IT Glue provisioning."
return
}
$headers = @{
"x-api-key" = $Credentials.ITGKey
"Content-Type" = "application/vnd.api+json"
}
$body = @{
data = @{
type = "organizations"
attributes = @{
name = $CompanyName
}
}
} | ConvertTo-Json -Depth 10
try {
$response = Invoke-RestMethod -Uri "$($Credentials.ITGUrl)/organizations" -Method POST -Headers $headers -Body $body
Write-Host "[INFO] Created IT Glue org: $($response.data.attributes.name)"
}
catch {
if ($_.Exception.Response.StatusCode.Value__ -eq 422) {
Write-Warning "[WARN] IT Glue org may already exist: $CompanyName"
}
else {
Write-Error "[ERROR] IT Glue provisioning failed: $($_.Exception.Message)"
}
}
}