Model/Credential.ps1

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

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

A credential, such as an API key or access key, discovered from a connected source.

.PARAMETER Name
Name of the Object
.PARAMETER Description
Description of the credential.
.PARAMETER Status
The credential status reported by the source.
.PARAMETER NativeIdentity
The credential's unique identifier on the source.
.PARAMETER Environment
The environment the credential belongs to.
.PARAMETER Source
No description available.
.PARAMETER Resource
No description available.
.PARAMETER DatasetId
The ID of the source dataset the credential was retrieved from.
.PARAMETER Type
The credential type.
.PARAMETER Scope
The scope the source reports for the credential.
.PARAMETER ExpiresAt
The date and time the credential expires.
.PARAMETER LastUsedAt
The date and time the credential was last used.
.PARAMETER Owners
No description available.
.PARAMETER Attributes
A map of curated credential attributes.
.PARAMETER ConnectorAttributes
A map of attributes sourced from the connector during aggregation.
.PARAMETER ManuallyEdited
Indicates if the credential has been manually edited.
.OUTPUTS

Credential<PSCustomObject>
#>


function Initialize-Credential {
    [CmdletBinding()]
    Param (
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Name},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Description},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Status},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${NativeIdentity},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Environment},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Source},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Resource},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${DatasetId},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Type},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Scope},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${ExpiresAt},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[System.DateTime]]
        ${LastUsedAt},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [PSCustomObject]
        ${Owners},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${Attributes},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Collections.Hashtable]
        ${ConnectorAttributes},
        [Parameter(ValueFromPipelineByPropertyName = $true)]
        [System.Nullable[Boolean]]
        ${ManuallyEdited} = $false
    )

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


        $PSO = [PSCustomObject]@{
            "name" = ${Name}
            "description" = ${Description}
            "status" = ${Status}
            "nativeIdentity" = ${NativeIdentity}
            "environment" = ${Environment}
            "source" = ${Source}
            "resource" = ${Resource}
            "datasetId" = ${DatasetId}
            "type" = ${Type}
            "scope" = ${Scope}
            "expiresAt" = ${ExpiresAt}
            "lastUsedAt" = ${LastUsedAt}
            "owners" = ${Owners}
            "attributes" = ${Attributes}
            "connectorAttributes" = ${ConnectorAttributes}
            "manuallyEdited" = ${ManuallyEdited}
        }

        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to Credential<PSCustomObject>

.DESCRIPTION

Convert from JSON to Credential<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

Credential<PSCustomObject>
#>

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

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

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in Credential
        $AllProperties = ("id", "name", "created", "modified", "description", "status", "nativeIdentity", "environment", "source", "resource", "datasetId", "type", "scope", "expiresAt", "lastUsedAt", "owners", "attributes", "connectorAttributes", "manuallyEdited")
        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 'name' missing."
        }

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) {
            throw "Error! JSON cannot be serialized due to the required property 'name' missing."
        } else {
            $Name = $JsonParameters.PSobject.Properties["name"].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 "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 "status"))) { #optional property not found
            $Status = $null
        } else {
            $Status = $JsonParameters.PSobject.Properties["status"].value
        }

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

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

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

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

        if (!([bool]($JsonParameters.PSobject.Properties.name -match "datasetId"))) { #optional property not found
            $DatasetId = $null
        } else {
            $DatasetId = $JsonParameters.PSobject.Properties["datasetId"].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 "scope"))) { #optional property not found
            $Scope = $null
        } else {
            $Scope = $JsonParameters.PSobject.Properties["scope"].value
        }

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

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

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

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

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

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

        $PSO = [PSCustomObject]@{
            "id" = ${Id}
            "name" = ${Name}
            "created" = ${Created}
            "modified" = ${Modified}
            "description" = ${Description}
            "status" = ${Status}
            "nativeIdentity" = ${NativeIdentity}
            "environment" = ${Environment}
            "source" = ${Source}
            "resource" = ${Resource}
            "datasetId" = ${DatasetId}
            "type" = ${Type}
            "scope" = ${Scope}
            "expiresAt" = ${ExpiresAt}
            "lastUsedAt" = ${LastUsedAt}
            "owners" = ${Owners}
            "attributes" = ${Attributes}
            "connectorAttributes" = ${ConnectorAttributes}
            "manuallyEdited" = ${ManuallyEdited}
        }

        return $PSO
    }

}