Skip to content
Ona Docs

ListServices

client.environments.automations.services.list(ServiceListParams { token, pageSize, filter, pagination } params, RequestOptionsoptions?): ServicesPage<Service { id, environmentId, metadata, 2 more } >
POST/gitpod.v1.EnvironmentAutomationService/ListServices

Lists automation services with optional filtering.

Use this method to:

  • View all services in an environment
  • Filter services by reference
  • Monitor service status

Examples

  • List environment services:

    Shows all services for an environment.

    filter:
      environmentIds: ["07e03a28-65a5-4d98-b532-8ea67b188048"]
    pagination:
      pageSize: 20
  • Filter by reference:

    Lists services matching specific references.

    filter:
      references: ["web-server", "database"]
    pagination:
      pageSize: 20
ParametersExpand Collapse
params: ServiceListParams { token, pageSize, filter, pagination }
token?: string

Query param

pageSize?: number

Query param

maximum100
minimum0
filter?: Filter

Body param: filter contains the filter options for listing services

environmentIds?: Array<string>

environment_ids filters the response to only services of these environments

references?: Array<string>

references filters the response to only services with these references

roles?: Array<ServiceRole>

roles filters the response to only services with these roles

One of the following:
"SERVICE_ROLE_UNSPECIFIED"
"SERVICE_ROLE_DEFAULT"
"SERVICE_ROLE_EDITOR"
"SERVICE_ROLE_AI_AGENT"
"SERVICE_ROLE_SECURITY_AGENT"
serviceIds?: Array<string>

service_ids filters the response to only services with these IDs

ReturnsExpand Collapse
Service { id, environmentId, metadata, 2 more }
id: string
formatuuid
environmentId?: string
formatuuid
metadata?: ServiceMetadata { createdAt, creator, description, 4 more }
createdAt?: string

created_at is the time the service was created.

formatdate-time
creator?: Subject { id, principal }

creator describes the principal who created the service.

id?: string

id is the UUID of the subject

formatuuid
principal?: Principal

Principal is the principal of the subject

One of the following:
"PRINCIPAL_UNSPECIFIED"
"PRINCIPAL_ACCOUNT"
"PRINCIPAL_USER"
"PRINCIPAL_RUNNER"
"PRINCIPAL_ENVIRONMENT"
"PRINCIPAL_SERVICE_ACCOUNT"
"PRINCIPAL_RUNNER_MANAGER"
description?: string

description is a user-facing description for the service. It can be used to provide context and documentation for the service.

name?: string

name is a user-facing name for the service. Unlike the reference, this field is not unique, and not referenced by the system. This is a short descriptive name for the service.

minLength1
reference?: string

reference is a user-facing identifier for the service which must be unique on the environment. It is used to express dependencies between services, and to identify the service in user interactions (e.g. the CLI).

role specifies the intended role or purpose of the service.

One of the following:
"SERVICE_ROLE_UNSPECIFIED"
"SERVICE_ROLE_DEFAULT"
"SERVICE_ROLE_EDITOR"
"SERVICE_ROLE_AI_AGENT"
"SERVICE_ROLE_SECURITY_AGENT"
triggeredBy?: Array<AutomationTrigger { beforeSnapshot, manual, postDevcontainerStart, 3 more } >

triggered_by is a list of trigger that start the service.

beforeSnapshot?: boolean
manual?: boolean
postDevcontainerStart?: boolean
postEnvironmentStart?: boolean
postMachineStart?: boolean
prebuild?: boolean
spec?: ServiceSpec { commands, desiredPhase, env, 4 more }
commands?: Commands { ready, start, stop }

commands contains the commands to start, stop and check the readiness of the service

ready?: string

ready is an optional command that is run repeatedly until it exits with a zero exit code. If set, the service will first go into a Starting phase, and then into a Running phase once the ready command exits with a zero exit code.

start?: string

start is the command to start and run the service. If start exits, the service will transition to the following phase:

  • Stopped: if the exit code is 0
  • Failed: if the exit code is not 0 If the stop command is not set, the start command will receive a SIGTERM signal when the service is requested to stop. If it does not exit within 2 minutes, it will receive a SIGKILL signal.
minLength1
stop?: string

stop is an optional command that runs when the service is requested to stop. If set, instead of sending a SIGTERM signal to the start command, the stop command will be run. Once the stop command exits, the start command will receive a SIGKILL signal. If the stop command exits with a non-zero exit code, the service will transition to the Failed phase. If the stop command does not exit within 2 minutes, a SIGKILL signal will be sent to both the start and stop commands.

desiredPhase?: ServicePhase

desired_phase is the phase the service should be in. Used to start or stop the service.

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"
env?: Array<EnvironmentVariableItem { name, value, valueFrom } >

env specifies environment variables for the service.

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

