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.
- Loading branch information
1 parent
a17af34
commit 61bcc5a
Showing
8 changed files
with
96 additions
and
123 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Modules/CIPPCore/Public/CippQueue/Invoke-ListCippQueue.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 Invoke-ListCippQueue { | ||
# Input bindings are passed in via param block. | ||
param($Request = $null, $TriggerMetadata) | ||
|
||
if ($Request) { | ||
$APIName = $TriggerMetadata.FunctionName | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug' | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host 'PowerShell HTTP trigger function processed a request.' | ||
} | ||
|
||
$CippQueue = Get-CippTable -TableName 'CippQueue' | ||
$CippQueueData = Get-CIPPAzDataTableEntity @CippQueue | Where-Object { ($_.Timestamp.DateTime) -ge (Get-Date).ToUniversalTime().AddHours(-1) } | Sort-Object -Property Timestamp -Descending | ||
if ($request) { | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = @($CippQueueData) | ||
}) | ||
} else { | ||
return $CippQueueData | ||
} | ||
} |
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 New-CippQueueEntry { | ||
Param( | ||
$Name, | ||
$Link, | ||
$Reference | ||
) | ||
|
||
$CippQueue = Get-CippTable -TableName CippQueue | ||
|
||
$QueueEntry = @{ | ||
PartitionKey = 'CippQueue' | ||
RowKey = (New-Guid).Guid.ToString() | ||
Name = $Name | ||
Link = $Link | ||
Reference = $Reference | ||
Status = 'Queued' | ||
} | ||
$CippQueue.Entity = $QueueEntry | ||
|
||
Add-CIPPAzDataTableEntity @CippQueue | ||
|
||
$QueueEntry | ||
} |
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,18 @@ | ||
function Remove-CippQueue { | ||
# 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' | ||
|
||
# Write to the Azure Functions log stream. | ||
Write-Host 'PowerShell HTTP trigger function processed a request.' | ||
|
||
$CippQueue = Get-CippTable -TableName 'CippQueue' | ||
Clear-AzDataTable @CippQueue | ||
|
||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = [HttpStatusCode]::OK | ||
Body = @{Results = @('History cleared') } | ||
}) | ||
} |
29 changes: 29 additions & 0 deletions
29
Modules/CIPPCore/Public/CippQueue/Update-CippQueueEntry.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,29 @@ | ||
function Update-CippQueueEntry { | ||
Param( | ||
[Parameter(Mandatory = $true)] | ||
$RowKey, | ||
$Status, | ||
$Name | ||
) | ||
|
||
$CippQueue = Get-CippTable -TableName CippQueue | ||
|
||
if ($RowKey) { | ||
$QueueEntry = Get-CIPPAzDataTableEntity @CippQueue -Filter ("RowKey eq '{0}'" -f $RowKey) | ||
|
||
if ($QueueEntry) { | ||
if ($Status) { | ||
$QueueEntry.Status = $Status | ||
} | ||
if ($Name) { | ||
$QueueEntry.Name = $Name | ||
} | ||
Update-AzDataTableEntity @CippQueue -Entity $QueueEntry | ||
$QueueEntry | ||
} else { | ||
return $false | ||
} | ||
} else { | ||
return $false | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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