cloudshell.proto 15 KB

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