Object
Object is a basic input for JSON data.
💡 Common object usage​
The object input type can be used to store any key/value based data, for example:
- Configurations
- Tags
- HTTP responses
- Dictionaries/Hash maps
In the live demo self-service hub page, we can see the Open terraform PR to add S3 bucket action whose policy
input is an object input. 🎬
API definition​
- Basic
- Select (Enum)
- Array
{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"default": {
"myKey": "myValue"
}
}
}
{
"myObjectSelectInput": {
"title": "My object select input",
"icon": "My icon",
"description": "My object select input",
"type": "object",
"enum": [
{
"myKey": 1
},
{
"myKey": 2
}
]
}
}
{
"myObjectArrayInput": {
"title": "My object array input",
"icon": "My icon",
"description": "My object array input",
"type": "array",
"items": {
"type": "object"
}
}
}
Check out Port's API reference to learn more.
Terraform definition​
- Basic
- Array
resource "port_action" "myAction" {
# ...action properties
user_properties = {
object_props = {
"myObjectInput" = {
title = "My object input"
description = "My object input"
default = jsonencode({ "myKey" = "myValue" })
}
}
}
}
resource "port_action" "myAction" {
# ...action properties
user_properties = {
array_props = {
"myObjectArrayInput" = {
title = "My object array input"
description = "My object array input"
object_items = {}
}
}
}
}
Validate object​
Object validations support the following operators:
properties
- which keys must appear and what their type should be;additionalProperties
- are keys not defined inproperties
allowed and what their type should be;patternProperties
- which regex pattern should properties follow
tip
Object validations follow the JSON schema model, refer to the JSON schema docs to learn about all of the available validations
- Basic
- Array
- Terraform - coming soon
{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"properties": {
"myRequiredProp": { "type": "number" }
},
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "number" }
},
"additionalProperties": true
}
}
{
"myObjectArrayInput": {
"title": "My object array input",
"icon": "My icon",
"description": "My object array input",
"type": "array",
"items": {
"type": "object",
"properties": {
"myRequiredProp": { "type": "number" }
},
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "number" }
},
"additionalProperties": true
}
}
}