memory-bank/components/content-service-api.md
The Content Service API defines the gRPC interfaces for the Content Service, which is responsible for managing various types of content within the Gitpod platform, including workspace files, blobs, logs, and IDE plugins.
This API provides a standardized interface for other components to interact with the Content Service, enabling operations such as:
The Content Service API is implemented as a set of gRPC services defined in Protocol Buffer files. These definitions are used to generate client and server code in various languages (Go, TypeScript) for use by other components in the system.
Provides core content management functionality:
DeleteUserContent: Deletes all content associated with a userManages workspace content:
WorkspaceDownloadURL: Provides a URL from which workspace content can be downloadedDeleteWorkspace: Deletes the content of a single workspaceWorkspaceSnapshotExists: Checks whether a workspace snapshot existsHandles blob storage operations:
UploadUrl: Provides a URL to which clients can upload content via HTTP PUTDownloadUrl: Provides a URL from which clients can download content via HTTP GETDelete: Deletes uploaded contentManages access to headless logs:
LogDownloadURL: Provides a URL from which logs can be downloadedListLogs: Returns a list of task IDs for a specified workspace instanceManages IDE plugins:
UploadURL: Provides a URL for uploading plugin contentDownloadURL: Provides a URL for downloading plugin contentPluginHash: Provides a hash of a pluginDefines how a workspace is initialized, with several initialization methods:
EmptyInitializer: Creates an empty workspaceGitInitializer: Initializes from a Git repositorySnapshotInitializer: Initializes from a snapshotPrebuildInitializer: Combines snapshots with GitCompositeInitializer: Uses multiple initializers in sequenceFileDownloadInitializer: Downloads files for workspace contentFromBackupInitializer: Initializes from a backupDescribes the current Git working copy status, similar to a combination of "git status" and "git branch".
The API uses Protocol Buffers version 3 (proto3) syntax, which provides forward and backward compatibility features.
The Content Service API uses Protocol Buffers and gRPC for defining interfaces. When changes are made to the .proto files, the corresponding code in various languages needs to be regenerated.
To regenerate the code:
Navigate to the content-service-api directory:
cd components/content-service-api
Run the generate script:
./generate.sh
This script performs the following actions:
protoc-gen-go and protoc-gen-go-grpcAfter regenerating the code, you may need to rebuild components that depend on the Content Service API. This typically involves:
For Go components:
cd <component-directory>
go build ./...
For TypeScript components:
cd <component-directory>
yarn install
yarn build
Using Leeway (for CI/CD):
leeway build -D components/<component-name>:app