Implement ITG API
This commit is contained in:
7
main.ps1
7
main.ps1
@@ -19,6 +19,7 @@ $urls = @{
|
||||
autotask = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/autotask.ps1"
|
||||
datto = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/dattormm.ps1"
|
||||
pax8 = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/pax8.ps1"
|
||||
itglue = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/tools/itglue.ps1"
|
||||
config = "https://git.svstools.com/cpayne/InstaClientPS/raw/branch/main/config.ps1"
|
||||
}
|
||||
|
||||
@@ -264,6 +265,12 @@ $SubmitBtn.Add_Click({
|
||||
-Credentials $script:toolCredentials
|
||||
}
|
||||
|
||||
if ($ITGlueBox.IsChecked) {
|
||||
Write-Host "[INFO] Provisioning IT Glue..."
|
||||
Invoke-ITGlueProvision -CompanyName $company -Credentials $script:toolCredentials
|
||||
}
|
||||
|
||||
|
||||
$StatusBlock.Text = "Provisioning completed successfully."
|
||||
Write-Host "[SUCCESS] Provisioning complete."
|
||||
|
||||
|
||||
41
tools/itglue.ps1
Normal file
41
tools/itglue.ps1
Normal 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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user