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.
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
{}