Skip to main content

Check out Port for yourself ➜ 

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

{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"default": {
"myKey": "myValue"
}
}
}

Check out Port's API reference to learn more.

Terraform definition

resource "port_action" "myAction" {
# ...action properties
user_properties = {
object_props = {
"myObjectInput" = {
title = "My object input"
description = "My object input"
default = jsonencode({ "myKey" = "myValue" })
}
}
}
}

Validate object

Object validations support the following operators:

  • properties - defines the schema for object keys when present. Only the entire object can be marked as required via the action's top-level required array. A required array inside an object input is not supported.
  • additionalProperties - whether keys not defined in properties are allowed (boolean) or what type they should be (type definition).
  • patternProperties - which regex pattern should properties follow
Object validation limits

Port does not support making individual keys inside an object required. A required array defined inside an object-type input is not supported and will be rejected. You can only require the object input as a whole using the action's top-level required array.

Where supported, object validations follow the JSON schema model. See the JSON schema docs for available validations.

{
"myObjectInput": {
"title": "My object input",
"icon": "My icon",
"description": "My object input",
"type": "object",
"properties": {
"myNumberProp": { "type": "number" }
},
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "number" }
},
"additionalProperties": true
}
}