日期时间
Datetime 是一种用于引用日期和时间的数据类型。
💡 常用日期时间 Usage
例如,datetime 属性类型可被用来存储任何日期和时间:
- 部署时间
- 发布时间
- 最后事件日期
- 创建时间戳
在live demo 这个示例中,我们可以看到 "最后更新 "日期时间属性。
应用程序接口定义
- Basic
- Array
{
"myDatetimeProp": {
"title": "My datetime",
"icon": "My icon",
"description": "My datetime property",
"type": "string",
"format": "date-time",
"default": "2022-04-18T11:44:15.345Z"
}
}
{
"myDatetimeArray": {
"title": "My datetime array",
"icon": "My icon",
"description": "My datetime array",
"type": "array",
"items": {
"type": "string",
"format": "date-time"
}
}
}
Check out Port's API reference to learn more.
Terraform 定义
- Basic
- Array
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
string_props = {
"myDatetimeProp" = {
title = "My datetime"
icon = "My icon"
description = "My datetime property"
format = "date-time"
default = "2022-04-18T11:44:15.345Z"
}
}
}
}
resource "port_blueprint" "myBlueprint" {
# ...blueprint properties
properties = {
array_props = {
"myDatetimeArray" = {
title = "My datetime array"
icon = "My icon"
required = false
type = "array"
string_items = {
format = "date-time"
}
}
}
}
}
Pulumi 的定义
- Basic
- Enum
- Array - coming soon
- Python
- TypeScript
- JavaScript
- GO
"""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={
"myDatetimeProp": BlueprintPropertiesStringPropsArgs(
title="My email",
format="date-time",
Required=True,
)
}
),
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: {
string_props: {
myDatetimeProp: {
title: "My datetime",
format: "date-time",
required: true,
},
},
},
});
"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: {
string_props: {
myDatetimeProp: {
title: "My datetime",
format: "date-time",
required: true,
},
},
},
relations: {},
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/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{
StringProps: port.BlueprintPropertiesStringPropsMap{
"myDatetimeProp": &port.BlueprintPropertiesStringPropsArgs{
Title: pulumi.String("My datetime"),
Format: pulumi.String("date-time"),
Required: pulumi.Bool(false),
},
},
},
})
ctx.Export("blueprint", blueprint.Title)
if err != nil {
return err
}
return nil
})
}
- Python
- TypeScript
- JavaScript
- GO
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesStringPropsArgs,BlueprintPropertiesArgs
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
string_props={
"myDatetimeProp": BlueprintPropertiesStringPropsArgs(
title="My datetime",
required=True,
format="date-time",
enums=["2022-04-18T11:44:15.345Z", "2022-05-18T11:44:15.345Z"],
enum_colors={
"2022-04-18T11:44:15.345Z": "red",
"2022-05-18T11:44:15.345Z": "green"
},
)
}
),
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: {
stringProps: {
myDatetimeProp: {
title: "My datetime",
format: "date-time",
required: true,
enums: ["2022-04-18T11:44:15.345Z", "2022-05-18T11:44:15.345Z"],
enumColors: {
"2022-04-18T11:44:15.345Z": "red",
"2022-05-18T11:44:15.345Z": "green",
},
},
},
});
"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: {
stringProps: {
myDatetimeProp: {
title: "My datetime",
format: "date-time",
required: true,
enums: ["2022-04-18T11:44:15.345Z", "2022-05-18T11:44:15.345Z"],
enumColors: {
"2022-04-18T11:44:15.345Z": "red",
"2022-05-18T11:44:15.345Z": "green",
},
},
},
relations: {},
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/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{
StringProps: port.BlueprintPropertiesStringPropsMap{
"myDatetimeProp": &port.BlueprintPropertiesStringPropsArgs{
Title: pulumi.String("My datetime"),
Format: pulumi.String("date-time"),
Required: pulumi.Bool(false),
Enums: pulumi.StringArray{
pulumi.String("2022-04-18T11:44:15.345Z"),
pulumi.String("2022-05-18T11:44:15.345Z"),
},
EnumColors: pulumi.StringMap{
"2022-04-18T11:44:15.345Z": pulumi.String("red"),
"2022-05-18T11:44:15.345Z": pulumi.String("green"),
},
},
},
},
})
ctx.Export("blueprint", blueprint.Title)
if err != nil {
return err
}
return nil
})
}