-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from Celerium/master
New Get-ITGlueLogs & Added support for the Australian datacenter
- Loading branch information
Showing
12 changed files
with
147 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,6 @@ function Set-ITGlueDocuments { | |
} | ||
|
||
$data = @{} | ||
$data = $rest_output | ||
$data = $rest_output | ||
return $data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
function Get-ITGlueLogs { | ||
<# | ||
.SYNOPSIS | ||
Get all activity logs of the account for the most recent 30 days. | ||
.DESCRIPTION | ||
The Get-ITGlueLogs cmdlet gets all activity logs of the account for the most recent 30 days. | ||
This endpoint is limited to 5 pages of results. If more results are desired, | ||
setting a larger page [size] will increase the number of results per page. | ||
To iterate over even more results, use filter [created_at] (with created_at sort) | ||
to fetch a subset of results based on timestamp, then use the last timestamp | ||
in the last page the start date in the filter for the next request. | ||
.PARAMETER sort | ||
Sort the order of the returned data | ||
Allowed values: | ||
'created_at','-created_at' | ||
.PARAMETER page_number | ||
The page number to return data from | ||
This endpoint is limited to 5 pages of results. | ||
.PARAMETER page_size | ||
The number of results to return with each page | ||
By default ITGlues API returned the first 50 items. | ||
Allowed values: | ||
1 - 1000 | ||
.EXAMPLE | ||
Get-ITGlueLogs | ||
Pulls the first 50 activity logs from the last 30 days with data | ||
being sorted newest to oldest. | ||
.EXAMPLE | ||
Get-ITGlueLogs -sort -created_at | ||
Pulls the first 50 activity logs from the last 30 days with data | ||
being sorted oldest to newest. | ||
.EXAMPLE | ||
Get-ITGlueLogs -page_number 2 | ||
Pulls the first 50 activity logs starting from page 2 from the last 30 days | ||
with data being sorted newest to oldest. | ||
.NOTES | ||
As of 2022-11 | ||
Need to add in the "filter[created_at]" parameter | ||
.LINK | ||
https://api.itglue.com/developer/#logs | ||
.LINK | ||
https://github.com/itglue/powershellwrapper | ||
#> | ||
|
||
[CmdletBinding(DefaultParameterSetName = 'index')] | ||
Param ( | ||
[Parameter(ParameterSetName = 'index')] | ||
[ValidateSet( 'created_at','-created_at' )] | ||
[String]$sort = '', | ||
|
||
[Parameter(ParameterSetName = 'index')] | ||
[Nullable[Int64]]$page_number = $null, | ||
|
||
[Parameter(ParameterSetName = 'index')] | ||
[ValidateRange ( 1, 1000 )] | ||
[Nullable[int]]$page_size = $null | ||
) | ||
|
||
$resource_uri = '/logs' | ||
|
||
if ($PSCmdlet.ParameterSetName -eq 'index') { | ||
if ($sort) { | ||
$body += @{'sort' = $sort} | ||
} | ||
if ($page_number) { | ||
$body += @{'page[number]' = $page_number} | ||
} | ||
if ($page_size) { | ||
$body += @{'page[size]' = $page_size} | ||
} | ||
} | ||
|
||
try { | ||
$ITGlue_Headers.Add('x-api-key', (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'N/A', $ITGlue_API_Key).GetNetworkCredential().Password) | ||
$rest_output = Invoke-RestMethod -method 'GET' -uri ($ITGlue_Base_URI + $resource_uri) -headers $ITGlue_Headers ` | ||
-body $body -ErrorAction Stop -ErrorVariable web_error | ||
} catch { | ||
Write-Error $_ | ||
} finally { | ||
[void] ($ITGlue_Headers.Remove('x-api-key')) # Quietly clean up scope so the API key doesn't persist | ||
} | ||
|
||
$data = @{} | ||
$data = $rest_output | ||
return $data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters