Skip to content

Commit 393968b

Browse files
Add ability to buy licenses too
1 parent 8b6f84c commit 393968b

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ExecCSPLicense {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
Tenant.Directory.Read
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
16+
17+
# Write to the Azure Functions log stream.
18+
Write-Host 'PowerShell HTTP trigger function processed a request.'
19+
20+
# Interact with query parameters or the body of the request.
21+
$TenantFilter = $Request.body.TenantFilter
22+
$Action = $Request.body.Action
23+
24+
try {
25+
if ($Action -eq 'Add') {
26+
$GraphRequest = Set-SherwebSubscription -tenantFilter $TenantFilter -SKU $Request.body.sku -add $Request.body.Add
27+
}
28+
29+
if ($Action -eq 'Remove') {
30+
$GraphRequest = Set-SherwebSubscription -tenantFilter $TenantFilter -SKU $Request.body.sku -remove $Request.body.Remove
31+
}
32+
33+
if ($Action -eq 'NewSub') {
34+
$GraphRequest = Set-SherwebSubscription -tenantFilter $TenantFilter -SKU $Request.body.sku -Quantity $Request.body.Quantity
35+
}
36+
$Message = 'License change executed successfully.'
37+
} catch {
38+
$Message = "Failed to execute license change. Error: $_"
39+
}
40+
#If #GraphRequest is a GUID, the subscription was edited succesfully, and return that its done.
41+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
42+
StatusCode = [HttpStatusCode]::OK
43+
Body = $Message
44+
}) -Clobber
45+
46+
}

Modules/CippExtensions/Public/Sherweb/Set-SherwebSubscription.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Set-SherwebSubscription {
1616
}
1717
}
1818
$AuthHeader = Get-SherwebAuthentication
19-
$ExistingSubscription = Get-CurrentSherwebSubscription -ClientId $ClientId -ClientSecret $ClientSecret -SubscriptionKey $SubscriptionKey -CustomerId $CustomerId -SKU $SKU
19+
$ExistingSubscription = Get-SherwebCurrentSubscription -CustomerId $CustomerId -SKU $SKU
2020

2121
if (-not $ExistingSubscription) {
2222
if ($Add -or $Remove) {

0 commit comments

Comments
 (0)