Skip to main content

Check out Port for yourselfย 

Timer

Timer is a data type used to define an expiration date/lifespan of a specific entity.

๐Ÿ’ก Common timer usageโ€‹

The timer property type can be used to store the future expiration date of catalog entities and properties, for example:

  • Temporary development environment.
  • Countdown to next healthcheck.
  • Temporary cloud resources.
  • Add temporary permissions to resource.

In this live demo example, we can see the TTL timer property. ๐ŸŽฌ

API definitionโ€‹

{
"myTimerProp": {
"title": "My timer",
"icon": "My icon",
"description": "My timer property",
"type": "string",
"format": "timer",
"default": "2022-04-18T11:44:15.345Z"
}
}

Check out Port's API reference to learn more.

Terraform definitionโ€‹

resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myTimerProp" = {
title = "My timer"
icon = "My icon"
description = "My timer property"
format = "timer"
default = "2022-04-18T11:44:15.345Z"
}
}
}
}

Pulumi definitionโ€‹

"""A Python Pulumi program"""

import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesStringPropsArgs

blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
string_props={
"myTimerProp": BlueprintPropertiesStringPropsArgs(
title="My timer",
format="timer",
required=True,
)
}
),
relations={}
)

Exampleโ€‹

Here is an entity for a timerExample blueprint which has a timer property with the identifier timer.

In the example entity, an expiration datetime is specified:

  "identifier": "entityIdentifier",
"title": "Timer Example",
"icon": "Microservice",
"blueprint": "timerExample",
"properties": {
"timer": "2022-12-01T16:50:00+02:00"
},
"relations": {}

Looking at Port's UI, we can see that the timer we created expires in 2 hours:

Timer entity

After 2 hours pass, the property status will change to Expired, and an event of Timer Expired will be sent to the ChangeLog:

Timer entity expired

The timer expiration event will also appear in Port's audit log:

Timer Audit log

In order to notify about the timer expiration, the following notification body will be sent to the Webhook/Kafka topic configured in the blueprint's changelogDestination:

{
"context": {
"blueprint": "timerExample",
"entity": "entityIdentifier"
},
"action": "TIMER_EXPIRED",
"trigger": {
"at": "2022-12-01T16:50:00+02:00",
"by": {
"byPort": true,
"orgId": "org_example"
},
"origin": "API"
},
"resourceType": "entity",
"status": "SUCCESS"
}