Model/AccessUsers.ps1
# # Proxmox VE # Generated module to access all Proxmox VE Api Endpoints # Version: 0.3 # Contact: amna.wolf@gmail.com # Generated by OpenAPI Generator: https://openapi-generator.tech # <# .SYNOPSIS No summary available. .DESCRIPTION No description available. .PARAMETER Email No description available. .PARAMETER Comment No description available. .PARAMETER Expire No description available. .PARAMETER Lastname No description available. .PARAMETER Firstname No description available. .PARAMETER Keys No description available. .PARAMETER Tokens No description available. .PARAMETER Groups No description available. .PARAMETER Enable No description available. .OUTPUTS AccessUsers<PSCustomObject> #> function Initialize-PVEAccessUsers { [CmdletBinding()] Param ( [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${Email}, [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${Comment}, [Parameter(ValueFromPipelineByPropertyName = $true)] [System.Nullable[Int32]] ${Expire}, [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${Lastname}, [Parameter(ValueFromPipelineByPropertyName = $true)] [String] ${Firstname}, [Parameter(ValueFromPipelineByPropertyName = $true)] [ValidatePattern("[0-9a-zA-Z!=]{0,4096}")] [String] ${Keys}, [Parameter(ValueFromPipelineByPropertyName = $true)] [PSCustomObject] ${Tokens}, [Parameter(ValueFromPipelineByPropertyName = $true)] [String[]] ${Groups}, [Parameter(ValueFromPipelineByPropertyName = $true)] [System.Nullable[Int32]] ${Enable} ) Process { 'Creating PSCustomObject: ProxmoxPVE => PVEAccessUsers' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug if (!$Email -and $Email.length -gt 254) { throw "invalid value for 'Email', the character length must be smaller than or equal to 254." } if (!$Comment -and $Comment.length -gt 2048) { throw "invalid value for 'Comment', the character length must be smaller than or equal to 2048." } if (!$Lastname -and $Lastname.length -gt 1024) { throw "invalid value for 'Lastname', the character length must be smaller than or equal to 1024." } if (!$Firstname -and $Firstname.length -gt 1024) { throw "invalid value for 'Firstname', the character length must be smaller than or equal to 1024." } if ($Enable -and $Enable -gt 1) { throw "invalid value for 'Enable', must be smaller than or equal to 1." } if ($Enable -and $Enable -lt 0) { throw "invalid value for 'Enable', must be greater than or equal to 0." } $DisplayNameMapping =@{ "Email"="email"; "Comment"="comment"; "Expire"="expire"; "Lastname"="lastname"; "Firstname"="firstname"; "Keys"="keys"; "Tokens"="tokens"; "Groups"="groups"; "Enable"="enable" } $OBJ = @{} foreach($parameter in $PSBoundParameters.Keys){ #If Specifield map the Display name back $OBJ.($DisplayNameMapping.($parameter)) = "$PSBoundParameters.$parameter" } $PSO = [PSCustomObject]$OBJ return $PSO } } <# .SYNOPSIS Convert from JSON to AccessUsers<PSCustomObject> .DESCRIPTION Convert from JSON to AccessUsers<PSCustomObject> .PARAMETER Json Json object .OUTPUTS AccessUsers<PSCustomObject> #> function ConvertFrom-PVEJsonToAccessUsers { Param( [AllowEmptyString()] [string]$Json ) Process { 'Converting JSON to PSCustomObject: ProxmoxPVE => PVEAccessUsers' | Write-Debug $PSBoundParameters | Out-DebugParameter | Write-Debug $JsonParameters = ConvertFrom-Json -InputObject $Json # check if Json contains properties not defined in PVEAccessUsers $AllProperties = ("email", "comment", "expire", "lastname", "firstname", "keys", "tokens", "groups", "enable") 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 "email"))) { #optional property not found $Email = $null } else { $Email = $JsonParameters.PSobject.Properties["email"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "comment"))) { #optional property not found $Comment = $null } else { $Comment = $JsonParameters.PSobject.Properties["comment"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "expire"))) { #optional property not found $Expire = $null } else { $Expire = $JsonParameters.PSobject.Properties["expire"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "lastname"))) { #optional property not found $Lastname = $null } else { $Lastname = $JsonParameters.PSobject.Properties["lastname"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "firstname"))) { #optional property not found $Firstname = $null } else { $Firstname = $JsonParameters.PSobject.Properties["firstname"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "keys"))) { #optional property not found $Keys = $null } else { $Keys = $JsonParameters.PSobject.Properties["keys"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "tokens"))) { #optional property not found $Tokens = $null } else { $Tokens = $JsonParameters.PSobject.Properties["tokens"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "groups"))) { #optional property not found $Groups = $null } else { $Groups = $JsonParameters.PSobject.Properties["groups"].value } if (!([bool]($JsonParameters.PSobject.Properties.name -match "enable"))) { #optional property not found $Enable = $null } else { $Enable = $JsonParameters.PSobject.Properties["enable"].value } $PSO = [PSCustomObject]@{ "email" = ${Email} "comment" = ${Comment} "expire" = ${Expire} "lastname" = ${Lastname} "firstname" = ${Firstname} "keys" = ${Keys} "tokens" = ${Tokens} "groups" = ${Groups} "enable" = ${Enable} } return $PSO } } |