Skip to main content

Check out Port for yourself ➜ 

Enum

Enum is a data type used to define a named set of constant values.

💡 Common enum usage

The enum property type can be used to define a set of constant values, for example:

  • Deployment status: pending, in progress, success, failed.
  • Environments: production, staging, development.
  • Service health status: healthy, degraded, unhealthy, unkown, maintenance, etc.

API definition

Limit field

When creating a blueprint property of type Enum in the UI, use the limit field to define how many values users can select for that property.

In the property creation form, the limit field dropdown provides two options:

  • 1 value: Only one value can be selected.
  • List of values: Multiple values can be selected.

Selecting the list of values option will set the property's type to array in the JSON definition.

Limit field restriction

The limit field setting, whether it's 1 value or a list of values, is permanent and cannot be changed after the property is created. If you create a property with a single value limit, you won’t be able to change it later to allow multiple values.

To change the limit configuration after creation:

  1. Create a new property with the limit field set to a list of values.
  2. Use the migrate blueprint data feature to insert the data to the new property.
  3. Delete the old property.
  4. Rename the new property to the old property name (optional).
{
"myStringEnum": {
"title": "My enum",
"icon": "My icon",
"type": "string",
"enum": ["my-option-1", "my-option-2"],
"enumColors": {
"my-option-1": "red",
"my-option-2": "green"
}
}
}

Check out Port's API reference to learn more.

Terraform definition

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myEnumProp" = {
title = "My Enum"
required = false
enum = ["my-option-1", "my-option-2"]
enum_colors = {
"my-option-1" = "green"
"my-option-2" = "blue"
}
}
}
}
}

Pulumi definition

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Blueprint

blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties={
"string_props": {
"myEnumProp": {
"title": "My Enum",
"required": True,
"enum_colors": {
"my-option-1": "red",
"my-option-2": "green",
},
"enums": ["my-option-1", "my-option-2"]
}
}
},
relations={}
)

Available enum colors

Properties defined using enum can also include specific colors for the different values available in the property definition, the available enum colors are:

blue
turquoise
orange
purple
pink
yellow
green
red
darkGray
lightGray
bronze