Hi everyone,
I am currently working on a connector file for a target system with a REST API. The API exposes Create and Update endpoints that require handling nested JSON structures.
My question is straightforward: Is there a way to pass a property inside a class, which acts as a reference to another class, as a complete object to a PowerShell cmdlet?
Example Scenario
Consider we have two classes, ClassA and ClassB:
Class A: string id string referenceToB int someValue
Class B: string id int someOtherValue
I would assume the cmdlet definition for the Create operation on
ClassA would look like this:param(
[string] $id,
[string] $referenceToB,
[int] $someValue
)
However, the JSON payload required by the REST API should look like this:
{
"id": "iamA",
"ClassB": {
"id": "iamB",
"someOtherValue": 1
},
"someValue": 2
}
Current Setup
At the moment, I have two classes defined in the XML configuration file, where one class references the other. However, I am unsure how this relationship is evaluated during synchronization and how it is passed to the corresponding cmdlet.
Questions
- Is there any documentation that explains how values defined in the connector file are passed as parameters to cmdlets in general?
- How can I manipulate these values before they are passed to possibly pass Class B as complete Object, Map, etc.?
Any insights or pointers would be greatly appreciated!