ps/Modules/Alkami.DevOps.Inventory/Public/New-PlatformElementDetails.ps1

40 lines
1.4 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function New-PlatformElementDetails {
<#
.SYNOPSIS
Use to persist an array of PlatformElementDetails to BoRG
.EXAMPLE
New-PlatformElementDetails -PlatformElementDetailArray @($obj) -BorgUri "http://uri.to.borg.com"
.PARAMETER PlatformElementDetailArray
An array of PSObjects containing all element details to be persisted. Use New-PlatformElementDetailPSObject for creation of the required PSObjects.
.PARAMETER BorgUri
Uri to the BoRG REST service.
.PARAMETER ApiKey
Borg Api key. Required for write operations.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[PSObject[]]$PlatformElementDetailArray, #Use New-PlatformElementDetailPSObject to create each PSObject
[Parameter(Mandatory = $true)]
[string]$BorgUri,
[Parameter(Mandatory = $true)]
[string]$ApiKey
)
$uri = "$BorgUri/api/PlatformElementDetails/PostCascadeChildren"
$headers = @{ "x-api-key" = $ApiKey }
$body = ConvertTo-Json $PlatformElementDetailArray
$response = Invoke-CommandWithRetry -Arguments @($uri,$headers,$body) -Seconds 3 -JitterMin 500 -JitterMax 3000 -ScriptBlock {
param($uri,$headers,$body)
return (Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -body $body -ContentType "application/json")
}
return ConvertTo-Json $response
}