Skip to content
Ona Docs

UpdateService

client.Environments.Automations.Services.Update(ctx, body) (*EnvironmentAutomationServiceUpdateResponse, error)
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 EnvironmentAutomationServiceUpdateParams
ID param.Field[string]Optional
formatuuid
Description stringOptional
Name stringOptional
minLength1
Role ServiceRoleOptional
One of the following:
const ServiceRoleUnspecified ServiceRole = "SERVICE_ROLE_UNSPECIFIED"
const ServiceRoleDefault ServiceRole = "SERVICE_ROLE_DEFAULT"
const ServiceRoleEditor ServiceRole = "SERVICE_ROLE_EDITOR"
const ServiceRoleAIAgent ServiceRole = "SERVICE_ROLE_AI_AGENT"
const ServiceRoleSecurityAgent ServiceRole = "SERVICE_ROLE_SECURITY_AGENT"
TriggeredBy EnvironmentAutomationServiceUpdateParamsMetadataTriggeredByOptional
Trigger []AutomationTriggerOptional
BeforeSnapshot boolOptional
Manual boolOptional
PostDevcontainerStart boolOptional
PostEnvironmentStart boolOptional
PostMachineStart boolOptional
Prebuild boolOptional

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 EnvironmentAutomationServiceUpdateParamsSpecCommandsOptional
Ready stringOptional
Start stringOptional
Stop stringOptional
Name stringOptional

name is the environment variable name.

minLength1
Value stringOptional

value is a literal string value.

ValueFrom EnvironmentVariableSourceOptional

value_from specifies a source for the value.

SecretRef SecretRef

secret_ref references a secret by ID.

ID stringOptional

id is the UUID of the secret to reference.

formatuuid
ReadinessTimeout stringOptional

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 RunsOnOptional
Docker RunsOnDockerOptional
Environment []stringOptional
Image stringOptional
minLength1
Machine unknownOptional

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

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 stringOptional
LogURL stringOptional
Output map[string, string]Optional

setting an output field to empty string will unset it.

Phase ServicePhaseOptional
One of the following:
const ServicePhaseUnspecified ServicePhase = "SERVICE_PHASE_UNSPECIFIED"
const ServicePhaseStarting ServicePhase = "SERVICE_PHASE_STARTING"
const ServicePhaseRunning ServicePhase = "SERVICE_PHASE_RUNNING"
const ServicePhaseStopping ServicePhase = "SERVICE_PHASE_STOPPING"
const ServicePhaseStopped ServicePhase = "SERVICE_PHASE_STOPPED"
const ServicePhaseFailed ServicePhase = "SERVICE_PHASE_FAILED"
const ServicePhaseDeleted ServicePhase = "SERVICE_PHASE_DELETED"
Session stringOptional
ReturnsExpand Collapse
type EnvironmentAutomationServiceUpdateResponse interface{…}

UpdateService

package main

import (
  "context"
  "fmt"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  service, err := client.Environments.Automations.Services.Update(context.TODO(), gitpod.EnvironmentAutomationServiceUpdateParams{
    ID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
    Spec: gitpod.F(gitpod.EnvironmentAutomationServiceUpdateParamsSpec{
      Commands: gitpod.F(gitpod.EnvironmentAutomationServiceUpdateParamsSpecCommands{
        Ready: gitpod.F("curl -s http://localhost:8080"),
        Start: gitpod.F("npm run start:dev"),
      }),
    }),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", service)
}
{}
Returns Examples
{}