File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed
CIPPCore/Public/Entrypoints
CippExtensions/Public/Sherweb Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function Set-SherwebSubscription {
16
16
}
17
17
}
18
18
$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
20
20
21
21
if (-not $ExistingSubscription ) {
22
22
if ($Add -or $Remove ) {
You can’t perform that action at this time.
0 commit comments