Skip to main content

Object

Object is a data type used to save object definitions in JSON.

💡 Common object usage​

The object property type can be used to store any key/value based data, for example:

  • Configurations;
  • Tags;
  • HTTP responses;
  • Dictionaries/Hash maps;
  • etc.

In this live demo example, we can see the Tags object property. 🎬

API definition​

{
"myObjectProp": {
"title": "My object",
"icon": "My icon",
"description": "My object property",
"type": "object",
"default": {
"myKey": "myValue"
}
}
}

Check out Port's API reference to learn more.

Terraform definition​

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
object_props = {
"myObjectProp" = {
title = "My object"
icon = "My icon"
description = "My object property"
default = jsonencode({"myKey" = "myValue"})
}
}
}
}

Pulumi definition​

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesObjectPropsArgs

blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
object_props=BlueprintPropertiesObjectPropsArgs(
title="My object", required=False
)
),
relations={},
)

Validate object​

Object validations support the following operators:

  • properties - which keys must appear and what their type should be;
  • additionalProperties - are keys not defined in properties 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

{
"myObjectProp": {
"title": "My object",
"icon": "My icon",
"description": "My object property",
"type": "object",
"properties": {
"myRequiredProp": { "type": "number" }
},
"patternProperties": {
"^S_": { "type": "string" },
"^I_": { "type": "number" }
},
"additionalProperties": true
}
}