@@ -58,9 +58,8 @@ func (r *InstanceService) New(ctx context.Context, body InstanceNewParams, opts
5858 return res , err
5959}
6060
61- // Update mutable properties of a running instance. Currently supports updating
62- // only the environment variables referenced by existing credential policies,
63- // enabling secret/key rotation without instance restart.
61+ // Update mutable instance properties. TTL values are relative to when the update
62+ // is committed. Expiration updates are rejected after the current deadline passes.
6463func (r * InstanceService ) Update (ctx context.Context , id string , body InstanceUpdateParams , opts ... option.RequestOption ) (res * Instance , err error ) {
6564 opts = slices .Concat (r .Options , opts )
6665 if id == "" {
@@ -635,6 +634,9 @@ type Instance struct {
635634 ID string `json:"id" api:"required"`
636635 // Creation timestamp (RFC3339)
637636 CreatedAt time.Time `json:"created_at" api:"required" format:"date-time"`
637+ // Absolute expiration time, or null when automatic expiration is disabled.
638+ // Instance TTL is cleared on fork.
639+ ExpiresAt time.Time `json:"expires_at" api:"required" format:"date-time"`
638640 // OCI image reference
639641 Image string `json:"image" api:"required"`
640642 // Human-readable name
@@ -719,6 +721,7 @@ type Instance struct {
719721 JSON struct {
720722 ID respjson.Field
721723 CreatedAt respjson.Field
724+ ExpiresAt respjson.Field
722725 Image respjson.Field
723726 Name respjson.Field
724727 State respjson.Field
@@ -1409,6 +1412,9 @@ type InstanceNewParams struct {
14091412 // Disk I/O rate limit (e.g., "100MB/s", "500MB/s"). Defaults to proportional share
14101413 // based on CPU allocation if configured.
14111414 DiskIoBps param.Opt [string ] `json:"disk_io_bps,omitzero"`
1415+ // Absolute expiration time. Must be in the future and is mutually exclusive with
1416+ // ttl.
1417+ ExpiresAt param.Opt [time.Time ] `json:"expires_at,omitzero" format:"date-time"`
14121418 // Additional memory for hotplug (human-readable format like "3GB", "1G"). Omit to
14131419 // disable hotplug memory.
14141420 HotplugSize param.Opt [string ] `json:"hotplug_size,omitzero"`
@@ -1430,6 +1436,10 @@ type InstanceNewParams struct {
14301436 // out-of-tree kernel modules (e.g., NVIDIA vGPU drivers). Recommended for
14311437 // workloads that don't need kernel module compilation.
14321438 SkipKernelHeaders param.Opt [bool ] `json:"skip_kernel_headers,omitzero"`
1439+ // Relative lifetime from instance creation, in Go duration format. Use "0s" or
1440+ // omit both expiration fields to disable automatic expiration. Mutually exclusive
1441+ // with expires_at.
1442+ Ttl param.Opt [string ] `json:"ttl,omitzero"`
14331443 // Number of virtual CPUs
14341444 Vcpus param.Opt [int64 ] `json:"vcpus,omitzero"`
14351445 // Linux-only automatic standby policy based on active inbound TCP connections
@@ -1656,6 +1666,12 @@ func init() {
16561666}
16571667
16581668type InstanceUpdateParams struct {
1669+ // Absolute expiration time. Must be in the future and is mutually exclusive with
1670+ // ttl.
1671+ ExpiresAt param.Opt [time.Time ] `json:"expires_at,omitzero" format:"date-time"`
1672+ // Relative lifetime from when this update is committed, in Go duration format. Use
1673+ // "0s" to disable automatic expiration. Mutually exclusive with expires_at.
1674+ Ttl param.Opt [string ] `json:"ttl,omitzero"`
16591675 // Linux-only automatic standby policy based on active inbound TCP connections
16601676 // observed from the host conntrack table.
16611677 AutoStandby AutoStandbyPolicyParam `json:"auto_standby,omitzero"`
0 commit comments