1#[derive(Clone, PartialEq, ::prost::Message)]
3pub struct ExecutionEvent {
4 #[prost(uint64, tag = "1")]
5 pub seq: u64,
6 #[prost(string, tag = "2")]
7 pub exec_id: ::prost::alloc::string::String,
8 #[prost(oneof = "execution_event::Event", tags = "3, 4, 5, 6, 7")]
9 pub event: ::core::option::Option<execution_event::Event>,
10}
11pub mod execution_event {
13 #[derive(Clone, PartialEq, ::prost::Message)]
14 pub struct StreamOutput {
15 #[prost(enumeration = "StreamName", tag = "1")]
16 pub name: i32,
17 #[prost(string, tag = "2")]
18 pub text: ::prost::alloc::string::String,
19 }
20 #[derive(Clone, PartialEq, ::prost::Message)]
21 pub struct MimeBundle {
22 #[prost(map = "string, bytes", tag = "1")]
23 pub payloads: ::std::collections::HashMap<
24 ::prost::alloc::string::String,
25 ::prost::alloc::vec::Vec<u8>,
26 >,
27 }
28 #[derive(Clone, PartialEq, ::prost::Message)]
29 pub struct ExecutionResult {
30 #[prost(message, optional, tag = "1")]
31 pub mime_bundle: ::core::option::Option<MimeBundle>,
32 }
33 #[derive(Clone, PartialEq, ::prost::Message)]
34 pub struct DisplayData {
35 #[prost(message, optional, tag = "1")]
36 pub mime_bundle: ::core::option::Option<MimeBundle>,
37 }
38 #[derive(Clone, PartialEq, ::prost::Message)]
39 pub struct ExecutionError {
40 #[prost(string, tag = "1")]
41 pub ename: ::prost::alloc::string::String,
42 #[prost(string, tag = "2")]
43 pub evalue: ::prost::alloc::string::String,
44 #[prost(string, repeated, tag = "3")]
45 pub traceback: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
46 #[prost(enumeration = "execution_error::Source", tag = "4")]
47 pub source: i32,
48 }
49 pub mod execution_error {
51 #[derive(
52 Clone,
53 Copy,
54 Debug,
55 PartialEq,
56 Eq,
57 Hash,
58 PartialOrd,
59 Ord,
60 ::prost::Enumeration
61 )]
62 #[repr(i32)]
63 pub enum Source {
64 Unspecified = 0,
65 Interpreter = 1,
66 KernelDied = 2,
67 OutputDropped = 3,
68 SupervisionFailed = 4,
69 }
70 impl Source {
71 pub fn as_str_name(&self) -> &'static str {
76 match self {
77 Self::Unspecified => "SOURCE_UNSPECIFIED",
78 Self::Interpreter => "SOURCE_INTERPRETER",
79 Self::KernelDied => "SOURCE_KERNEL_DIED",
80 Self::OutputDropped => "SOURCE_OUTPUT_DROPPED",
81 Self::SupervisionFailed => "SOURCE_SUPERVISION_FAILED",
82 }
83 }
84 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
86 match value {
87 "SOURCE_UNSPECIFIED" => Some(Self::Unspecified),
88 "SOURCE_INTERPRETER" => Some(Self::Interpreter),
89 "SOURCE_KERNEL_DIED" => Some(Self::KernelDied),
90 "SOURCE_OUTPUT_DROPPED" => Some(Self::OutputDropped),
91 "SOURCE_SUPERVISION_FAILED" => Some(Self::SupervisionFailed),
92 _ => None,
93 }
94 }
95 }
96 }
97 #[derive(Clone, Copy, PartialEq, ::prost::Message)]
98 pub struct ExecutionComplete {
99 #[prost(enumeration = "Status", tag = "1")]
100 pub status: i32,
101 #[prost(double, tag = "2")]
102 pub duration_s: f64,
103 }
104 #[derive(
105 Clone,
106 Copy,
107 Debug,
108 PartialEq,
109 Eq,
110 Hash,
111 PartialOrd,
112 Ord,
113 ::prost::Enumeration
114 )]
115 #[repr(i32)]
116 pub enum StreamName {
117 Unspecified = 0,
118 Stdout = 1,
119 Stderr = 2,
120 }
121 impl StreamName {
122 pub fn as_str_name(&self) -> &'static str {
127 match self {
128 Self::Unspecified => "STREAM_NAME_UNSPECIFIED",
129 Self::Stdout => "STREAM_NAME_STDOUT",
130 Self::Stderr => "STREAM_NAME_STDERR",
131 }
132 }
133 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
135 match value {
136 "STREAM_NAME_UNSPECIFIED" => Some(Self::Unspecified),
137 "STREAM_NAME_STDOUT" => Some(Self::Stdout),
138 "STREAM_NAME_STDERR" => Some(Self::Stderr),
139 _ => None,
140 }
141 }
142 }
143 #[derive(
144 Clone,
145 Copy,
146 Debug,
147 PartialEq,
148 Eq,
149 Hash,
150 PartialOrd,
151 Ord,
152 ::prost::Enumeration
153 )]
154 #[repr(i32)]
155 pub enum Status {
156 Unspecified = 0,
157 Ok = 1,
158 Error = 2,
159 Interrupted = 3,
160 }
161 impl Status {
162 pub fn as_str_name(&self) -> &'static str {
167 match self {
168 Self::Unspecified => "STATUS_UNSPECIFIED",
169 Self::Ok => "STATUS_OK",
170 Self::Error => "STATUS_ERROR",
171 Self::Interrupted => "STATUS_INTERRUPTED",
172 }
173 }
174 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
176 match value {
177 "STATUS_UNSPECIFIED" => Some(Self::Unspecified),
178 "STATUS_OK" => Some(Self::Ok),
179 "STATUS_ERROR" => Some(Self::Error),
180 "STATUS_INTERRUPTED" => Some(Self::Interrupted),
181 _ => None,
182 }
183 }
184 }
185 #[derive(Clone, PartialEq, ::prost::Oneof)]
186 pub enum Event {
187 #[prost(message, tag = "3")]
188 StreamOutput(StreamOutput),
189 #[prost(message, tag = "4")]
190 Result(ExecutionResult),
191 #[prost(message, tag = "5")]
192 DisplayData(DisplayData),
193 #[prost(message, tag = "6")]
194 Error(ExecutionError),
195 #[prost(message, tag = "7")]
196 Complete(ExecutionComplete),
197 }
198}
199#[derive(Clone, PartialEq, ::prost::Message)]
200pub struct Sandbox {
201 #[prost(string, tag = "1")]
202 pub sandbox_rid: ::prost::alloc::string::String,
203 #[prost(enumeration = "SandboxProfile", tag = "2")]
204 pub profile: i32,
205 #[prost(enumeration = "SandboxStatus", tag = "3")]
206 pub status: i32,
207 #[prost(message, optional, tag = "4")]
208 pub created_at: ::core::option::Option<
209 super::super::super::google::protobuf::Timestamp,
210 >,
211 #[prost(message, optional, tag = "5")]
212 pub last_activity_at: ::core::option::Option<
213 super::super::super::google::protobuf::Timestamp,
214 >,
215 #[prost(uint32, tag = "6")]
216 pub idle_timeout_seconds: u32,
217 #[prost(string, optional, tag = "7")]
218 pub running_exec_id: ::core::option::Option<::prost::alloc::string::String>,
219}
220#[derive(Clone, PartialEq, ::prost::Message)]
221pub struct CreateSandboxRequest {
222 #[prost(enumeration = "SandboxProfile", tag = "1")]
223 pub profile: i32,
224 #[prost(string, tag = "2")]
225 pub parent_rid: ::prost::alloc::string::String,
226}
227#[derive(Clone, PartialEq, ::prost::Message)]
228pub struct CreateSandboxResponse {
229 #[prost(message, optional, tag = "1")]
230 pub sandbox: ::core::option::Option<Sandbox>,
231 #[prost(bool, tag = "2")]
232 pub created: bool,
233}
234#[derive(Clone, PartialEq, ::prost::Message)]
235pub struct GetSandboxRequest {
236 #[prost(string, tag = "1")]
237 pub sandbox_rid: ::prost::alloc::string::String,
238}
239#[derive(Clone, PartialEq, ::prost::Message)]
240pub struct GetSandboxResponse {
241 #[prost(message, optional, tag = "1")]
242 pub sandbox: ::core::option::Option<Sandbox>,
243}
244#[derive(Clone, PartialEq, ::prost::Message)]
245pub struct GetLiveSandboxRequest {
246 #[prost(string, tag = "1")]
247 pub parent_rid: ::prost::alloc::string::String,
248}
249#[derive(Clone, PartialEq, ::prost::Message)]
250pub struct GetLiveSandboxResponse {
251 #[prost(message, optional, tag = "1")]
252 pub sandbox: ::core::option::Option<Sandbox>,
253}
254#[derive(Clone, PartialEq, ::prost::Message)]
255pub struct DeleteSandboxRequest {
256 #[prost(string, tag = "1")]
257 pub sandbox_rid: ::prost::alloc::string::String,
258}
259#[derive(Clone, PartialEq, ::prost::Message)]
260pub struct DeleteSandboxResponse {
261 #[prost(message, optional, tag = "1")]
262 pub sandbox: ::core::option::Option<Sandbox>,
263}
264#[derive(Clone, PartialEq, ::prost::Message)]
265pub struct ExecuteCodeRequest {
266 #[prost(string, tag = "1")]
267 pub sandbox_rid: ::prost::alloc::string::String,
268 #[prost(string, tag = "2")]
269 pub code: ::prost::alloc::string::String,
270 #[prost(string, tag = "3")]
271 pub exec_id: ::prost::alloc::string::String,
272 #[prost(string, tag = "4")]
273 pub workspace_rid: ::prost::alloc::string::String,
274}
275#[derive(Clone, PartialEq, ::prost::Message)]
276pub struct ExecuteCodeResponse {
277 #[prost(message, optional, tag = "1")]
278 pub event: ::core::option::Option<ExecutionEvent>,
279}
280#[derive(Clone, PartialEq, ::prost::Message)]
281pub struct GetExecutionRequest {
282 #[prost(string, tag = "1")]
283 pub sandbox_rid: ::prost::alloc::string::String,
284 #[prost(string, tag = "2")]
285 pub exec_id: ::prost::alloc::string::String,
286}
287#[derive(Clone, PartialEq, ::prost::Message)]
288pub struct GetExecutionResponse {
289 #[prost(message, optional, tag = "1")]
290 pub event: ::core::option::Option<ExecutionEvent>,
291}
292#[derive(Clone, PartialEq, ::prost::Message)]
293pub struct InterruptExecutionRequest {
294 #[prost(string, tag = "1")]
295 pub sandbox_rid: ::prost::alloc::string::String,
296 #[prost(string, optional, tag = "2")]
297 pub exec_id: ::core::option::Option<::prost::alloc::string::String>,
298}
299#[derive(Clone, Copy, PartialEq, ::prost::Message)]
300pub struct InterruptExecutionResponse {}
301#[derive(Clone, PartialEq, ::prost::Message)]
302pub struct RestartInterpreterRequest {
303 #[prost(string, tag = "1")]
304 pub sandbox_rid: ::prost::alloc::string::String,
305}
306#[derive(Clone, Copy, PartialEq, ::prost::Message)]
307pub struct RestartInterpreterResponse {}
308#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
309#[repr(i32)]
310pub enum SandboxProfile {
311 Unspecified = 0,
312 Notebook = 1,
313 AgentRun = 2,
314}
315impl SandboxProfile {
316 pub fn as_str_name(&self) -> &'static str {
321 match self {
322 Self::Unspecified => "SANDBOX_PROFILE_UNSPECIFIED",
323 Self::Notebook => "SANDBOX_PROFILE_NOTEBOOK",
324 Self::AgentRun => "SANDBOX_PROFILE_AGENT_RUN",
325 }
326 }
327 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
329 match value {
330 "SANDBOX_PROFILE_UNSPECIFIED" => Some(Self::Unspecified),
331 "SANDBOX_PROFILE_NOTEBOOK" => Some(Self::Notebook),
332 "SANDBOX_PROFILE_AGENT_RUN" => Some(Self::AgentRun),
333 _ => None,
334 }
335 }
336}
337#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
338#[repr(i32)]
339pub enum SandboxStatus {
340 Unspecified = 0,
341 Creating = 1,
342 Ready = 2,
343 Terminating = 3,
344 Terminated = 4,
345 Failed = 5,
346}
347impl SandboxStatus {
348 pub fn as_str_name(&self) -> &'static str {
353 match self {
354 Self::Unspecified => "SANDBOX_STATUS_UNSPECIFIED",
355 Self::Creating => "SANDBOX_STATUS_CREATING",
356 Self::Ready => "SANDBOX_STATUS_READY",
357 Self::Terminating => "SANDBOX_STATUS_TERMINATING",
358 Self::Terminated => "SANDBOX_STATUS_TERMINATED",
359 Self::Failed => "SANDBOX_STATUS_FAILED",
360 }
361 }
362 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
364 match value {
365 "SANDBOX_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
366 "SANDBOX_STATUS_CREATING" => Some(Self::Creating),
367 "SANDBOX_STATUS_READY" => Some(Self::Ready),
368 "SANDBOX_STATUS_TERMINATING" => Some(Self::Terminating),
369 "SANDBOX_STATUS_TERMINATED" => Some(Self::Terminated),
370 "SANDBOX_STATUS_FAILED" => Some(Self::Failed),
371 _ => None,
372 }
373 }
374}
375pub mod code_sandbox_service_client {
377 #![allow(
378 unused_variables,
379 dead_code,
380 missing_docs,
381 clippy::wildcard_imports,
382 clippy::let_unit_value,
383 )]
384 use tonic::codegen::*;
385 use tonic::codegen::http::Uri;
386 #[derive(Debug, Clone)]
387 pub struct CodeSandboxServiceClient<T> {
388 inner: tonic::client::Grpc<T>,
389 }
390 impl CodeSandboxServiceClient<tonic::transport::Channel> {
391 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
393 where
394 D: TryInto<tonic::transport::Endpoint>,
395 D::Error: Into<StdError>,
396 {
397 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
398 Ok(Self::new(conn))
399 }
400 }
401 impl<T> CodeSandboxServiceClient<T>
402 where
403 T: tonic::client::GrpcService<tonic::body::Body>,
404 T::Error: Into<StdError>,
405 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
406 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
407 {
408 pub fn new(inner: T) -> Self {
409 let inner = tonic::client::Grpc::new(inner);
410 Self { inner }
411 }
412 pub fn with_origin(inner: T, origin: Uri) -> Self {
413 let inner = tonic::client::Grpc::with_origin(inner, origin);
414 Self { inner }
415 }
416 pub fn with_interceptor<F>(
417 inner: T,
418 interceptor: F,
419 ) -> CodeSandboxServiceClient<InterceptedService<T, F>>
420 where
421 F: tonic::service::Interceptor,
422 T::ResponseBody: Default,
423 T: tonic::codegen::Service<
424 http::Request<tonic::body::Body>,
425 Response = http::Response<
426 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
427 >,
428 >,
429 <T as tonic::codegen::Service<
430 http::Request<tonic::body::Body>,
431 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
432 {
433 CodeSandboxServiceClient::new(InterceptedService::new(inner, interceptor))
434 }
435 #[must_use]
440 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
441 self.inner = self.inner.send_compressed(encoding);
442 self
443 }
444 #[must_use]
446 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
447 self.inner = self.inner.accept_compressed(encoding);
448 self
449 }
450 #[must_use]
454 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
455 self.inner = self.inner.max_decoding_message_size(limit);
456 self
457 }
458 #[must_use]
462 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
463 self.inner = self.inner.max_encoding_message_size(limit);
464 self
465 }
466 pub async fn create_sandbox(
467 &mut self,
468 request: impl tonic::IntoRequest<super::CreateSandboxRequest>,
469 ) -> std::result::Result<
470 tonic::Response<super::CreateSandboxResponse>,
471 tonic::Status,
472 > {
473 self.inner
474 .ready()
475 .await
476 .map_err(|e| {
477 tonic::Status::unknown(
478 format!("Service was not ready: {}", e.into()),
479 )
480 })?;
481 let codec = tonic::codec::ProstCodec::default();
482 let path = http::uri::PathAndQuery::from_static(
483 "/nominal.codesandbox.v1.CodeSandboxService/CreateSandbox",
484 );
485 let mut req = request.into_request();
486 req.extensions_mut()
487 .insert(
488 GrpcMethod::new(
489 "nominal.codesandbox.v1.CodeSandboxService",
490 "CreateSandbox",
491 ),
492 );
493 self.inner.unary(req, path, codec).await
494 }
495 pub async fn get_sandbox(
496 &mut self,
497 request: impl tonic::IntoRequest<super::GetSandboxRequest>,
498 ) -> std::result::Result<
499 tonic::Response<super::GetSandboxResponse>,
500 tonic::Status,
501 > {
502 self.inner
503 .ready()
504 .await
505 .map_err(|e| {
506 tonic::Status::unknown(
507 format!("Service was not ready: {}", e.into()),
508 )
509 })?;
510 let codec = tonic::codec::ProstCodec::default();
511 let path = http::uri::PathAndQuery::from_static(
512 "/nominal.codesandbox.v1.CodeSandboxService/GetSandbox",
513 );
514 let mut req = request.into_request();
515 req.extensions_mut()
516 .insert(
517 GrpcMethod::new(
518 "nominal.codesandbox.v1.CodeSandboxService",
519 "GetSandbox",
520 ),
521 );
522 self.inner.unary(req, path, codec).await
523 }
524 pub async fn get_live_sandbox(
525 &mut self,
526 request: impl tonic::IntoRequest<super::GetLiveSandboxRequest>,
527 ) -> std::result::Result<
528 tonic::Response<super::GetLiveSandboxResponse>,
529 tonic::Status,
530 > {
531 self.inner
532 .ready()
533 .await
534 .map_err(|e| {
535 tonic::Status::unknown(
536 format!("Service was not ready: {}", e.into()),
537 )
538 })?;
539 let codec = tonic::codec::ProstCodec::default();
540 let path = http::uri::PathAndQuery::from_static(
541 "/nominal.codesandbox.v1.CodeSandboxService/GetLiveSandbox",
542 );
543 let mut req = request.into_request();
544 req.extensions_mut()
545 .insert(
546 GrpcMethod::new(
547 "nominal.codesandbox.v1.CodeSandboxService",
548 "GetLiveSandbox",
549 ),
550 );
551 self.inner.unary(req, path, codec).await
552 }
553 pub async fn delete_sandbox(
554 &mut self,
555 request: impl tonic::IntoRequest<super::DeleteSandboxRequest>,
556 ) -> std::result::Result<
557 tonic::Response<super::DeleteSandboxResponse>,
558 tonic::Status,
559 > {
560 self.inner
561 .ready()
562 .await
563 .map_err(|e| {
564 tonic::Status::unknown(
565 format!("Service was not ready: {}", e.into()),
566 )
567 })?;
568 let codec = tonic::codec::ProstCodec::default();
569 let path = http::uri::PathAndQuery::from_static(
570 "/nominal.codesandbox.v1.CodeSandboxService/DeleteSandbox",
571 );
572 let mut req = request.into_request();
573 req.extensions_mut()
574 .insert(
575 GrpcMethod::new(
576 "nominal.codesandbox.v1.CodeSandboxService",
577 "DeleteSandbox",
578 ),
579 );
580 self.inner.unary(req, path, codec).await
581 }
582 pub async fn execute_code(
583 &mut self,
584 request: impl tonic::IntoRequest<super::ExecuteCodeRequest>,
585 ) -> std::result::Result<
586 tonic::Response<tonic::codec::Streaming<super::ExecuteCodeResponse>>,
587 tonic::Status,
588 > {
589 self.inner
590 .ready()
591 .await
592 .map_err(|e| {
593 tonic::Status::unknown(
594 format!("Service was not ready: {}", e.into()),
595 )
596 })?;
597 let codec = tonic::codec::ProstCodec::default();
598 let path = http::uri::PathAndQuery::from_static(
599 "/nominal.codesandbox.v1.CodeSandboxService/ExecuteCode",
600 );
601 let mut req = request.into_request();
602 req.extensions_mut()
603 .insert(
604 GrpcMethod::new(
605 "nominal.codesandbox.v1.CodeSandboxService",
606 "ExecuteCode",
607 ),
608 );
609 self.inner.server_streaming(req, path, codec).await
610 }
611 pub async fn get_execution(
612 &mut self,
613 request: impl tonic::IntoRequest<super::GetExecutionRequest>,
614 ) -> std::result::Result<
615 tonic::Response<tonic::codec::Streaming<super::GetExecutionResponse>>,
616 tonic::Status,
617 > {
618 self.inner
619 .ready()
620 .await
621 .map_err(|e| {
622 tonic::Status::unknown(
623 format!("Service was not ready: {}", e.into()),
624 )
625 })?;
626 let codec = tonic::codec::ProstCodec::default();
627 let path = http::uri::PathAndQuery::from_static(
628 "/nominal.codesandbox.v1.CodeSandboxService/GetExecution",
629 );
630 let mut req = request.into_request();
631 req.extensions_mut()
632 .insert(
633 GrpcMethod::new(
634 "nominal.codesandbox.v1.CodeSandboxService",
635 "GetExecution",
636 ),
637 );
638 self.inner.server_streaming(req, path, codec).await
639 }
640 pub async fn interrupt_execution(
641 &mut self,
642 request: impl tonic::IntoRequest<super::InterruptExecutionRequest>,
643 ) -> std::result::Result<
644 tonic::Response<super::InterruptExecutionResponse>,
645 tonic::Status,
646 > {
647 self.inner
648 .ready()
649 .await
650 .map_err(|e| {
651 tonic::Status::unknown(
652 format!("Service was not ready: {}", e.into()),
653 )
654 })?;
655 let codec = tonic::codec::ProstCodec::default();
656 let path = http::uri::PathAndQuery::from_static(
657 "/nominal.codesandbox.v1.CodeSandboxService/InterruptExecution",
658 );
659 let mut req = request.into_request();
660 req.extensions_mut()
661 .insert(
662 GrpcMethod::new(
663 "nominal.codesandbox.v1.CodeSandboxService",
664 "InterruptExecution",
665 ),
666 );
667 self.inner.unary(req, path, codec).await
668 }
669 pub async fn restart_interpreter(
670 &mut self,
671 request: impl tonic::IntoRequest<super::RestartInterpreterRequest>,
672 ) -> std::result::Result<
673 tonic::Response<super::RestartInterpreterResponse>,
674 tonic::Status,
675 > {
676 self.inner
677 .ready()
678 .await
679 .map_err(|e| {
680 tonic::Status::unknown(
681 format!("Service was not ready: {}", e.into()),
682 )
683 })?;
684 let codec = tonic::codec::ProstCodec::default();
685 let path = http::uri::PathAndQuery::from_static(
686 "/nominal.codesandbox.v1.CodeSandboxService/RestartInterpreter",
687 );
688 let mut req = request.into_request();
689 req.extensions_mut()
690 .insert(
691 GrpcMethod::new(
692 "nominal.codesandbox.v1.CodeSandboxService",
693 "RestartInterpreter",
694 ),
695 );
696 self.inner.unary(req, path, codec).await
697 }
698 }
699}