Public/New-IAMCoreSyncRule.ps1
|
function New-IAMCoreSyncRule { [CmdletBinding(SupportsShouldProcess = $true)] param ( [Parameter(Mandatory = $true)] [string]$Description, [Parameter(Mandatory = $true)] [string]$ConnectorId, [Parameter(Mandatory = $true)] [boolean]$ProvisioningEnabled, [Parameter(Mandatory = $true)] [boolean]$ScheduleEnabled, [Parameter(Mandatory = $true)] [ValidateSet("Identity", "Relationship", "OrgUnit")] [string]$CoreObjectType, [Parameter(Mandatory = $true)] [string]$ConnectorObjectType, [Parameter(Mandatory = $false)] [System.Collections.Specialized.OrderedDictionary[]] $Scope = @( [ordered] @{ '$type' = "true" } ), [Parameter(Mandatory = $true)] [System.Collections.Specialized.OrderedDictionary] $JoinValueExpression, [Parameter(Mandatory = $true)] [ValidateSet("Anchor1", "Anchor2", "Anchor3", "Anchor4", "Anchor5", "Anchor6", "Anchor7", "Anchor8", "Anchor9")] [string] $JoinAttribute, [Parameter(Mandatory = $true)] [System.Collections.Specialized.OrderedDictionary[]] $InboundAttributeFlows, [Parameter(Mandatory = $false)] [int] $Priority = (Get-Random -Minimum 100 -Maximum 1000) ) if ($PSCmdlet.ShouldProcess("Creating IAM Core sync rule '$Description'")) { $Body = @{ description = $Description connectorId = $ConnectorId provisioningEnabled = $ProvisioningEnabled scheduleEnabled = $ScheduleEnabled coreObjectType = $CoreObjectType connectorObjectType = $ConnectorObjectType scope = $Scope joinValueExpression = $JoinValueExpression joinAttribute = $JoinAttribute inboundAttributeFlows = $InboundAttributeFlows priority = $Priority } | ConvertTo-Json -Depth 100 $Result = Invoke-RestMethod -Uri "$Script:APIRoot/sync/syncrules" -Headers (Get-IAMCoreHeader) -Method Post -Body $Body -ContentType "application/json" if ($Result.IsSuccess) { return $Result.Data } else { throw "Failed to create IAM Core sync rule: $($Result.ErrorMessage)" } } } |