From 5209f050bc7f9a992b436bf75f2914fe0fbef531 Mon Sep 17 00:00:00 2001 From: ffeldhaus Date: Tue, 18 Dec 2018 16:47:20 +0100 Subject: [PATCH] Implemented Retrieving of FC identify --- src/OnCommand-Insight.psm1 | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/OnCommand-Insight.psm1 b/src/OnCommand-Insight.psm1 index 8de88df..d8f2cc7 100644 --- a/src/OnCommand-Insight.psm1 +++ b/src/OnCommand-Insight.psm1 @@ -5059,7 +5059,7 @@ function Global:Update-OciAnnotation { $Result = ParseJsonString -json $Result.Trim() } - Write-Output $Result + Write-Output $Result } } @@ -6401,7 +6401,7 @@ function Global:Bulk-OciAssignApplicationToAssets { if (!$assets) { throw "No Assets specified!" } - + $switchparameters=@() foreach ($parameter in $switchparameters) { if ((Get-Variable $parameter).Value) { @@ -16116,7 +16116,7 @@ function Global:Get-OciAnnotationsByQtree { if ($Definition) { $Uri += "?expand=definition" - } + } try { $Result = Invoke-RestMethod -WebSession $Server.Session -TimeoutSec $Server.Timeout -Method GET -Uri $Uri -Headers $Server.Headers @@ -31137,6 +31137,61 @@ function Global:Search-Oci { } } +## identifications ## + +<# + .SYNOPSIS + Retrieve FC Identify + .DESCRIPTION + Retrieve FC Identify + .PARAMETER expand + Expand parameter for underlying JSON object (e.g. expand=acquisitionUnit) + .PARAMETER server + OCI Server to connect to +#> +function Global:Get-OciFcIdentify { + [CmdletBinding()] + + PARAM ( + [parameter(Mandatory=$False, + Position=0, + HelpMessage="Expand parameter for underlying JSON object (e.g. expand=acquisitionUnit)")][String]$expand, + [parameter(Mandatory=$False, + Position=1, + HelpMessage="OnCommand Insight Server.")]$Server=$CurrentOciServer + ) + + Begin { + $Result = $null + if (!$Server) { + throw "Server parameter not specified and no global OCI Server available. Run Connect-OciServer first!" + } + } + + Process { + $Uri = $Server.BaseUri + "/rest/v1/identifications/fc" + + if ($expand) { + $Uri += "?$($Separator)expand=$expand" + } + + try { + $Result = Invoke-RestMethod -WebSession $Server.Session -TimeoutSec $Server.Timeout -Method GET -Uri $Uri -Headers $Server.Headers + } + catch { + $ResponseBody = ParseExceptionBody -Response $_.Exception.Response + Write-Error "GET to $Uri failed with Exception $($_.Exception.Message) `n $responseBody" + } + + if (([String]$Result).Trim().startsWith('{') -or ([String]$Result).toString().Trim().startsWith('[')) { + $Result = ParseJsonString -json $Result.Trim + } + + #$Datasources = ParseDatasources -Datasources $Result -Timezone $Server.Timezone + Write-Output $Result + } +} + ### Experimental Cmdlets ### <#