Model/RiskRule.ps1

#
# NERM API
# The NERM API accesss and modifies resources in your environment.
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Type
No description available.
.PARAMETER ComparisonOperator
No description available.
.PARAMETER Value
No description available.
.PARAMETER SecondaryValue
No description available.
.OUTPUTS

RiskRule<PSCustomObject>
#>


function Initialize-NERMRiskRule {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("RiskRule")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("==", ">", "<")]
        [String]
        ${ComparisonOperator},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Value},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("OverallRisk")]
        [String]
        ${SecondaryValue}
    )

    Process {
        'Creating PSCustomObject: PSSailpoint.NERM => NERMRiskRule' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        if (!$Type) {
            throw "invalid value for 'Type', 'Type' cannot be null."
        }

        if (!$Value) {
            throw "invalid value for 'Value', 'Value' cannot be null."
        }

        if (!$SecondaryValue) {
            throw "invalid value for 'SecondaryValue', 'SecondaryValue' cannot be null."
        }


        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "comparison_operator" = ${ComparisonOperator}
            "value" = ${Value}
            "secondary_value" = ${SecondaryValue}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to RiskRule<PSCustomObject>

.DESCRIPTION

Convert from JSON to RiskRule<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

RiskRule<PSCustomObject>
#>

function ConvertFrom-NERMJsonToRiskRule {
    Param(
        [AllowEmptyString()]
        [string]$Json
    )

    Process {
        'Converting JSON to PSCustomObject: PSSailpoint.NERM => NERMRiskRule' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMRiskRule
        $AllProperties = ("id", "uid", "type", "comparison_operator", "value", "secondary_value")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        If ([string]::IsNullOrEmpty($Json) -or $Json -eq "{}") { # empty json
            throw "Error! Empty JSON cannot be serialized due to the required property 'type' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "type"))) {
            throw "Error! JSON cannot be serialized due to the required property 'type' missing."
        } else {
            $Type = $JsonParameters.PSobject.Properties["type"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "value"))) {
            throw "Error! JSON cannot be serialized due to the required property 'value' missing."
        } else {
            $Value = $JsonParameters.PSobject.Properties["value"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "secondary_value"))) {
            throw "Error! JSON cannot be serialized due to the required property 'secondary_value' missing."
        } else {
            $SecondaryValue = $JsonParameters.PSobject.Properties["secondary_value"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "id"))) { #optional property not found
            $Id = $null
        } else {
            $Id = $JsonParameters.PSobject.Properties["id"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "uid"))) { #optional property not found
            $Uid = $null
        } else {
            $Uid = $JsonParameters.PSobject.Properties["uid"].value
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "comparison_operator"))) { #optional property not found
            $ComparisonOperator = $null
        } else {
            $ComparisonOperator = $JsonParameters.PSobject.Properties["comparison_operator"].value
        }

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "uid" = ${Uid}
            "type" = ${Type}
            "comparison_operator" = ${ComparisonOperator}
            "value" = ${Value}
            "secondary_value" = ${SecondaryValue}
        }

        return $PSO
    }

}