lib/Classes/Public/TMActionParameters.ps1

#Example JSON Input
<#
  {
    "desc": "",
    "type": "string",
    "value": "True",
    "context": "USER_DEF",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "",
    "paramName": "AllowInsecureSSL",
    "description": "Allow bypassing untrusted ssl certificates."
  },
  {
    "desc": "",
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "DeviceHostname",
    "description": "Hostname of the Device Record",
    "fieldLabel": "Network - Hostname"
  },
  {
    "desc": "",
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "assetName",
    "paramName": "DeviceName",
    "description": "Name of the TM Asset Record",
    "fieldLabel": "Name"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "TargetComputeContainer",
    "description": "Compute Container to migrate the VM to",
    "fieldLabel": "Target Compute Container"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "TargetDatastore",
    "description": "Datastore to migrate the VM to",
    "fieldLabel": "Target Datastore"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "TargetFolder",
    "description": "Folder to migrate the VM to",
    "fieldLabel": "Target Folder"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "TargetNetwork",
    "description": "Network to migrate the VM to",
    "fieldLabel": "Target Network"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "customN",
    "paramName": "TargetvCenter",
    "description": "vCenter Server to migrate the VM to",
    "fieldLabel": "Target vCenter"
  },
  {
    "type": "string",
    "value": "",
    "context": "DEVICE",
    "encoded": false,
    "invalid": false,
    "readonly": false,
    "required": false,
    "fieldName": "custom5",
    "paramName": "ZertoServer",
    "description": "Zerto Server to migrate the VM with"
  }
#>



class TMActionParameters {
    [String]$type         # 'should be a class of it's own
    [Int]$order
    [String]$paramName
    [String]$description
    [psobject]$value
    [String]$context
    [bool]$required
    [bool]$encoded
    [bool]$invalid
    [String]$fieldName
    [String]$fieldLabel
    [bool]$readonly
    # [bool]$Prompt

    TMActionParameters() {}

    TMActionParameters([String]$_json) {
        $this.paramName = ($_json | ConvertFrom-Json).paramName
    }

    TMActionParameters([PsCustomObject]$_item) {
        $this.paramName = $_item.paramName
        $this.context = $_item.context
        $this.description = $_item.description ?? $_item.desc
        $this.fieldName = $_item.fieldName
        $this.fieldLabel = $_item.fieldLabel ?? ''
        $this.order = $_item.order ?? 0
        $this.readonly = $_item.readonly
        $this.required = $_item.required
        $this.type = $_item.type
        $this.value = $_item.value
        $this.encoded = $_item.encoded
        $this.invalid = $_item.invalid
        # $this.prompt = $this.prompt ?? ($_item.paramName -like 'get_')
    }
}