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 KelvinTegelaar#534 from KelvinTegelaar/dev
Dev to release
- Loading branch information
Showing
9 changed files
with
137 additions
and
48 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
87 changes: 87 additions & 0 deletions
87
Modules/CIPPCore/Public/Entrypoints/Invoke-ExecOnboardTenant.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,87 @@ | ||
using namespace System.Net | ||
|
||
function Invoke-ExecOnboardTenant { | ||
param($Request, $TriggerMetadata) | ||
|
||
$APIName = 'ExecOnboardTenant' | ||
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug' | ||
|
||
$Id = $Request.Body.Id | ||
if ($Id) { | ||
try { | ||
$OnboardTable = Get-CIPPTable -TableName 'TenantOnboarding' | ||
$TenantOnboarding = Get-CIPPAzDataTableEntity @OnboardTable -Filter "RowKey eq '$Id'" | ||
|
||
if (!$TenantOnboarding -or [bool]$Request.Query.Retry) { | ||
$OnboardingSteps = [PSCustomObject]@{ | ||
'Step1' = @{ | ||
'Status' = 'pending' | ||
'Title' = 'Step 1: GDAP Invite' | ||
'Message' = 'Waiting for onboarding job to start' | ||
} | ||
'Step2' = @{ | ||
'Status' = 'pending' | ||
'Title' = 'Step 2: GDAP Role Test' | ||
'Message' = 'Waiting for Step 1' | ||
} | ||
'Step3' = @{ | ||
'Status' = 'pending' | ||
'Title' = 'Step 3: GDAP Group Mapping' | ||
'Message' = 'Waiting for Step 2' | ||
} | ||
'Step4' = @{ | ||
'Status' = 'pending' | ||
'Title' = 'Step 4: CPV Refresh' | ||
'Message' = 'Waiting for Step 3' | ||
} | ||
'Step5' = @{ | ||
'Status' = 'pending' | ||
'Title' = 'Step 5: Graph API Test' | ||
'Message' = 'Waiting for Step 4' | ||
} | ||
} | ||
$TenantOnboarding = [PSCustomObject]@{ | ||
PartitionKey = 'Onboarding' | ||
RowKey = [string]$Id | ||
CustomerId = '' | ||
Status = 'queued' | ||
OnboardingSteps = [string](ConvertTo-Json -InputObject $OnboardingSteps -Compress) | ||
Relationship = '' | ||
Logs = '' | ||
Exception = '' | ||
} | ||
Add-CIPPAzDataTableEntity @OnboardTable -Entity $TenantOnboarding -Force -ErrorAction Stop | ||
|
||
Push-OutputBinding -Name QueueItem -Value ([pscustomobject]@{ | ||
FunctionName = 'ExecOnboardTenantQueue' | ||
id = $Id | ||
Roles = $Request.Body.gdapRoles | ||
}) | ||
} | ||
|
||
$Steps = $TenantOnboarding.OnboardingSteps | ConvertFrom-Json | ||
$OnboardingSteps = foreach ($Step in $Steps.PSObject.Properties.Name) { $Steps.$Step } | ||
$Relationship = try { $TenantOnboarding.Relationship | ConvertFrom-Json -ErrorAction Stop } catch { @{} } | ||
$Logs = try { $TenantOnboarding.Logs | ConvertFrom-Json -ErrorAction Stop } catch { @{} } | ||
$TenantOnboarding.OnboardingSteps = $OnboardingSteps | ||
$TenantOnboarding.Relationship = $Relationship | ||
$TenantOnboarding.Logs = $Logs | ||
$Results = $TenantOnboarding | ||
|
||
$StatusCode = [HttpStatusCode]::OK | ||
} catch { | ||
$ErrorMsg = Get-NormalizedError -message $($_.Exception.Message) | ||
$Results = "Function Error: $($_.InvocationInfo.ScriptLineNumber) - $ErrorMsg" | ||
$StatusCode = [HttpStatusCode]::BadRequest | ||
} | ||
} else { | ||
$StatusCode = [HttpStatusCode]::NotFound | ||
$Results = 'Relationship not found' | ||
} | ||
# Associate values to output bindings by calling 'Push-OutputBinding'. | ||
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{ | ||
StatusCode = $StatusCode | ||
Body = $Results | ||
}) | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.8.3 | ||
4.8.4 |