Number
Number is a primitive data type used to save numeric data.
Common number usage
The number property type can be used to store any numeric data, for example:
- Number of critical vulnerabilities;
- Memory/storage allocations;
- Replica counts;
- Number of open issues;
- etc.
In this live demo example, we can see the JIRA Issues number property. 🎬
API definition
- Basic
- Enum
- Array
- Enum Array
{
  "myNumberProp": {
    "title": "My number",
    "icon": "My icon",
    "description": "My number property",
    "type": "number",
    "default": 7
  }
}
{
  "myNumberEnum": {
    "title": "My number enum",
    "icon": "My icon",
    "description": "My number enum",
    "type": "number",
    "enum": [1, 2, 3, 4]
  }
}
{
  "myNumberArray": {
    "title": "My number array",
    "icon": "My icon",
    "description": "My number array",
    "type": "array",
    "items": {
      "type": "number"
    }
  }
}
{
  "myNumberArray": {
    "title": "My number enum array",
    "icon": "My icon",
    "description": "My number enum array",
    "type": "array",
    "items": {
      "type": "number",
      "enum": [1, 2, 3, 4],
      "enumColors": {
        "1": "red",
        "2": "green",
        "3": "blue"
      }
    }
  }
}
Check out Port's API reference to learn more.
Terraform definition
- Basic
- Enum
- Array
resource "port_blueprint" "myBlueprint" {
  # ...blueprint properties
  properties = {
    number_props = {
      "myNumberProp" = {
        title       = "My number"
        description = "My number property"
        default     = 7
      }
    }
  }
}
resource "port_blueprint" "myBlueprint" {
  # ...blueprint properties
  properties = {
    number_props = {
      "myNumberProp" = {
        title       = "My number"
        description = "My number property"
        enum        = [1, 2, 3, 4]
      }
    }
  }
}
resource "port_blueprint" "myBlueprint" {
  # ...blueprint properties
  properties = {
    "myNumberArray" = {
      title        = "My number array"
      description  = "My number array"
      number_items = {}
    }
    "myNumberArrayWithDefault" = {
      title       = "My number array with default"
      description = "My number array"
      number_items = {
        default = [1, 2, 3, 4]
      }
    }
  }
}
Pulumi definition
- Basic
- Python
- TypeScript
- JavaScript
- GO
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesNumberPropsArgs
blueprint = Blueprint(
    "myBlueprint",
    identifier="myBlueprint",
    title="My Blueprint",
    properties=BlueprintPropertiesArgs(
        number_props={
            "myNumberProp": BlueprintPropertiesNumberPropsArgs(
                title="My number", required=False,
            )
        },
    ),
    relations={}
)
import * as pulumi from "@pulumi/pulumi";
import * as port from "@port-labs/port";
export const blueprint = new port.Blueprint("myBlueprint", {
  identifier: "myBlueprint",
  title: "My Blueprint",
  properties: {
    numberProps: {
      myNumberProp: {
        title: "My number",
        required: false,
      },
    },
  },
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
  title: "My Blueprint",
  identifier: "myBlueprint",
  properties: {
    numberProps: {
      myNumberProp: {
        title: "My number",
        required: false,
      },
    },
  },
  relations: {},
});
exports.title = entity.title;
package main
import (
	"github.com/port-labs/pulumi-port/sdk/v2/go/port"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		blueprint, err := port.NewBlueprint(ctx, "myBlueprint", &port.BlueprintArgs{
			Identifier: pulumi.String("myBlueprint"),
			Title:      pulumi.String("My Blueprint"),
			Properties: port.BlueprintPropertiesArgs{
				NumberProps: port.BlueprintPropertiesNumberPropsMap{
					"myNumberProp": port.BlueprintPropertiesNumberPropsArgs{
						Title:    pulumi.String("My number"),
						Required: pulumi.Bool(false),
					},
				},
			},
		})
		ctx.Export("blueprint", blueprint.Title)
		if err != nil {
			return err
		}
		return nil
	})
}
Validate number
Number validations support the following operators:
- range
Ranges of numbers are specified using a combination of the minimum and maximum keywords, (or exclusiveMinimum and exclusiveMaximum for expressing exclusive range).
If x is the value being validated, the following must hold true:
- x ≥ minimum
- x > exclusiveMinimum
- x ≤ maximum
- x < exclusiveMaximum
- Basic
- Array
- Terraform
{
  "myNumberProp": {
    "title": "My number",
    "icon": "My icon",
    "description": "My number property",
    "type": "number",
    "minimum": 0,
    "maximum": 50
  }
}
{
  "myNumberArray": {
    "title": "My number array",
    "icon": "My icon",
    "description": "My number array",
    "type": "array",
    "items": {
      "type": "number",
      "exclusiveMinimum": 0,
      "exclusiveMaximum": 50
    }
  }
}
resource "port_blueprint" "myBlueprint" {
  properties = {
    "number_props" = {
      "myNumberProp" = {
        title       = "My number"
        icon        = "My icon"
        description = "My number property"
        minimum     = 0
        maximum     = 50
      }
    }
  }
}