Skip to content
Ona Docs

UpdateService

client.environments.automations.services.update(ServiceUpdateParams { id, metadata, spec, status } body, RequestOptionsoptions?): ServiceUpdateResponse
POST/gitpod.v1.EnvironmentAutomationService/UpdateService

Updates an automation service configuration.

Use this method to:

  • Modify service commands
  • Update triggers
  • Change runtime settings
  • Adjust dependencies

Examples

  • Update commands:

    Changes service start and ready commands.

    id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    spec:
      commands:
        start: "npm run start:dev"
        ready: "curl -s http://localhost:8080"
  • Update triggers:

    Modifies when the service starts.

    id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
    metadata:
      triggeredBy:
        trigger:
          - postDevcontainerStart: true
          - manual: true
ParametersExpand Collapse
body: ServiceUpdateParams { id, metadata, spec, status }
id?: string
formatuuid
metadata?: Metadata
description?: string | null
name?: string | null
minLength1
role?: ServiceRole | null
One of the following:
"SERVICE_ROLE_UNSPECIFIED"
"SERVICE_ROLE_DEFAULT"
"SERVICE_ROLE_EDITOR"
"SERVICE_ROLE_AI_AGENT"
"SERVICE_ROLE_SECURITY_AGENT"
triggeredBy?: TriggeredBy | null
trigger?: Array<AutomationTrigger { beforeSnapshot, manual, postDevcontainerStart, 3 more } >
beforeSnapshot?: boolean
manual?: boolean
postDevcontainerStart?: boolean
postEnvironmentStart?: boolean
postMachineStart?: boolean
prebuild?: boolean
spec?: Spec

Changing the spec of a service is a complex operation. The spec of a service can only be updated if the service is in a stopped state. If the service is running, it must be stopped first.

commands?: Commands | null
ready?: string | null
start?: string | null
stop?: string | null
env?: Array<EnvironmentVariableItem { name, value, valueFrom } >
name?: string

name is the environment variable name.

minLength1
value?: string

value is a literal string value.

valueFrom?: EnvironmentVariableSource { secretRef }

value_from specifies a source for the value.

secretRef: SecretRef { id }

secret_ref references a secret by ID.

id?: string

id is the UUID of the secret to reference.

formatuuid
readinessTimeout?: string

A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like “day” or “month”. It is related to Timestamp in that the difference between two Timestamp values is a Duration and it can be added or subtracted from a Timestamp. Range is approximately +-10,000 years.

Examples

Example 1: Compute Duration from two Timestamps in pseudo code.

 Timestamp start = ...;
 Timestamp end = ...;
 Duration duration = ...;

 duration.seconds = end.seconds - start.seconds;
 duration.nanos = end.nanos - start.nanos;

 if (duration.seconds < 0 && duration.nanos > 0) {
   duration.seconds += 1;
   duration.nanos -= 1000000000;
 } else if (duration.seconds > 0 && duration.nanos < 0) {
   duration.seconds -= 1;
   duration.nanos += 1000000000;
 }

Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.

 Timestamp start = ...;
 Duration duration = ...;
 Timestamp end = ...;

 end.seconds = start.seconds + duration.seconds;
 end.nanos = start.nanos + duration.nanos;

 if (end.nanos < 0) {
   end.seconds -= 1;
   end.nanos += 1000000000;
 } else if (end.nanos >= 1000000000) {
   end.seconds += 1;
   end.nanos -= 1000000000;
 }

Example 3: Compute Duration from datetime.timedelta in Python.

 td = datetime.timedelta(days=3, minutes=10)
 duration = Duration()
 duration.FromTimedelta(td)

JSON Mapping

In JSON format, the Duration type is encoded as a string rather than an object, where the string ends in the suffix “s” (indicating seconds) and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds. For example, 3 seconds with 0 nanoseconds should be encoded in JSON format as “3s”, while 3 seconds and 1 nanosecond should be expressed in JSON format as “3.000000001s”, and 3 seconds and 1 microsecond should be expressed in JSON format as “3.000001s”.

formatregex
runsOn?: RunsOn { docker, machine } | null
docker?: Docker { environment, image }
environment?: Array<string>
image?: string
minLength1
machine?: unknown

Machine runs the service/task directly on the VM/machine level.

status?: Status

Service status updates are only expected from the executing environment. As a client of this API you are not expected to provide this field. Updating this field requires the environmentservice:update_status permission.

failureMessage?: string | null
logUrl?: string | null
output?: Record<string, string>

setting an output field to empty string will unset it.

phase?: ServicePhase | null
One of the following:
"SERVICE_PHASE_UNSPECIFIED"
"SERVICE_PHASE_STARTING"
"SERVICE_PHASE_RUNNING"
"SERVICE_PHASE_STOPPING"
"SERVICE_PHASE_STOPPED"
"SERVICE_PHASE_FAILED"
"SERVICE_PHASE_DELETED"
session?: string | null
ReturnsExpand Collapse
ServiceUpdateResponse = unknown

UpdateService

import Gitpod from '@gitpod/sdk';

const client = new Gitpod({
  bearerToken: process.env['GITPOD_API_KEY'], // This is the default and can be omitted
});

const service = await client.environments.automations.services.update({
  id: 'd2c94c27-3b76-4a42-b88c-95a85e392c68',
  spec: { commands: { ready: 'curl -s http://localhost:8080', start: 'npm run start:dev' } },
});

console.log(service);
{}
Returns Examples
{}