Skip to content
Ona Docs

GetService

environments.automations.services.retrieve(ServiceRetrieveParams**kwargs) -> ServiceRetrieveResponse
POST/gitpod.v1.EnvironmentAutomationService/GetService

Gets details about a specific automation service.

Use this method to:

  • Check service status
  • View service configuration
  • Monitor service health
  • Retrieve service metadata

Examples

  • Get service details:

    Retrieves information about a specific service.

    id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
ParametersExpand Collapse
id: Optional[str]
formatuuid
ReturnsExpand Collapse
class ServiceRetrieveResponse:
service: Service
id: str
formatuuid
environment_id: Optional[str]
formatuuid
metadata: Optional[ServiceMetadata]
created_at: Optional[datetime]

created_at is the time the service was created.

formatdate-time
creator: Optional[Subject]

creator describes the principal who created the service.

id: Optional[str]

id is the UUID of the subject

formatuuid
principal: Optional[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: Optional[str]

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

name: Optional[str]

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: Optional[str]

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: Optional[ServiceRole]

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"
triggered_by: Optional[List[AutomationTrigger]]

triggered_by is a list of trigger that start the service.

before_snapshot: Optional[bool]
manual: Optional[bool]
post_devcontainer_start: Optional[bool]
post_environment_start: Optional[bool]
post_machine_start: Optional[bool]
prebuild: Optional[bool]
spec: Optional[ServiceSpec]
commands: Optional[Commands]

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

ready: Optional[str]

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: Optional[str]

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: Optional[str]

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.

desired_phase: Optional[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: Optional[List[EnvironmentVariableItem]]

env specifies environment variables for the service.

name: Optional[str]

name is the environment variable name.

minLength1
value: Optional[str]

value is a literal string value.

value_from: Optional[EnvironmentVariableSource]

value_from specifies a source for the value.

secret_ref: SecretRef

secret_ref references a secret by ID.

id: Optional[str]

id is the UUID of the secret to reference.

formatuuid
readiness_timeout: Optional[str]

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

formatregex
runs_on: Optional[RunsOn]

runs_on specifies the environment the service should run on.

docker: Optional[Docker]
environment: Optional[List[str]]
image: Optional[str]
minLength1
machine: Optional[object]

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

session: Optional[str]

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.

spec_version: Optional[str]

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: Optional[ServiceStatus]
failure_message: Optional[str]

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.

log_url: Optional[str]

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

output: Optional[Dict[str, str]]

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

phase: Optional[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: Optional[str]

session is the current session of the service.

status_version: Optional[str]

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.

GetService

import os
from gitpod import Gitpod

client = Gitpod(
    bearer_token=os.environ.get("GITPOD_API_KEY"),  # This is the default and can be omitted
)
service = client.environments.automations.services.retrieve(
    id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
)
print(service.service)
{
  "service": {
    "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
{
  "service": {
    "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"
    }
  }
}