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, you have two options:

{
"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