Model/WorkItems.ps1

#
# Identity Security Cloud Beta API
# Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. These APIs are in beta and are subject to change. 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.1.0-beta
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Id
ID of the work item
.PARAMETER RequesterId
ID of the requester
.PARAMETER RequesterDisplayName
The displayname of the requester
.PARAMETER OwnerId
The ID of the owner
.PARAMETER OwnerName
The name of the owner
.PARAMETER Created
No description available.
.PARAMETER Modified
No description available.
.PARAMETER Description
The description of the work item
.PARAMETER State
No description available.
.PARAMETER Type
No description available.
.PARAMETER RemediationItems
No description available.
.PARAMETER ApprovalItems
No description available.
.PARAMETER Name
The work item name
.PARAMETER Completed
No description available.
.PARAMETER NumItems
The number of items in the work item
.PARAMETER Errors
No description available.
.PARAMETER Form
No description available.
.OUTPUTS

WorkItems<PSCustomObject>
#>


function Initialize-BetaWorkItems {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Id},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequesterId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${RequesterDisplayName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OwnerId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${OwnerName},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Created},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Modified},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("Finished", "Rejected", "Returned", "Expired", "Pending", "Canceled", "")]
        [PSCustomObject]
        ${State},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [ValidateSet("Unknown", "Generic", "Certification", "Remediation", "Delegation", "Approval", "ViolationReview", "Form", "PolicyViolation", "Challenge", "ImpactAnalysis", "Signoff", "Event", "ManualAction", "Test")]
        [PSCustomObject]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${RemediationItems},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject[]]
        ${ApprovalItems},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${Completed},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Int32]]
        ${NumItems},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${Errors},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Form}
    )

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


        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "requesterId" = ${RequesterId}
            "requesterDisplayName" = ${RequesterDisplayName}
            "ownerId" = ${OwnerId}
            "ownerName" = ${OwnerName}
            "created" = ${Created}
            "modified" = ${Modified}
            "description" = ${Description}
            "state" = ${State}
            "type" = ${Type}
            "remediationItems" = ${RemediationItems}
            "approvalItems" = ${ApprovalItems}
            "name" = ${Name}
            "completed" = ${Completed}
            "numItems" = ${NumItems}
            "errors" = ${Errors}
            "form" = ${Form}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to WorkItems<PSCustomObject>

.DESCRIPTION

Convert from JSON to WorkItems<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

WorkItems<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in BetaWorkItems
        $AllProperties = ("id", "requesterId", "requesterDisplayName", "ownerId", "ownerName", "created", "modified", "description", "state", "type", "remediationItems", "approvalItems", "name", "completed", "numItems", "errors", "form")
        foreach ($name in $JsonParameters.PsObject.Properties.Name) {
            if (!($AllProperties.Contains($name))) {
                throw "Error! JSON key '$name' not found in the properties: $($AllProperties)"
            }
        }

        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 "requesterId"))) { #optional property not found
            $RequesterId = $null
        } else {
            $RequesterId = $JsonParameters.PSobject.Properties["requesterId"].value
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "requesterId" = ${RequesterId}
            "requesterDisplayName" = ${RequesterDisplayName}
            "ownerId" = ${OwnerId}
            "ownerName" = ${OwnerName}
            "created" = ${Created}
            "modified" = ${Modified}
            "description" = ${Description}
            "state" = ${State}
            "type" = ${Type}
            "remediationItems" = ${RemediationItems}
            "approvalItems" = ${ApprovalItems}
            "name" = ${Name}
            "completed" = ${Completed}
            "numItems" = ${NumItems}
            "errors" = ${Errors}
            "form" = ${Form}
        }

        return $PSO
    }

}