Model/CreateDisk.ps1

#
# Storvix APIs
# List of all APIs accessible with the AiRE filer
# Version: 3.0.0
# Contact: support@storvix.eu
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

<#
.SYNOPSIS

No summary available.

.DESCRIPTION

No description available.

.PARAMETER Path
No description available.
.PARAMETER Type
No description available.
.PARAMETER Size
No description available.
.PARAMETER BlockSize
No description available.
.PARAMETER Compression
No description available.
.PARAMETER VarProfile
No description available.
.PARAMETER Policy
No description available.
.OUTPUTS

CreateDisk<PSCustomObject>
#>


function Initialize-CreateDisk {
    [CmdletBinding()]
    Param (
        [Parameter(Position = 0, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Path} = "{masterpool}/{diskname}",
        [Parameter(Position = 1, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Type} = "disk",
        [Parameter(Position = 2, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Size} = "1024",
        [Parameter(Position = 3, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${BlockSize} = "512",
        [Parameter(Position = 4, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Compression} = "lz4",
        [Parameter(Position = 5, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${VarProfile} = "none",
        [Parameter(Position = 6, ValueFromPipelineByPropertyName = $true)]
        [String]
        ${Policy} = "none"
    )

    Process {
        'Creating PSCustomObject: AiRE => CreateDisk' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug


        $PSO = [PSCustomObject]@{
            "path" = ${Path}
            "type" = ${Type}
            "size" = ${Size}
            "block_size" = ${BlockSize}
            "compression" = ${Compression}
            "profile" = ${VarProfile}
            "policy" = ${Policy}
        }


        return $PSO
    }
}

<#
.SYNOPSIS

Convert from JSON to CreateDisk<PSCustomObject>

.DESCRIPTION

Convert from JSON to CreateDisk<PSCustomObject>

.PARAMETER Json

Json object

.OUTPUTS

CreateDisk<PSCustomObject>
#>

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

    Process {
        'Converting JSON to PSCustomObject: AiRE => CreateDisk' | Write-Debug
        $PSBoundParameters | Out-DebugParameter | Write-Debug

        $JsonParameters = ConvertFrom-Json -InputObject $Json

        # check if Json contains properties not defined in CreateDisk
        $AllProperties = ("path", "type", "size", "block_size", "compression", "profile", "policy")
        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 "path"))) { #optional property not found
            $Path = $null
        } else {
            $Path = $JsonParameters.PSobject.Properties["path"].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 "size"))) { #optional property not found
            $Size = $null
        } else {
            $Size = $JsonParameters.PSobject.Properties["size"].value
        }

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

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

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

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

        $PSO = [PSCustomObject]@{
            "path" = ${Path}
            "type" = ${Type}
            "size" = ${Size}
            "block_size" = ${BlockSize}
            "compression" = ${Compression}
            "profile" = ${VarProfile}
            "policy" = ${Policy}
        }

        return $PSO
    }

}