nerm/src/PSSailpoint.NERM/Model/ProfileAttributeRuleDate.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 ConditionObjectType
No description available.
.PARAMETER ConditionObjectId
No description available.
.PARAMETER SecondaryAttributeType
No description available.
.PARAMETER SecondaryAttributeId
No description available.
.PARAMETER ComparisonOperator
No description available.
.PARAMETER Value
No description available.
.PARAMETER SecondaryValue
No description available.
.PARAMETER TertiaryValue
No description available.
.OUTPUTS

ProfileAttributeRuleDate<PSCustomObject>
#>


function Initialize-NERMProfileAttributeRuleDate {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("ProfileAttributeRule")]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("DateAttribute")]
        [String]
        ${ConditionObjectType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${ConditionObjectId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("DateAttribute")]
        [String]
        ${SecondaryAttributeType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${SecondaryAttributeId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet(">", "<", "after", "before")]
        [String]
        ${ComparisonOperator},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("Today", "<uid>")]
        [String]
        ${Value},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("after", "before")]
        [String]
        ${SecondaryValue},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TertiaryValue}
    )

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

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

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

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


        $PSO = [PSCustomObject]@{
            "type" = ${Type}
            "condition_object_type" = ${ConditionObjectType}
            "condition_object_id" = ${ConditionObjectId}
            "secondary_attribute_type" = ${SecondaryAttributeType}
            "secondary_attribute_id" = ${SecondaryAttributeId}
            "comparison_operator" = ${ComparisonOperator}
            "value" = ${Value}
            "secondary_value" = ${SecondaryValue}
            "tertiary_value" = ${TertiaryValue}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to ProfileAttributeRuleDate<PSCustomObject>

.DESCRIPTION

Convert from JSON to ProfileAttributeRuleDate<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ProfileAttributeRuleDate<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in NERMProfileAttributeRuleDate
        $AllProperties = ("id", "uid", "type", "condition_object_type", "condition_object_id", "secondary_attribute_type", "secondary_attribute_id", "comparison_operator", "value", "secondary_value", "tertiary_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 "condition_object_type"))) {
            throw "Error! JSON cannot be serialized due to the required property 'condition_object_type' missing."
        } else {
            $ConditionObjectType = $JsonParameters.PSobject.Properties["condition_object_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 "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 "condition_object_id"))) { #optional property not found
            $ConditionObjectId = $null
        } else {
            $ConditionObjectId = $JsonParameters.PSobject.Properties["condition_object_id"].value
        }

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "uid" = ${Uid}
            "type" = ${Type}
            "condition_object_type" = ${ConditionObjectType}
            "condition_object_id" = ${ConditionObjectId}
            "secondary_attribute_type" = ${SecondaryAttributeType}
            "secondary_attribute_id" = ${SecondaryAttributeId}
            "comparison_operator" = ${ComparisonOperator}
            "value" = ${Value}
            "secondary_value" = ${SecondaryValue}
            "tertiary_value" = ${TertiaryValue}
        }

        return $PSO
    }

}