Model/SearchCriteria.ps1

#
# Identity Security Cloud V2025 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: v2025
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

Represents the search criteria for querying entitlements.

.PARAMETER Indices
A list of indices to search within. Must contain exactly one item, typically ""entitlements"".
.PARAMETER Filters
A map of filters applied to the search. Keys are filter names, and values are filter definitions.
.PARAMETER Query
No description available.
.PARAMETER QueryType
Specifies the type of query. Must be ""TEXT"" if `textQuery` is used.
.PARAMETER TextQuery
No description available.
.PARAMETER IncludeNested
Whether to include nested objects in the search results.
.PARAMETER Sort
Specifies the sorting order for the results.
.PARAMETER SearchAfter
Used for pagination to fetch results after a specific point.
.OUTPUTS

SearchCriteria<PSCustomObject>
#>


function Initialize-V2025SearchCriteria {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${Indices},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${Filters},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Query},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${QueryType},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${TextQuery},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${IncludeNested} = $false,
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${Sort},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String[]]
        ${SearchAfter}
    )

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

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


        $PSO = [PSCustomObject]@{
            "indices" = ${Indices}
            "filters" = ${Filters}
            "query" = ${Query}
            "queryType" = ${QueryType}
            "textQuery" = ${TextQuery}
            "includeNested" = ${IncludeNested}
            "sort" = ${Sort}
            "searchAfter" = ${SearchAfter}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to SearchCriteria<PSCustomObject>

.DESCRIPTION

Convert from JSON to SearchCriteria<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

SearchCriteria<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in V2025SearchCriteria
        $AllProperties = ("indices", "filters", "query", "queryType", "textQuery", "includeNested", "sort", "searchAfter")
        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 'indices' missing."
        }

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

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

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "indices" = ${Indices}
            "filters" = ${Filters}
            "query" = ${Query}
            "queryType" = ${QueryType}
            "textQuery" = ${TextQuery}
            "includeNested" = ${IncludeNested}
            "sort" = ${Sort}
            "searchAfter" = ${SearchAfter}
        }

        return $PSO
    }

}