Skip to content

Commit 446315d

Browse files
committed
[public-api] add v2 WorkspaceService.getWorkspace
1 parent e1833f6 commit 446315d

File tree

8 files changed

+2900
-2
lines changed

8 files changed

+2900
-2
lines changed
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
syntax = "proto3";
2+
3+
package gitpod.experimental.v2;
4+
5+
import "google/protobuf/timestamp.proto";
6+
7+
option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v2";
8+
9+
service WorkspaceService {
10+
// GetWorkspace returns a single workspace.
11+
//
12+
// +return NOT_FOUND User does not have access to a workspace with the given
13+
// ID +return NOT_FOUND Workspace does not exist
14+
rpc GetWorkspace(GetWorkspaceRequest) returns (GetWorkspaceResponse) {}
15+
}
16+
17+
message GetWorkspaceRequest { string id = 1; }
18+
19+
message GetWorkspaceResponse { Workspace item = 1; }
20+
21+
// +resource get workspace
22+
message Workspace {
23+
string id = 1;
24+
// prebuild indicates it is a prebuild
25+
// TODO(ak) model prebuilds as a separate resource
26+
bool prebuild = 2;
27+
28+
string organization_id = 3;
29+
30+
string name = 4;
31+
bool pinned = 5;
32+
33+
WorkspaceStatus status = 6;
34+
35+
// additional_environment_variables provide additional environment variables
36+
// which take precedence over environment variables provided by the project
37+
// and user.
38+
//
39+
// +optional
40+
repeated WorkspaceEnvironmentVariable additional_environment_variables = 7;
41+
42+
// region specifies the region in which the workspace will be created.
43+
// Obtain available regions using the ListRegions operation.
44+
//
45+
// +optional defaults to the user's default region
46+
optional string region = 8;
47+
48+
// workspace_class specifies the workspace class with which to create the
49+
// workspace. Obtain available workspace classes using the ListWorkspaceClass
50+
// operation.
51+
//
52+
// +optional defaults to the class configured on the project or the cluster's
53+
// default class.
54+
optional string workspace_class = 9;
55+
56+
// editor specifies the editor that will be used with this workspace.
57+
// Obtain available editors using the EditorService.ListEditors operation.
58+
//
59+
// +optional defaults to the default editor of the user
60+
optional EditorReference editor = 10;
61+
62+
// context_url is the normalized URL from which the workspace was created
63+
// TODO(ak) replace with resolveContextURL API
64+
string context_url = 11;
65+
66+
// Prebuild ID is the unique identifier of the prebuild
67+
// from which this workspace was created
68+
// +optional if empty then this workspace was not created from a prebuild
69+
optional string prebuild_id = 12;
70+
}
71+
72+
message WorkspaceStatus {
73+
// Phase is a simple, high-level summary of where the workspace is in its
74+
// lifecycle. The phase is not intended to be a comprehensive rollup of
75+
// observations of the workspace state, nor is it intended to be a
76+
// comprehensive state machine.
77+
WorkspacePhase phase = 1;
78+
79+
// message is an optional human-readable message detailing the current phase
80+
optional string message = 2;
81+
82+
// workspace_url is the URL of the workspace. Only present when the phase is
83+
// running.
84+
string workspace_url = 3;
85+
86+
// git_status details the Git working copy status of the workspace.
87+
// Note: this is a best-effort field and more often than not will not be
88+
// present. Its absence does not indicate the absence of a working copy.
89+
WorkspaceGitStatus git_status = 4;
90+
91+
// ports lists the network ports currently available/known of this workspace
92+
repeated WorkspacePort ports = 5;
93+
94+
// Admission describes who can access a workspace instance and its ports.
95+
AdmissionLevel admission = 6;
96+
97+
// Instance ID is the unique identifier of the workspace instance
98+
string instance_id = 7;
99+
100+
// Conditions contains observations of the workspace's current phase.
101+
WorkspaceConditions conditions = 8;
102+
}
103+
104+
message WorkspaceConditions {
105+
// failed contains technical details for the failure of the workspace.
106+
// +optional If this field is empty, the workspace has not failed.
107+
optional string failed = 1;
108+
109+
// timeout contains the reason the workspace has timed out.
110+
// +optional If this field is empty, the workspace has not timed out.
111+
optional string timeout = 2;
112+
}
113+
114+
// Admission level describes who can access a workspace instance and its ports.
115+
enum AdmissionLevel {
116+
ADMISSION_LEVEL_UNSPECIFIED = 0;
117+
118+
// ADMISSION_LEVEL_OWNER_ONLY means the workspace can only be accessed using
119+
// the owner token
120+
ADMISSION_LEVEL_OWNER_ONLY = 1;
121+
122+
// ADMISSION_LEVEL_EVERYONE means the workspace (including ports) can be
123+
// accessed by everyone.
124+
ADMISSION_LEVEL_EVERYONE = 2;
125+
}
126+
127+
message WorkspacePort {
128+
// Policy defines the accssbility policy of a workspace port is guarded by an
129+
// authentication in the proxy
130+
enum Policy {
131+
POLICY_UNSPECIFIED = 0;
132+
133+
// Private means the port is accessible by the workspace owner only using
134+
// the workspace port URL
135+
POLICY_PRIVATE = 1;
136+
137+
// Public means the port is accessible by everybody using the workspace port
138+
// URL
139+
POLICY_PUBLIC = 2;
140+
}
141+
142+
// Protocol defines the backend protocol of port
143+
enum Protocol {
144+
PROTOCOL_UNSPECIFIED = 0;
145+
146+
// Http means the port backend is http
147+
PROTOCOL_HTTP = 1;
148+
149+
// Https means the port backend is https
150+
PROTOCOL_HTTPS = 2;
151+
}
152+
153+
// port number
154+
uint64 port = 1;
155+
156+
// policy of this port
157+
Policy policy = 2;
158+
159+
// url that can be used to access the port
160+
string url = 3;
161+
162+
// backend protocol of this port
163+
Protocol protocol = 4;
164+
}
165+
166+
message WorkspaceGitStatus {
167+
// clone_url is the repository url as you would pass it to "git clone".
168+
// Only HTTPS clone URLs are supported.
169+
string clone_url = 1;
170+
171+
// branch is branch we're currently on
172+
string branch = 2;
173+
174+
// latest_commit is the most recent commit on the current branch
175+
string latest_commit = 3;
176+
177+
// uncommited_files is an array of uncommitted files, possibly truncated
178+
repeated string uncommited_files = 4;
179+
180+
// the total number of uncommited files
181+
int32 total_uncommited_files = 5;
182+
183+
// untracked_files is an array of untracked files in the workspace, possibly
184+
// truncated
185+
repeated string untracked_files = 6;
186+
187+
// the total number of untracked files
188+
int32 total_untracked_files = 7;
189+
190+
// unpushed_commits is an array of unpushed changes in the workspace, possibly
191+
// truncated
192+
repeated string unpushed_commits = 8;
193+
194+
// the total number of unpushed changes
195+
int32 total_unpushed_commits = 9;
196+
}
197+
198+
message WorkspacePhase {
199+
enum Phase {
200+
// Unknown indicates an issue within the workspace manager in that it cannot
201+
// determine the actual phase of a workspace. This phase is usually
202+
// accompanied by an error.
203+
PHASE_UNSPECIFIED = 0;
204+
205+
// Preparing means that we haven't actually started the workspace instance
206+
// just yet, but rather are still preparing for launch.
207+
PHASE_PREPARING = 1;
208+
209+
// ImageBuild indicates that there's an image build running for this
210+
// workspace.
211+
PHASE_IMAGEBUILD = 2;
212+
213+
// Pending means the workspace does not yet consume resources in the
214+
// cluster, but rather is looking for some space within the cluster. If for
215+
// example the cluster needs to scale up to accomodate the workspace, the
216+
// workspace will be in Pending state until that happened.
217+
PHASE_PENDING = 3;
218+
219+
// Creating means the workspace is currently being created. That includes
220+
// downloading the images required to run the workspace over the network.
221+
// The time spent in this phase varies widely and depends on the current
222+
// network speed, image size and cache states.
223+
PHASE_CREATING = 4;
224+
225+
// Initializing is the phase in which the workspace is executing the
226+
// appropriate workspace initializer (e.g. Git clone or backup download).
227+
// After this phase one can expect the workspace to either be Running or
228+
// Failed.
229+
PHASE_INITIALIZING = 5;
230+
231+
// Running means the workspace is able to actively perform work, either by
232+
// serving a user through Theia, or as a headless workspace.
233+
PHASE_RUNNING = 6;
234+
235+
// Interrupted is an exceptional state where the container should be running
236+
// but is temporarily unavailable. When in this state, we expect it to
237+
// become running or stopping anytime soon.
238+
PHASE_INTERRUPTED = 7;
239+
240+
// Stopping means that the workspace is currently shutting down. It could go
241+
// to stopped every moment.
242+
PHASE_STOPPING = 8;
243+
244+
// Stopped means the workspace ended regularly because it was shut down.
245+
PHASE_STOPPED = 9;
246+
}
247+
248+
Phase name = 1;
249+
google.protobuf.Timestamp last_transition_time = 2;
250+
}
251+
252+
message EditorReference {
253+
string name = 1;
254+
string version = 2;
255+
}
256+
257+
message WorkspaceEnvironmentVariable {
258+
string name = 1;
259+
optional string value = 2;
260+
}

components/public-api/go/experimental/v2/v2connect/workspace.connect.go

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/public-api/go/experimental/v2/v2connect/workspace.proxy.connect.go

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)