Skip to main content

Check out Port for yourselfย 

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.

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
}
}