Skip to content
Ona Docs

UpdateEnvironment

client.Environments.Update(ctx, body) (*EnvironmentUpdateResponse, error)
POST/gitpod.v1.EnvironmentService/UpdateEnvironment

Updates an environment’s configuration while it is running.

Updates are limited to:

  • Git credentials (username, email)
  • SSH public keys
  • Content initialization
  • Port configurations
  • Automation files
  • Environment timeouts

Examples

  • Update Git credentials:

    Updates the Git configuration for the environment.

    environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
    spec:
      content:
        gitUsername: "example-user"
        gitEmail: "user@example.com"
  • Add SSH public key:

    Adds a new SSH public key for authentication.

    environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
    spec:
      sshPublicKeys:
        - id: "0194b7c1-c954-718d-91a4-9a742aa5fc11"
          value: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI..."
  • Update content session:

    Updates the content session identifier for the environment.

    environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048"
    spec:
      content:
        session: "0194b7c1-c954-718d-91a4-9a742aa5fc11"

Note: Machine class changes require stopping the environment and creating a new one.

ParametersExpand Collapse
body EnvironmentUpdateParams
EnvironmentID param.Field[string]Optional

environment_id specifies which environment should be updated.

+required

formatuuid
Metadata param.Field[EnvironmentUpdateParamsMetadata]Optional
Name stringOptional

name is the user-defined display name of the environment

maxLength128
Spec param.Field[EnvironmentUpdateParamsSpec]Optional
AutomationsFile EnvironmentUpdateParamsSpecAutomationsFileOptional

automations_file is the automations file spec of the environment

AutomationsFilePath stringOptional

automations_file_path is the path to the automations file that is applied in the environment, relative to the repo root. path must not be absolute (start with a /):

this.matches('^$|^[^/].*')
Session stringOptional
Content EnvironmentUpdateParamsSpecContentOptional
GitEmail stringOptional

The Git email address

GitUsername stringOptional

The Git username

Initializer EnvironmentInitializerOptional

initializer configures how the environment is to be initialized

Specs []EnvironmentInitializerSpecOptional
ContextURL EnvironmentInitializerSpecsContextURLOptional
URL stringOptional

url is the URL from which the environment is created

formaturi
Git EnvironmentInitializerSpecsGitOptional
CheckoutLocation stringOptional

a path relative to the environment root in which the code will be checked out to

CloneTarget stringOptional

the value for the clone target mode - use depends on the target mode

RemoteUri stringOptional

remote_uri is the Git remote origin

TargetMode EnvironmentInitializerSpecsGitTargetModeOptional

the target mode determines what gets checked out

One of the following:
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeUnspecified EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_UNSPECIFIED"
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeRemoteHead EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_REMOTE_HEAD"
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeRemoteCommit EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_REMOTE_COMMIT"
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeRemoteBranch EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_REMOTE_BRANCH"
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeLocalBranch EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_LOCAL_BRANCH"
const EnvironmentInitializerSpecsGitTargetModeCloneTargetModeRemoteTag EnvironmentInitializerSpecsGitTargetMode = "CLONE_TARGET_MODE_REMOTE_TAG"
UpstreamRemoteUri stringOptional

upstream_Remote_uri is the fork upstream of a repository

Session stringOptional

session should be changed to trigger a content reinitialization

Devcontainer EnvironmentUpdateParamsSpecDevcontainerOptional
DevcontainerFilePath stringOptional

devcontainer_file_path is the path to the devcontainer file relative to the repo root path must not be absolute (start with a /):

this.matches('^$|^[^/].*')
Session stringOptional

session should be changed to trigger a devcontainer rebuild

KernelControlsConfig KernelControlsConfigOptional

kernel_controls_config configures kernel-level controls for this environment

Veto VetoOptional

veto controls blocking mechanisms

Exec VetoExecOptional

exec controls executable blocking

Action KernelControlsActionOptional

action specifies what action kernel-level controls take on policy violations

One of the following:
const KernelControlsActionUnspecified KernelControlsAction = "KERNEL_CONTROLS_ACTION_UNSPECIFIED"
const KernelControlsActionBlock KernelControlsAction = "KERNEL_CONTROLS_ACTION_BLOCK"
const KernelControlsActionAudit KernelControlsAction = "KERNEL_CONTROLS_ACTION_AUDIT"
Denylist []stringOptional

denylist is the list of executable paths or names to block

Enabled boolOptional

enabled controls whether executable blocking is active

Ports []EnvironmentUpdateParamsSpecPortOptional

ports controls port sharing

Admission AdmissionLevelOptional

policy of this port

One of the following:
const AdmissionLevelUnspecified AdmissionLevel = "ADMISSION_LEVEL_UNSPECIFIED"
const AdmissionLevelOwnerOnly AdmissionLevel = "ADMISSION_LEVEL_OWNER_ONLY"
const AdmissionLevelEveryone AdmissionLevel = "ADMISSION_LEVEL_EVERYONE"
const AdmissionLevelOrganization AdmissionLevel = "ADMISSION_LEVEL_ORGANIZATION"
const AdmissionLevelCreatorOnly AdmissionLevel = "ADMISSION_LEVEL_CREATOR_ONLY"
Name stringOptional

name of this port

maxLength100
minLength1
Port int64Optional

port number

formatint32
maximum65535
minimum1024
Protocol EnvironmentUpdateParamsSpecPortsProtocolOptional

protocol for communication (Gateway proxy → user environment service). this setting only affects the protocol used between Gateway and user environment services.

One of the following:
const EnvironmentUpdateParamsSpecPortsProtocolProtocolUnspecified EnvironmentUpdateParamsSpecPortsProtocol = "PROTOCOL_UNSPECIFIED"
const EnvironmentUpdateParamsSpecPortsProtocolProtocolHTTP EnvironmentUpdateParamsSpecPortsProtocol = "PROTOCOL_HTTP"
const EnvironmentUpdateParamsSpecPortsProtocolProtocolHTTPS EnvironmentUpdateParamsSpecPortsProtocol = "PROTOCOL_HTTPS"
SSHPublicKeys []EnvironmentUpdateParamsSpecSSHPublicKeyOptional

ssh_public_keys are the public keys to update empty array means nothing to update

ID stringOptional

id is the unique identifier of the public key

Value stringOptional

value is the actual public key in the public key file format if not provided, the public key will be removed

Timeout EnvironmentUpdateParamsSpecTimeoutOptional

Timeout configures the environment timeout

Disconnected stringOptional

inacitivity is the maximum time of disconnection before the environment is stopped or paused. Minimum duration is 30 minutes. Set to 0 to disable. value must be 0s (disabled) or at least 1800s (30 minutes):

this == duration('0s') || this >= duration('1800s')
formatregex
ReturnsExpand Collapse
type EnvironmentUpdateResponse interface{…}

UpdateEnvironment

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"),
  )
  environment, err := client.Environments.Update(context.TODO(), gitpod.EnvironmentUpdateParams{
    EnvironmentID: gitpod.F("07e03a28-65a5-4d98-b532-8ea67b188048"),
    Spec: gitpod.F(gitpod.EnvironmentUpdateParamsSpec{
      SSHPublicKeys: gitpod.F([]gitpod.EnvironmentUpdateParamsSpecSSHPublicKey{gitpod.EnvironmentUpdateParamsSpecSSHPublicKey{
        ID: gitpod.F("0194b7c1-c954-718d-91a4-9a742aa5fc11"),
        Value: gitpod.F("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI..."),
      }}),
    }),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", environment)
}
{}
Returns Examples
{}