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}
273#[derive(Clone, PartialEq, ::prost::Message)]
274pub struct ExecuteCodeResponse {
275 #[prost(message, optional, tag = "1")]
276 pub event: ::core::option::Option<ExecutionEvent>,
277}
278#[derive(Clone, PartialEq, ::prost::Message)]
279pub struct GetExecutionRequest {
280 #[prost(string, tag = "1")]
281 pub sandbox_rid: ::prost::alloc::string::String,
282 #[prost(string, tag = "2")]
283 pub exec_id: ::prost::alloc::string::String,
284}
285#[derive(Clone, PartialEq, ::prost::Message)]
286pub struct GetExecutionResponse {
287 #[prost(message, optional, tag = "1")]
288 pub event: ::core::option::Option<ExecutionEvent>,
289}
290#[derive(Clone, PartialEq, ::prost::Message)]
291pub struct InterruptExecutionRequest {
292 #[prost(string, tag = "1")]
293 pub sandbox_rid: ::prost::alloc::string::String,
294 #[prost(string, optional, tag = "2")]
295 pub exec_id: ::core::option::Option<::prost::alloc::string::String>,
296}
297#[derive(Clone, Copy, PartialEq, ::prost::Message)]
298pub struct InterruptExecutionResponse {}
299#[derive(Clone, PartialEq, ::prost::Message)]
300pub struct RestartInterpreterRequest {
301 #[prost(string, tag = "1")]
302 pub sandbox_rid: ::prost::alloc::string::String,
303}
304#[derive(Clone, Copy, PartialEq, ::prost::Message)]
305pub struct RestartInterpreterResponse {}
306#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
307#[repr(i32)]
308pub enum SandboxProfile {
309 Unspecified = 0,
310 Notebook = 1,
311 AgentRun = 2,
312}
313impl SandboxProfile {
314 pub fn as_str_name(&self) -> &'static str {
319 match self {
320 Self::Unspecified => "SANDBOX_PROFILE_UNSPECIFIED",
321 Self::Notebook => "SANDBOX_PROFILE_NOTEBOOK",
322 Self::AgentRun => "SANDBOX_PROFILE_AGENT_RUN",
323 }
324 }
325 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
327 match value {
328 "SANDBOX_PROFILE_UNSPECIFIED" => Some(Self::Unspecified),
329 "SANDBOX_PROFILE_NOTEBOOK" => Some(Self::Notebook),
330 "SANDBOX_PROFILE_AGENT_RUN" => Some(Self::AgentRun),
331 _ => None,
332 }
333 }
334}
335#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
336#[repr(i32)]
337pub enum SandboxStatus {
338 Unspecified = 0,
339 Creating = 1,
340 Ready = 2,
341 Terminating = 3,
342 Terminated = 4,
343 Failed = 5,
344}
345impl SandboxStatus {
346 pub fn as_str_name(&self) -> &'static str {
351 match self {
352 Self::Unspecified => "SANDBOX_STATUS_UNSPECIFIED",
353 Self::Creating => "SANDBOX_STATUS_CREATING",
354 Self::Ready => "SANDBOX_STATUS_READY",
355 Self::Terminating => "SANDBOX_STATUS_TERMINATING",
356 Self::Terminated => "SANDBOX_STATUS_TERMINATED",
357 Self::Failed => "SANDBOX_STATUS_FAILED",
358 }
359 }
360 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
362 match value {
363 "SANDBOX_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
364 "SANDBOX_STATUS_CREATING" => Some(Self::Creating),
365 "SANDBOX_STATUS_READY" => Some(Self::Ready),
366 "SANDBOX_STATUS_TERMINATING" => Some(Self::Terminating),
367 "SANDBOX_STATUS_TERMINATED" => Some(Self::Terminated),
368 "SANDBOX_STATUS_FAILED" => Some(Self::Failed),
369 _ => None,
370 }
371 }
372}
373pub mod code_sandbox_service_client {
375 #![allow(
376 unused_variables,
377 dead_code,
378 missing_docs,
379 clippy::wildcard_imports,
380 clippy::let_unit_value,
381 )]
382 use tonic::codegen::*;
383 use tonic::codegen::http::Uri;
384 #[derive(Debug, Clone)]
385 pub struct CodeSandboxServiceClient<T> {
386 inner: tonic::client::Grpc<T>,
387 }
388 impl CodeSandboxServiceClient<tonic::transport::Channel> {
389 pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
391 where
392 D: TryInto<tonic::transport::Endpoint>,
393 D::Error: Into<StdError>,
394 {
395 let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
396 Ok(Self::new(conn))
397 }
398 }
399 impl<T> CodeSandboxServiceClient<T>
400 where
401 T: tonic::client::GrpcService<tonic::body::Body>,
402 T::Error: Into<StdError>,
403 T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
404 <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
405 {
406 pub fn new(inner: T) -> Self {
407 let inner = tonic::client::Grpc::new(inner);
408 Self { inner }
409 }
410 pub fn with_origin(inner: T, origin: Uri) -> Self {
411 let inner = tonic::client::Grpc::with_origin(inner, origin);
412 Self { inner }
413 }
414 pub fn with_interceptor<F>(
415 inner: T,
416 interceptor: F,
417 ) -> CodeSandboxServiceClient<InterceptedService<T, F>>
418 where
419 F: tonic::service::Interceptor,
420 T::ResponseBody: Default,
421 T: tonic::codegen::Service<
422 http::Request<tonic::body::Body>,
423 Response = http::Response<
424 <T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
425 >,
426 >,
427 <T as tonic::codegen::Service<
428 http::Request<tonic::body::Body>,
429 >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
430 {
431 CodeSandboxServiceClient::new(InterceptedService::new(inner, interceptor))
432 }
433 #[must_use]
438 pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
439 self.inner = self.inner.send_compressed(encoding);
440 self
441 }
442 #[must_use]
444 pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
445 self.inner = self.inner.accept_compressed(encoding);
446 self
447 }
448 #[must_use]
452 pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
453 self.inner = self.inner.max_decoding_message_size(limit);
454 self
455 }
456 #[must_use]
460 pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
461 self.inner = self.inner.max_encoding_message_size(limit);
462 self
463 }
464 pub async fn create_sandbox(
465 &mut self,
466 request: impl tonic::IntoRequest<super::CreateSandboxRequest>,
467 ) -> std::result::Result<
468 tonic::Response<super::CreateSandboxResponse>,
469 tonic::Status,
470 > {
471 self.inner
472 .ready()
473 .await
474 .map_err(|e| {
475 tonic::Status::unknown(
476 format!("Service was not ready: {}", e.into()),
477 )
478 })?;
479 let codec = tonic::codec::ProstCodec::default();
480 let path = http::uri::PathAndQuery::from_static(
481 "/nominal.codesandbox.v1.CodeSandboxService/CreateSandbox",
482 );
483 let mut req = request.into_request();
484 req.extensions_mut()
485 .insert(
486 GrpcMethod::new(
487 "nominal.codesandbox.v1.CodeSandboxService",
488 "CreateSandbox",
489 ),
490 );
491 self.inner.unary(req, path, codec).await
492 }
493 pub async fn get_sandbox(
494 &mut self,
495 request: impl tonic::IntoRequest<super::GetSandboxRequest>,
496 ) -> std::result::Result<
497 tonic::Response<super::GetSandboxResponse>,
498 tonic::Status,
499 > {
500 self.inner
501 .ready()
502 .await
503 .map_err(|e| {
504 tonic::Status::unknown(
505 format!("Service was not ready: {}", e.into()),
506 )
507 })?;
508 let codec = tonic::codec::ProstCodec::default();
509 let path = http::uri::PathAndQuery::from_static(
510 "/nominal.codesandbox.v1.CodeSandboxService/GetSandbox",
511 );
512 let mut req = request.into_request();
513 req.extensions_mut()
514 .insert(
515 GrpcMethod::new(
516 "nominal.codesandbox.v1.CodeSandboxService",
517 "GetSandbox",
518 ),
519 );
520 self.inner.unary(req, path, codec).await
521 }
522 pub async fn get_live_sandbox(
523 &mut self,
524 request: impl tonic::IntoRequest<super::GetLiveSandboxRequest>,
525 ) -> std::result::Result<
526 tonic::Response<super::GetLiveSandboxResponse>,
527 tonic::Status,
528 > {
529 self.inner
530 .ready()
531 .await
532 .map_err(|e| {
533 tonic::Status::unknown(
534 format!("Service was not ready: {}", e.into()),
535 )
536 })?;
537 let codec = tonic::codec::ProstCodec::default();
538 let path = http::uri::PathAndQuery::from_static(
539 "/nominal.codesandbox.v1.CodeSandboxService/GetLiveSandbox",
540 );
541 let mut req = request.into_request();
542 req.extensions_mut()
543 .insert(
544 GrpcMethod::new(
545 "nominal.codesandbox.v1.CodeSandboxService",
546 "GetLiveSandbox",
547 ),
548 );
549 self.inner.unary(req, path, codec).await
550 }
551 pub async fn delete_sandbox(
552 &mut self,
553 request: impl tonic::IntoRequest<super::DeleteSandboxRequest>,
554 ) -> std::result::Result<
555 tonic::Response<super::DeleteSandboxResponse>,
556 tonic::Status,
557 > {
558 self.inner
559 .ready()
560 .await
561 .map_err(|e| {
562 tonic::Status::unknown(
563 format!("Service was not ready: {}", e.into()),
564 )
565 })?;
566 let codec = tonic::codec::ProstCodec::default();
567 let path = http::uri::PathAndQuery::from_static(
568 "/nominal.codesandbox.v1.CodeSandboxService/DeleteSandbox",
569 );
570 let mut req = request.into_request();
571 req.extensions_mut()
572 .insert(
573 GrpcMethod::new(
574 "nominal.codesandbox.v1.CodeSandboxService",
575 "DeleteSandbox",
576 ),
577 );
578 self.inner.unary(req, path, codec).await
579 }
580 pub async fn execute_code(
581 &mut self,
582 request: impl tonic::IntoRequest<super::ExecuteCodeRequest>,
583 ) -> std::result::Result<
584 tonic::Response<tonic::codec::Streaming<super::ExecuteCodeResponse>>,
585 tonic::Status,
586 > {
587 self.inner
588 .ready()
589 .await
590 .map_err(|e| {
591 tonic::Status::unknown(
592 format!("Service was not ready: {}", e.into()),
593 )
594 })?;
595 let codec = tonic::codec::ProstCodec::default();
596 let path = http::uri::PathAndQuery::from_static(
597 "/nominal.codesandbox.v1.CodeSandboxService/ExecuteCode",
598 );
599 let mut req = request.into_request();
600 req.extensions_mut()
601 .insert(
602 GrpcMethod::new(
603 "nominal.codesandbox.v1.CodeSandboxService",
604 "ExecuteCode",
605 ),
606 );
607 self.inner.server_streaming(req, path, codec).await
608 }
609 pub async fn get_execution(
610 &mut self,
611 request: impl tonic::IntoRequest<super::GetExecutionRequest>,
612 ) -> std::result::Result<
613 tonic::Response<tonic::codec::Streaming<super::GetExecutionResponse>>,
614 tonic::Status,
615 > {
616 self.inner
617 .ready()
618 .await
619 .map_err(|e| {
620 tonic::Status::unknown(
621 format!("Service was not ready: {}", e.into()),
622 )
623 })?;
624 let codec = tonic::codec::ProstCodec::default();
625 let path = http::uri::PathAndQuery::from_static(
626 "/nominal.codesandbox.v1.CodeSandboxService/GetExecution",
627 );
628 let mut req = request.into_request();
629 req.extensions_mut()
630 .insert(
631 GrpcMethod::new(
632 "nominal.codesandbox.v1.CodeSandboxService",
633 "GetExecution",
634 ),
635 );
636 self.inner.server_streaming(req, path, codec).await
637 }
638 pub async fn interrupt_execution(
639 &mut self,
640 request: impl tonic::IntoRequest<super::InterruptExecutionRequest>,
641 ) -> std::result::Result<
642 tonic::Response<super::InterruptExecutionResponse>,
643 tonic::Status,
644 > {
645 self.inner
646 .ready()
647 .await
648 .map_err(|e| {
649 tonic::Status::unknown(
650 format!("Service was not ready: {}", e.into()),
651 )
652 })?;
653 let codec = tonic::codec::ProstCodec::default();
654 let path = http::uri::PathAndQuery::from_static(
655 "/nominal.codesandbox.v1.CodeSandboxService/InterruptExecution",
656 );
657 let mut req = request.into_request();
658 req.extensions_mut()
659 .insert(
660 GrpcMethod::new(
661 "nominal.codesandbox.v1.CodeSandboxService",
662 "InterruptExecution",
663 ),
664 );
665 self.inner.unary(req, path, codec).await
666 }
667 pub async fn restart_interpreter(
668 &mut self,
669 request: impl tonic::IntoRequest<super::RestartInterpreterRequest>,
670 ) -> std::result::Result<
671 tonic::Response<super::RestartInterpreterResponse>,
672 tonic::Status,
673 > {
674 self.inner
675 .ready()
676 .await
677 .map_err(|e| {
678 tonic::Status::unknown(
679 format!("Service was not ready: {}", e.into()),
680 )
681 })?;
682 let codec = tonic::codec::ProstCodec::default();
683 let path = http::uri::PathAndQuery::from_static(
684 "/nominal.codesandbox.v1.CodeSandboxService/RestartInterpreter",
685 );
686 let mut req = request.into_request();
687 req.extensions_mut()
688 .insert(
689 GrpcMethod::new(
690 "nominal.codesandbox.v1.CodeSandboxService",
691 "RestartInterpreter",
692 ),
693 );
694 self.inner.unary(req, path, codec).await
695 }
696 }
697}