Model/ScheduledAttributes.ps1

#
# Identity Security Cloud V3 API
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.
# Version: 3.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

Attributes related to a scheduled trigger

.PARAMETER CronString
A valid CRON expression
.PARAMETER Frequency
Frequency of execution
.PARAMETER TimeZone
Time zone identifier
.PARAMETER WeeklyDays
Scheduled days of the week for execution
.PARAMETER WeeklyTimes
Scheduled execution times
.OUTPUTS

ScheduledAttributes<PSCustomObject>
#>


function Initialize-ScheduledAttributes {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${CronString},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("daily", "weekly", "monthly", "yearly", "cronSchedule")]
        [String]
        ${Frequency},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${TimeZone},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${WeeklyDays},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${WeeklyTimes}
    )

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

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


        $PSO = [PSCustomObject]@{
            "cronString" = ${CronString}
            "frequency" = ${Frequency}
            "timeZone" = ${TimeZone}
            "weeklyDays" = ${WeeklyDays}
            "weeklyTimes" = ${WeeklyTimes}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to ScheduledAttributes<PSCustomObject>

.DESCRIPTION

Convert from JSON to ScheduledAttributes<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

ScheduledAttributes<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in ScheduledAttributes
        $AllProperties = ("cronString", "frequency", "timeZone", "weeklyDays", "weeklyTimes")
        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 'frequency' missing."
        }

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "cronString" = ${CronString}
            "frequency" = ${Frequency}
            "timeZone" = ${TimeZone}
            "weeklyDays" = ${WeeklyDays}
            "weeklyTimes" = ${WeeklyTimes}
        }

        return $PSO
    }

}