forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #61 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
- Loading branch information
Showing
18 changed files
with
1,367 additions
and
1,199 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
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Modules/CippExtensions/Private/GitHub/Get-GitHubFileContents.ps1
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,23 @@ | ||
function Get-GitHubFileContents { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(ValueFromPipelineByPropertyName = $true)] | ||
$Url | ||
) | ||
|
||
process { | ||
$Table = Get-CIPPTable -TableName Extensionsconfig | ||
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).GitHub | ||
[uri]$Uri = $Url | ||
$Path = $Uri.PathAndQuery.TrimStart('/') | ||
$File = Invoke-GitHubApiRequest -Configuration $Configuration -Path "$Path" -Method GET | ||
|
||
return [PSCustomObject]@{ | ||
name = $File.name | ||
path = $File.path | ||
content = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($File.content)) | ||
sha = $File.sha | ||
size = $File.size | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
Modules/CippExtensions/Private/GitHub/Search-GitHubRepository.ps1
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,38 @@ | ||
function Search-GitHubRepository { | ||
[CmdletBinding()] | ||
Param ( | ||
[string[]]$Repository, | ||
[string]$Path, | ||
[string]$SearchTerm, | ||
[string]$Language, | ||
[string]$Type = 'code' | ||
) | ||
$Table = Get-CIPPTable -TableName Extensionsconfig | ||
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).GitHub | ||
|
||
$QueryParts = [System.Collections.Generic.List[string]]::new() | ||
if ($Repository) { | ||
$RepoParts = [System.Collections.Generic.List[string]]::new() | ||
foreach ($Repo in $Repository) { | ||
$RepoParts.Add("repo:$Repo") | ||
} | ||
if (($RepoParts | Measure-Object).Count -gt 1) { | ||
$QueryParts.Add('(' + ($RepoParts -join ' OR ') + ')') | ||
} else { | ||
$QueryParts.Add($RepoParts[0]) | ||
} | ||
} | ||
if ($Path) { | ||
$QueryParts.Add("path:$Path") | ||
} | ||
if ($SearchTerm) { | ||
$QueryParts.Add("`"$SearchTerm`"") | ||
} | ||
if ($Language) { | ||
$QueryParts.Add("language:$Language") | ||
} | ||
|
||
$Query = $QueryParts -join ' ' | ||
Write-Information "Query: $Query" | ||
Invoke-GitHubApiRequest -Configuration $Configuration -Path "search/$($Type)?q=$($Query)" -Method GET | ||
} |
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,28 @@ | ||
function Get-HaloTicketType { | ||
<# | ||
.SYNOPSIS | ||
Get Halo Ticket Type | ||
.DESCRIPTION | ||
Get Halo Ticket Type | ||
.EXAMPLE | ||
Get-HaloTicketType | ||
#> | ||
[CmdletBinding()] | ||
param () | ||
$Table = Get-CIPPTable -TableName Extensionsconfig | ||
try { | ||
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json -ea stop).HaloPSA | ||
$Token = Get-HaloToken -configuration $Configuration | ||
|
||
Invoke-RestMethod -Uri "$($Configuration.ResourceURL)/TicketType?showall=true&showinactive=true&access_control_level=2&include_defaults=true&domain=reqs" -ContentType 'application/json' -Method GET -Headers @{Authorization = "Bearer $($Token.access_token)" } | ||
} catch { | ||
$Message = if ($_.ErrorDetails.Message) { | ||
Get-NormalizedError -Message $_.ErrorDetails.Message | ||
} else { | ||
$_.Exception.message | ||
} | ||
@(@{name = "Could not get HaloPSA Ticket Types, error: $Message"; id = '' }) | ||
} | ||
} | ||
|
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
13 changes: 13 additions & 0 deletions
13
Modules/CippExtensions/Public/PwPush/Get-PwPushAccount.ps1
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,13 @@ | ||
function Get-PwPushAccount { | ||
$Table = Get-CIPPTable -TableName Extensionsconfig | ||
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).PWPush | ||
if ($Configuration.Enabled -eq $true -and $Configuration.PWPushPro -eq $true) { | ||
Set-PwPushConfig -Configuration $Configuration | ||
Get-PushAccount | ||
} else { | ||
return @(@{ | ||
name = 'PWPush Pro is not enabled or configured. Make sure to save the configuration first.'; | ||
id = '' | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.