Skip to main content

Check out Port for yourselfย 

Array

Array is a data type used to save lists of data.

๐Ÿ’ก Common array usageโ€‹

The array property type can be used to store any list of data, for example:

  • Used packages
  • Dependencies
  • Badges

In this live demo example, we can see the Monitor Tooling array property. ๐ŸŽฌ

API definitionโ€‹

{
"myArrayProp": {
"title": "My array",
"icon": "My icon",
"description": "My array property",
"type": "array",
"default": [1, 2, 3]
}
}

Check out Port's API reference to learn more.

Terraform definitionโ€‹

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
array_props = {
"myArrayProp" = {
title = "My array"
required = true
}
}
}
}
info

To set the type of an array property, you need to use the <type>_items property type. For example, to set an array of strings, you need to use the string_items property type.

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
array_props = {
"myArrayProp" = {
title = "My array"
required = true
string_items = {} # You can also set here default values
}
}
}
}

We currently support the following types of array items: string_items, number_items, boolean_items, object_items.

Pulumi definitionโ€‹

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertyArgs

blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
array_props={
"myArrayProp": BlueprintPropertyArgs(
title="My array", required=True,
)
}
),
relations=[]
)

Validate arrayโ€‹

Array validations support the following operators:

  • minItems
  • maxItems
  • uniqueItems
tip

Array validations follow the JSON schema model, refer to the JSON schema docs to learn about all of the available validations

{
"myArrayProp": {
"title": "My array",
"icon": "My icon",
"description": "My array property",
"type": "array",
"minItems": 0,
"maxItems": 5,
"uniqueItems": false
}
}