readiness_timeout is the maximum duration a service may remain in the Starting phase while readiness checks run. 0s disables the timeout.

formatregex
runsOn?: RunsOn { docker, machine }

runs_on specifies the environment the service should run on.

docker?: Docker { environment, image }
environment?: Array<string>
image?: string
minLength1
machine?: unknown

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

session?: string

session should be changed to trigger a restart of the service. If a service exits it will not be restarted until the session is changed.

specVersion?: string

version of the spec. The value of this field has no semantic meaning (e.g. don’t interpret it as as a timestamp), but it can be used to impose a partial order. If a.spec_version < b.spec_version then a was the spec before b.

status?: ServiceStatus { failureMessage, logUrl, output, 3 more }
failureMessage?: string

failure_message summarises why the service failed to operate. If this is non-empty the service has failed to operate and will likely transition to a failed state.

logUrl?: string

log_url contains the URL at which the service logs can be accessed.

output?: Record<string, string>

output contains the output of the service. setting an output field to empty string will unset it.

phase?: ServicePhase

phase is the current phase of the service.

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

session is the current session of the service.

statusVersion?: string

version of the status update. Service instances themselves are unversioned, but their status has different versions. The value of this field has no semantic meaning (e.g. don’t interpret it as as a timestamp), but it can be used to impose a partial order. If a.status_version < b.status_version then a was the status before b.

ListServices

import Gitpod from '@gitpod/sdk';

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

// Automatically fetches more pages as needed.
for await (const service of client.environments.automations.services.list({
  filter: { references: ['web-server', 'database'] },
  pagination: { pageSize: 20 },
})) {
  console.log(service.id);
}
{
  "pagination": {
    "nextToken": "nextToken"
  },
  "services": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "environmentId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "metadata": {
        "createdAt": "2019-12-27T18:11:19.117Z",
        "creator": {
          "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
          "principal": "PRINCIPAL_UNSPECIFIED"
        },
        "description": "description",
        "name": "x",
        "reference": "reference",
        "role": "SERVICE_ROLE_UNSPECIFIED",
        "triggeredBy": [
          {
            "beforeSnapshot": true,
            "manual": true,
            "postDevcontainerStart": true,
            "postEnvironmentStart": true,
            "postMachineStart": true,
            "prebuild": true
          }
        ]
      },
      "spec": {
        "commands": {
          "ready": "ready",
          "start": "x",
          "stop": "stop"
        },
        "desiredPhase": "SERVICE_PHASE_UNSPECIFIED",
        "env": [
          {
            "name": "x",
            "value": "value",
            "valueFrom": {
              "secretRef": {
                "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
              }
            }
          }
        ],
        "readinessTimeout": "+9125115.360s",
        "runsOn": {
          "docker": {
            "environment": [
              "string"
            ],
            "image": "x"
          },
          "machine": {}
        },
        "session": "session",
        "specVersion": "specVersion"
      },
      "status": {
        "failureMessage": "failureMessage",
        "logUrl": "logUrl",
        "output": {
          "foo": "string"
        },
        "phase": "SERVICE_PHASE_UNSPECIFIED",
        "session": "session",
        "statusVersion": "statusVersion"
      }
    }
  ]
}
Returns Examples
{
  "pagination": {
    "nextToken": "nextToken"
  },
  "services": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "environmentId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "metadata": {
        "createdAt": "2019-12-27T18:11:19.117Z",
        "creator": {
          "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
          "principal": "PRINCIPAL_UNSPECIFIED"
        },
        "description": "description",
        "name": "x",
        "reference": "reference",
        "role": "SERVICE_ROLE_UNSPECIFIED",
        "triggeredBy": [
          {
            "beforeSnapshot": true,
            "manual": true,
            "postDevcontainerStart": true,
            "postEnvironmentStart": true,
            "postMachineStart": true,
            "prebuild": true
          }
        ]
      },
      "spec": {
        "commands": {
          "ready": "ready",
          "start": "x",
          "stop": "stop"
        },
        "desiredPhase": "SERVICE_PHASE_UNSPECIFIED",
        "env": [
          {
            "name": "x",
            "value": "value",
            "valueFrom": {
              "secretRef": {
                "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
              }
            }
          }
        ],
        "readinessTimeout": "+9125115.360s",
        "runsOn": {
          "docker": {
            "environment": [
              "string"
            ],
            "image": "x"
          },
          "machine": {}
        },
        "session": "session",
        "specVersion": "specVersion"
      },
      "status": {
        "failureMessage": "failureMessage",
        "logUrl": "logUrl",
        "output": {
          "foo": "string"
        },
        "phase": "SERVICE_PHASE_UNSPECIFIED",
        "session": "session",
        "statusVersion": "statusVersion"
      }
    }
  ]
}