Skip to content
Ona Docs

UpdateService

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
Body ParametersJSONExpand Collapse
id: optional string
formatuuid
metadata: optional object { description, name, role, triggeredBy }
description: optional string
name: optional string
minLength1
role: optional ServiceRole
One of the following:
"SERVICE_ROLE_UNSPECIFIED"
"SERVICE_ROLE_DEFAULT"
"SERVICE_ROLE_EDITOR"
"SERVICE_ROLE_AI_AGENT"
"SERVICE_ROLE_SECURITY_AGENT"
triggeredBy: optional object { trigger }
trigger: optional array of AutomationTrigger { beforeSnapshot, manual, postDevcontainerStart, 3 more }
beforeSnapshot: optional boolean
manual: optional boolean
postDevcontainerStart: optional boolean
postEnvironmentStart: optional boolean
postMachineStart: optional boolean
prebuild: optional boolean
spec: optional object { commands, env, readinessTimeout, runsOn }

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: optional object { ready, start, stop }
ready: optional string
start: optional string
stop: optional string
env: optional array of EnvironmentVariableItem { name, value, valueFrom }
name: optional string

name is the environment variable name.

minLength1
value: optional string

value is a literal string value.

valueFrom: optional EnvironmentVariableSource { secretRef }

value_from specifies a source for the value.

secretRef: SecretRef { id }

secret_ref references a secret by ID.

id: optional string

id is the UUID of the secret to reference.

formatuuid
readinessTimeout: optional 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: optional RunsOn { docker, machine }
docker: optional object { environment, image }
environment: optional array of string
image: optional string
minLength1
machine: optional unknown

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

status: optional object { failureMessage, logUrl, output, 2 more }

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: optional string
logUrl: optional string
output: optional map[string]

setting an output field to empty string will unset it.

phase: optional ServicePhase
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: optional string

UpdateService

curl https://app.gitpod.io/api/gitpod.v1.EnvironmentAutomationService/UpdateService \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $GITPOD_API_KEY" \
    -d '{}'
{}
Returns Examples
{}