cloudshell.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.shell.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/longrunning/operations.proto";
  21. import "google/protobuf/timestamp.proto";
  22. option go_package = "google.golang.org/genproto/googleapis/cloud/shell/v1;shell";
  23. option java_multiple_files = true;
  24. option java_outer_classname = "CloudShellProto";
  25. option java_package = "com.google.cloud.shell.v1";
  26. // API for interacting with Google Cloud Shell. Each user of Cloud Shell has at
  27. // least one environment, which has the ID "default". Environment consists of a
  28. // Docker image defining what is installed on the environment and a home
  29. // directory containing the user's data that will remain across sessions.
  30. // Clients use this API to start and fetch information about their environment,
  31. // which can then be used to connect to that environment via a separate SSH
  32. // client.
  33. service CloudShellService {
  34. option (google.api.default_host) = "cloudshell.googleapis.com";
  35. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";
  36. // Gets an environment. Returns NOT_FOUND if the environment does not exist.
  37. rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) {
  38. option (google.api.http) = {
  39. get: "/v1/{name=users/*/environments/*}"
  40. };
  41. option (google.api.method_signature) = "name";
  42. }
  43. // Starts an existing environment, allowing clients to connect to it. The
  44. // returned operation will contain an instance of StartEnvironmentMetadata in
  45. // its metadata field. Users can wait for the environment to start by polling
  46. // this operation via GetOperation. Once the environment has finished starting
  47. // and is ready to accept connections, the operation will contain a
  48. // StartEnvironmentResponse in its response field.
  49. rpc StartEnvironment(StartEnvironmentRequest) returns (google.longrunning.Operation) {
  50. option (google.api.http) = {
  51. post: "/v1/{name=users/*/environments/*}:start"
  52. body: "*"
  53. };
  54. option (google.longrunning.operation_info) = {
  55. response_type: "StartEnvironmentResponse"
  56. metadata_type: "StartEnvironmentMetadata"
  57. };
  58. }
  59. // Sends OAuth credentials to a running environment on behalf of a user. When
  60. // this completes, the environment will be authorized to run various Google
  61. // Cloud command line tools without requiring the user to manually
  62. // authenticate.
  63. rpc AuthorizeEnvironment(AuthorizeEnvironmentRequest) returns (google.longrunning.Operation) {
  64. option (google.api.http) = {
  65. post: "/v1/{name=users/*/environments/*}:authorize"
  66. body: "*"
  67. };
  68. option (google.longrunning.operation_info) = {
  69. response_type: "AuthorizeEnvironmentResponse"
  70. metadata_type: "AuthorizeEnvironmentMetadata"
  71. };
  72. }
  73. // Adds a public SSH key to an environment, allowing clients with the
  74. // corresponding private key to connect to that environment via SSH. If a key
  75. // with the same content already exists, this will error with ALREADY_EXISTS.
  76. rpc AddPublicKey(AddPublicKeyRequest) returns (google.longrunning.Operation) {
  77. option (google.api.http) = {
  78. post: "/v1/{environment=users/*/environments/*}:addPublicKey"
  79. body: "*"
  80. };
  81. option (google.longrunning.operation_info) = {
  82. response_type: "AddPublicKeyResponse"
  83. metadata_type: "AddPublicKeyMetadata"
  84. };
  85. }
  86. // Removes a public SSH key from an environment. Clients will no longer be
  87. // able to connect to the environment using the corresponding private key.
  88. // If a key with the same content is not present, this will error with
  89. // NOT_FOUND.
  90. rpc RemovePublicKey(RemovePublicKeyRequest) returns (google.longrunning.Operation) {
  91. option (google.api.http) = {
  92. post: "/v1/{environment=users/*/environments/*}:removePublicKey"
  93. body: "*"
  94. };
  95. option (google.longrunning.operation_info) = {
  96. response_type: "RemovePublicKeyResponse"
  97. metadata_type: "RemovePublicKeyMetadata"
  98. };
  99. }
  100. }
  101. // A Cloud Shell environment, which is defined as the combination of a Docker
  102. // image specifying what is installed on the environment and a home directory
  103. // containing the user's data that will remain across sessions. Each user has
  104. // at least an environment with the ID "default".
  105. message Environment {
  106. option (google.api.resource) = {
  107. type: "cloudshell.googleapis.com/Environment"
  108. pattern: "users/{user}/environments/{environment}"
  109. };
  110. // Possible execution states for an environment.
  111. enum State {
  112. // The environment's states is unknown.
  113. STATE_UNSPECIFIED = 0;
  114. // The environment is not running and can't be connected to. Starting the
  115. // environment will transition it to the PENDING state.
  116. SUSPENDED = 1;
  117. // The environment is being started but is not yet ready to accept
  118. // connections.
  119. PENDING = 2;
  120. // The environment is running and ready to accept connections. It will
  121. // automatically transition back to DISABLED after a period of inactivity or
  122. // if another environment is started.
  123. RUNNING = 3;
  124. // The environment is being deleted and can't be connected to.
  125. DELETING = 4;
  126. }
  127. // Immutable. Full name of this resource, in the format
  128. // `users/{owner_email}/environments/{environment_id}`. `{owner_email}` is the
  129. // email address of the user to whom this environment belongs, and
  130. // `{environment_id}` is the identifier of this environment. For example,
  131. // `users/someone@example.com/environments/default`.
  132. string name = 1 [(google.api.field_behavior) = IMMUTABLE];
  133. // Output only. The environment's identifier, unique among the user's
  134. // environments.
  135. string id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
  136. // Required. Immutable. Full path to the Docker image used to run this environment, e.g.
  137. // "gcr.io/dev-con/cloud-devshell:latest".
  138. string docker_image = 3 [
  139. (google.api.field_behavior) = REQUIRED,
  140. (google.api.field_behavior) = IMMUTABLE
  141. ];
  142. // Output only. Current execution state of this environment.
  143. State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  144. // Output only. Host to which clients can connect to initiate HTTPS or WSS
  145. // connections with the environment.
  146. string web_host = 12 [(google.api.field_behavior) = OUTPUT_ONLY];
  147. // Output only. Username that clients should use when initiating SSH sessions
  148. // with the environment.
  149. string ssh_username = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  150. // Output only. Host to which clients can connect to initiate SSH sessions
  151. // with the environment.
  152. string ssh_host = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  153. // Output only. Port to which clients can connect to initiate SSH sessions
  154. // with the environment.
  155. int32 ssh_port = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
  156. // Output only. Public keys associated with the environment. Clients can
  157. // connect to this environment via SSH only if they possess a private key
  158. // corresponding to at least one of these public keys. Keys can be added to or
  159. // removed from the environment using the AddPublicKey and RemovePublicKey
  160. // methods.
  161. repeated string public_keys = 8 [(google.api.field_behavior) = OUTPUT_ONLY];
  162. }
  163. // Request message for
  164. // [GetEnvironment][google.cloud.shell.v1.CloudShellService.GetEnvironment].
  165. message GetEnvironmentRequest {
  166. // Required. Name of the requested resource, for example `users/me/environments/default`
  167. // or `users/someone@example.com/environments/default`.
  168. string name = 1 [
  169. (google.api.field_behavior) = REQUIRED,
  170. (google.api.resource_reference) = {
  171. type: "cloudshell.googleapis.com/Environment"
  172. }
  173. ];
  174. }
  175. // Message included in the metadata field of operations returned from
  176. // [CreateEnvironment][google.cloud.shell.v1.CloudShellService.CreateEnvironment].
  177. message CreateEnvironmentMetadata {
  178. }
  179. // Message included in the metadata field of operations returned from
  180. // [DeleteEnvironment][google.cloud.shell.v1.CloudShellService.DeleteEnvironment].
  181. message DeleteEnvironmentMetadata {
  182. }
  183. // Request message for
  184. // [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment].
  185. message StartEnvironmentRequest {
  186. // Name of the resource that should be started, for example
  187. // `users/me/environments/default` or
  188. // `users/someone@example.com/environments/default`.
  189. string name = 1;
  190. // The initial access token passed to the environment. If this is present and
  191. // valid, the environment will be pre-authenticated with gcloud so that the
  192. // user can run gcloud commands in Cloud Shell without having to log in. This
  193. // code can be updated later by calling AuthorizeEnvironment.
  194. string access_token = 2;
  195. // Public keys that should be added to the environment before it is started.
  196. repeated string public_keys = 3;
  197. }
  198. // Request message for
  199. // [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
  200. message AuthorizeEnvironmentRequest {
  201. // Name of the resource that should receive the credentials, for example
  202. // `users/me/environments/default` or
  203. // `users/someone@example.com/environments/default`.
  204. string name = 1;
  205. // The OAuth access token that should be sent to the environment.
  206. string access_token = 2;
  207. // The OAuth ID token that should be sent to the environment.
  208. string id_token = 4;
  209. // The time when the credentials expire. If not set, defaults to one hour from
  210. // when the server received the request.
  211. google.protobuf.Timestamp expire_time = 3;
  212. }
  213. // Response message for
  214. // [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
  215. message AuthorizeEnvironmentResponse {
  216. }
  217. // Message included in the metadata field of operations returned from
  218. // [AuthorizeEnvironment][google.cloud.shell.v1.CloudShellService.AuthorizeEnvironment].
  219. message AuthorizeEnvironmentMetadata {
  220. }
  221. // Message included in the metadata field of operations returned from
  222. // [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment].
  223. message StartEnvironmentMetadata {
  224. // Possible states an environment might transition between during startup.
  225. // These states are not normally actionable by clients, but may be used to
  226. // show a progress message to the user. An environment won't necessarily go
  227. // through all of these states when starting. More states are likely to be
  228. // added in the future.
  229. enum State {
  230. // The environment's start state is unknown.
  231. STATE_UNSPECIFIED = 0;
  232. // The environment is in the process of being started, but no additional
  233. // details are available.
  234. STARTING = 1;
  235. // Startup is waiting for the user's disk to be unarchived. This can happen
  236. // when the user returns to Cloud Shell after not having used it for a
  237. // while, and suggests that startup will take longer than normal.
  238. UNARCHIVING_DISK = 2;
  239. // Startup is waiting for compute resources to be assigned to the
  240. // environment. This should normally happen very quickly, but an environment
  241. // might stay in this state for an extended period of time if the system is
  242. // experiencing heavy load.
  243. AWAITING_COMPUTE_RESOURCES = 4;
  244. // Startup has completed. If the start operation was successful, the user
  245. // should be able to establish an SSH connection to their environment.
  246. // Otherwise, the operation will contain details of the failure.
  247. FINISHED = 3;
  248. }
  249. // Current state of the environment being started.
  250. State state = 1;
  251. }
  252. // Message included in the response field of operations returned from
  253. // [StartEnvironment][google.cloud.shell.v1.CloudShellService.StartEnvironment]
  254. // once the operation is complete.
  255. message StartEnvironmentResponse {
  256. // Environment that was started.
  257. Environment environment = 1;
  258. }
  259. // Request message for
  260. // [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
  261. message AddPublicKeyRequest {
  262. // Environment this key should be added to, e.g.
  263. // `users/me/environments/default`.
  264. string environment = 1;
  265. // Key that should be added to the environment. Supported formats are
  266. // `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256`
  267. // (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and
  268. // `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as
  269. // <format> <content>, where <content> part is encoded with
  270. // Base64.
  271. string key = 2;
  272. }
  273. // Response message for
  274. // [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
  275. message AddPublicKeyResponse {
  276. // Key that was added to the environment.
  277. string key = 1;
  278. }
  279. // Message included in the metadata field of operations returned from
  280. // [AddPublicKey][google.cloud.shell.v1.CloudShellService.AddPublicKey].
  281. message AddPublicKeyMetadata {
  282. }
  283. // Request message for
  284. // [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
  285. message RemovePublicKeyRequest {
  286. // Environment this key should be removed from, e.g.
  287. // `users/me/environments/default`.
  288. string environment = 1;
  289. // Key that should be removed from the environment.
  290. string key = 2;
  291. }
  292. // Response message for
  293. // [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
  294. message RemovePublicKeyResponse {
  295. }
  296. // Message included in the metadata field of operations returned from
  297. // [RemovePublicKey][google.cloud.shell.v1.CloudShellService.RemovePublicKey].
  298. message RemovePublicKeyMetadata {
  299. }
  300. // Cloud-shell specific information that will be included as details in failure
  301. // responses.
  302. message CloudShellErrorDetails {
  303. // Set of possible errors returned from API calls.
  304. enum CloudShellErrorCode {
  305. // An unknown error occurred.
  306. CLOUD_SHELL_ERROR_CODE_UNSPECIFIED = 0;
  307. // The image used by the Cloud Shell environment either does not exist or
  308. // the user does not have access to it.
  309. IMAGE_UNAVAILABLE = 1;
  310. // Cloud Shell has been disabled by an administrator for the user making the
  311. // request.
  312. CLOUD_SHELL_DISABLED = 2;
  313. // Cloud Shell has been permanently disabled due to a Terms of Service
  314. // violation by the user.
  315. TOS_VIOLATION = 4;
  316. // The user has exhausted their weekly Cloud Shell quota, and Cloud Shell
  317. // will be disabled until the quota resets.
  318. QUOTA_EXCEEDED = 5;
  319. // The Cloud Shell environment is unavailable and cannot be connected to at
  320. // the moment.
  321. ENVIRONMENT_UNAVAILABLE = 6;
  322. }
  323. // Code indicating the specific error the occurred.
  324. CloudShellErrorCode code = 1;
  325. }