Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
!Deploy!
Browse files Browse the repository at this point in the history
  • Loading branch information
Gary Smith committed Jun 2, 2021
1 parent 33d64e0 commit 2ac577a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Format as below (Requires the '### Added' as a header or task fails)
...- Update ReadMe.MD

## [Unreleased]
### Added
- Set-InsightObject and Get-InsightObject updated to suport more depth for JSON.
- Set-InsightObject and New-InsightObject updated array var name

## [1.16] - 2021-06-01
### Added
Expand Down
72 changes: 72 additions & 0 deletions JSM.Insight/Public/Find-InsightObject.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
function Find-InsightObject {
[CmdletBinding()]
param (
[string]$IQL,
[string]$objectTypeId,
[int]$page = 1,
[int]$resultsPerPage = 500,
[int]$orderByTypeAttrId,
[ValidateSet(0,1)]
[int]$asc = 1,
[string]$objectId,
[string]$objectSchemaId,
[bool]$includeAttributes,
[array]$attributesToDisplay,
[String]$Version = "1",
[string]$InsightCreds = $InsightCreds,
[string]$InsightWorkspaceID = $InsightWorkspaceID
)

begin {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"
$Headers = New-InsightHeaders
}

process {

$RequestBody = @{
'iql' = $iql
'objectTypeId' = $objectTypeId
'resultsPerPage' = $resultsPerPage
}
if ($page) {
$RequestBody.Add('page', $page)
}
if ($orderByTypeAttrId) {
$RequestBody.Add('orderByTypeAttrId', $orderByTypeAttrId)
}
if ($asc) {
$RequestBody.Add('asc', $asc)
}
if ($objectId) {
$RequestBody.Add('objectId', $objectId)
}
if ($objectSchemaId) {
$RequestBody.Add('objectSchemaId', $objectSchemaId)
}
if ($includeAttributes) {
$RequestBody.Add('includeAttributes', $includeAttributes)
}
if ($attributesToDisplay ) {
$RequestBody.Add('attributesToDisplay', $attributesToDisplay)
}

$RequestBody = $RequestBody | ConvertTo-Json -Depth 5

$Request = [System.UriBuilder]"https://api.atlassian.com/jsm/insight/workspace/$InsightWorkspaceID/v$Version/object/navlist/iql"
}

end {
try {
$response = Invoke-RestMethod -Uri $Request.Uri -Body $RequestBody -Headers $headers -Method POST
}
catch {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Failed"
Write-Error -Message "$($_.Exception.Message)" -ErrorId $_.Exception.Code -Category InvalidOperation
}

$response

Write-Verbose "[$($MyInvocation.MyCommand.Name)] Complete"
}
}
5 changes: 3 additions & 2 deletions JSM.Insight/Public/New-InsightObject.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function New-InsightObject {
[CmdletBinding()]
param (
Expand All @@ -20,9 +19,11 @@ function New-InsightObject {

$RequestBody = @{
'objectTypeId' = $objectTypeId
'attributes' = @($attributes)
'attributes' = @($attributesArray)
}

$RequestBody = $RequestBody | ConvertTo-Json -Depth 5

$Request = [System.UriBuilder]"https://api.atlassian.com/jsm/insight/workspace/$InsightWorkspaceID/v$Version/object/create"
}

Expand Down
4 changes: 3 additions & 1 deletion JSM.Insight/Public/Set-InsightObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ function Set-InsightObject {

$RequestBody = @{
'objectTypeId' = $objectTypeId
'attributes' = @($attributes)
'attributes' = @($attributesArray)
}

$RequestBody = $RequestBody | ConvertTo-Json -Depth 5

$Request = [System.UriBuilder]"https://api.atlassian.com/jsm/insight/workspace/$InsightWorkspaceID/v$Version/object/$id"
}

Expand Down

0 comments on commit 2ac577a

Please sign in to comment.