Skip to content

Commit

Permalink
extra functions
Browse files Browse the repository at this point in the history
  • Loading branch information
KelvinTegelaar committed May 31, 2023
1 parent 8c40137 commit a941814
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
19 changes: 19 additions & 0 deletions ExecExtensionTest/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "Request",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "Response"
}
]
}
38 changes: 38 additions & 0 deletions ExecExtensionTest/run.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using namespace System.Net

# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)

$APIName = $TriggerMetadata.FunctionName
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message "Accessed this API" -Sev "Debug"
$Table = Get-CIPPTable -TableName Extensionsconfig
$Configuration = ((Get-AzDataTableEntity @Table).config | ConvertFrom-Json)
# Interact with query parameters or the body of the request.
try {
switch ($Request.query.extensionName) {
"HaloPSA" {

$token = Get-HaloToken -configuration $Configuration.HaloPSA
$Results = [pscustomobject]@{"Results" = "Succesfully Connected to HaloPSA" }
}
"Gradient" {
$GradientToken = Get-GradientToken -Configuration $Configuration.Gradient
$ExistingIntegrations = (Invoke-RestMethod -Uri 'https://app.usegradient.com/api/vendor-api/organization' -Method GET -Headers $GradientToken)
if ($ExistingIntegrations.Status -ne "active") {
$ActivateRequest = Invoke-RestMethod -Uri 'https://app.usegradient.com/api/vendor-api/organization/status/active' -Method PATCH -Headers $GradientToken
}
$Results = [pscustomobject]@{"Results" = "Succesfully Connected to Gradient" }

}

}
}
catch {
$Results = [pscustomobject]@{"Results" = "Failed to connect: $($_.Exception.Message)" }
}

# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Results
})
Binary file modified Modules/CippExtensions/CippExtensions.psd1
Binary file not shown.
1 change: 0 additions & 1 deletion Modules/CippExtensions/Public/Get-CippMappings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function Get-CippMappings {
switch ($ConfigItem) {
"HaloPSA" {
If ($Configuration.HaloPSA.enabled) {
$MappedId =
New-HaloPSATicket -Title "CIPP Alert" -Description "CIPP Alert" -client $mappedId -Priority "Low" -Type "Incident" -Status "New" -Source "CIPP" -Assignee "CIPP"
}
}
Expand Down

0 comments on commit a941814

Please sign in to comment.