#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutionEvent {
#[prost(uint64, tag = "1")]
pub seq: u64,
#[prost(string, tag = "2")]
pub exec_id: ::prost::alloc::string::String,
#[prost(oneof = "execution_event::Event", tags = "3, 4, 5, 6, 7")]
pub event: ::core::option::Option<execution_event::Event>,
}
pub mod execution_event {
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamOutput {
#[prost(enumeration = "StreamName", tag = "1")]
pub name: i32,
#[prost(string, tag = "2")]
pub text: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MimeBundle {
#[prost(map = "string, bytes", tag = "1")]
pub payloads: ::std::collections::HashMap<
::prost::alloc::string::String,
::prost::alloc::vec::Vec<u8>,
>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutionResult {
#[prost(message, optional, tag = "1")]
pub mime_bundle: ::core::option::Option<MimeBundle>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DisplayData {
#[prost(message, optional, tag = "1")]
pub mime_bundle: ::core::option::Option<MimeBundle>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecutionError {
#[prost(string, tag = "1")]
pub ename: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub evalue: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "3")]
pub traceback: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(enumeration = "execution_error::Source", tag = "4")]
pub source: i32,
}
pub mod execution_error {
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Source {
Unspecified = 0,
Interpreter = 1,
KernelDied = 2,
OutputDropped = 3,
SupervisionFailed = 4,
}
impl Source {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SOURCE_UNSPECIFIED",
Self::Interpreter => "SOURCE_INTERPRETER",
Self::KernelDied => "SOURCE_KERNEL_DIED",
Self::OutputDropped => "SOURCE_OUTPUT_DROPPED",
Self::SupervisionFailed => "SOURCE_SUPERVISION_FAILED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SOURCE_UNSPECIFIED" => Some(Self::Unspecified),
"SOURCE_INTERPRETER" => Some(Self::Interpreter),
"SOURCE_KERNEL_DIED" => Some(Self::KernelDied),
"SOURCE_OUTPUT_DROPPED" => Some(Self::OutputDropped),
"SOURCE_SUPERVISION_FAILED" => Some(Self::SupervisionFailed),
_ => None,
}
}
}
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ExecutionComplete {
#[prost(enumeration = "Status", tag = "1")]
pub status: i32,
#[prost(double, tag = "2")]
pub duration_s: f64,
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum StreamName {
Unspecified = 0,
Stdout = 1,
Stderr = 2,
}
impl StreamName {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "STREAM_NAME_UNSPECIFIED",
Self::Stdout => "STREAM_NAME_STDOUT",
Self::Stderr => "STREAM_NAME_STDERR",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STREAM_NAME_UNSPECIFIED" => Some(Self::Unspecified),
"STREAM_NAME_STDOUT" => Some(Self::Stdout),
"STREAM_NAME_STDERR" => Some(Self::Stderr),
_ => None,
}
}
}
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Status {
Unspecified = 0,
Ok = 1,
Error = 2,
Interrupted = 3,
}
impl Status {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "STATUS_UNSPECIFIED",
Self::Ok => "STATUS_OK",
Self::Error => "STATUS_ERROR",
Self::Interrupted => "STATUS_INTERRUPTED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"STATUS_OK" => Some(Self::Ok),
"STATUS_ERROR" => Some(Self::Error),
"STATUS_INTERRUPTED" => Some(Self::Interrupted),
_ => None,
}
}
}
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Event {
#[prost(message, tag = "3")]
StreamOutput(StreamOutput),
#[prost(message, tag = "4")]
Result(ExecutionResult),
#[prost(message, tag = "5")]
DisplayData(DisplayData),
#[prost(message, tag = "6")]
Error(ExecutionError),
#[prost(message, tag = "7")]
Complete(ExecutionComplete),
}
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Sandbox {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
#[prost(enumeration = "SandboxProfile", tag = "2")]
pub profile: i32,
#[prost(enumeration = "SandboxStatus", tag = "3")]
pub status: i32,
#[prost(message, optional, tag = "4")]
pub created_at: ::core::option::Option<
super::super::super::google::protobuf::Timestamp,
>,
#[prost(message, optional, tag = "5")]
pub last_activity_at: ::core::option::Option<
super::super::super::google::protobuf::Timestamp,
>,
#[prost(uint32, tag = "6")]
pub idle_timeout_seconds: u32,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateSandboxRequest {
#[prost(enumeration = "SandboxProfile", tag = "1")]
pub profile: i32,
#[prost(string, tag = "2")]
pub parent_rid: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CreateSandboxResponse {
#[prost(message, optional, tag = "1")]
pub sandbox: ::core::option::Option<Sandbox>,
#[prost(bool, tag = "2")]
pub created: bool,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSandboxRequest {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetSandboxResponse {
#[prost(message, optional, tag = "1")]
pub sandbox: ::core::option::Option<Sandbox>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteSandboxRequest {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeleteSandboxResponse {
#[prost(message, optional, tag = "1")]
pub sandbox: ::core::option::Option<Sandbox>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecuteCodeRequest {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
pub code: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
pub exec_id: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExecuteCodeResponse {
#[prost(message, optional, tag = "1")]
pub event: ::core::option::Option<ExecutionEvent>,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InterruptExecutionRequest {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct InterruptExecutionResponse {}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RestartInterpreterRequest {
#[prost(string, tag = "1")]
pub sandbox_rid: ::prost::alloc::string::String,
}
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct RestartInterpreterResponse {}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SandboxProfile {
Unspecified = 0,
Notebook = 1,
AgentRun = 2,
}
impl SandboxProfile {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SANDBOX_PROFILE_UNSPECIFIED",
Self::Notebook => "SANDBOX_PROFILE_NOTEBOOK",
Self::AgentRun => "SANDBOX_PROFILE_AGENT_RUN",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SANDBOX_PROFILE_UNSPECIFIED" => Some(Self::Unspecified),
"SANDBOX_PROFILE_NOTEBOOK" => Some(Self::Notebook),
"SANDBOX_PROFILE_AGENT_RUN" => Some(Self::AgentRun),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SandboxStatus {
Unspecified = 0,
Creating = 1,
Ready = 2,
Terminating = 3,
Terminated = 4,
Failed = 5,
}
impl SandboxStatus {
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Unspecified => "SANDBOX_STATUS_UNSPECIFIED",
Self::Creating => "SANDBOX_STATUS_CREATING",
Self::Ready => "SANDBOX_STATUS_READY",
Self::Terminating => "SANDBOX_STATUS_TERMINATING",
Self::Terminated => "SANDBOX_STATUS_TERMINATED",
Self::Failed => "SANDBOX_STATUS_FAILED",
}
}
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SANDBOX_STATUS_UNSPECIFIED" => Some(Self::Unspecified),
"SANDBOX_STATUS_CREATING" => Some(Self::Creating),
"SANDBOX_STATUS_READY" => Some(Self::Ready),
"SANDBOX_STATUS_TERMINATING" => Some(Self::Terminating),
"SANDBOX_STATUS_TERMINATED" => Some(Self::Terminated),
"SANDBOX_STATUS_FAILED" => Some(Self::Failed),
_ => None,
}
}
}
pub mod code_sandbox_service_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
#[derive(Debug, Clone)]
pub struct CodeSandboxServiceClient<T> {
inner: tonic::client::Grpc<T>,
}
impl CodeSandboxServiceClient<tonic::transport::Channel> {
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> CodeSandboxServiceClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> CodeSandboxServiceClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
CodeSandboxServiceClient::new(InterceptedService::new(inner, interceptor))
}
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
pub async fn create_sandbox(
&mut self,
request: impl tonic::IntoRequest<super::CreateSandboxRequest>,
) -> std::result::Result<
tonic::Response<super::CreateSandboxResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/CreateSandbox",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"CreateSandbox",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn get_sandbox(
&mut self,
request: impl tonic::IntoRequest<super::GetSandboxRequest>,
) -> std::result::Result<
tonic::Response<super::GetSandboxResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/GetSandbox",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"GetSandbox",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn delete_sandbox(
&mut self,
request: impl tonic::IntoRequest<super::DeleteSandboxRequest>,
) -> std::result::Result<
tonic::Response<super::DeleteSandboxResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/DeleteSandbox",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"DeleteSandbox",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn execute_code(
&mut self,
request: impl tonic::IntoRequest<super::ExecuteCodeRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ExecuteCodeResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/ExecuteCode",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"ExecuteCode",
),
);
self.inner.server_streaming(req, path, codec).await
}
pub async fn interrupt_execution(
&mut self,
request: impl tonic::IntoRequest<super::InterruptExecutionRequest>,
) -> std::result::Result<
tonic::Response<super::InterruptExecutionResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/InterruptExecution",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"InterruptExecution",
),
);
self.inner.unary(req, path, codec).await
}
pub async fn restart_interpreter(
&mut self,
request: impl tonic::IntoRequest<super::RestartInterpreterRequest>,
) -> std::result::Result<
tonic::Response<super::RestartInterpreterResponse>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/nominal.codesandbox.v1.CodeSandboxService/RestartInterpreter",
);
let mut req = request.into_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"nominal.codesandbox.v1.CodeSandboxService",
"RestartInterpreter",
),
);
self.inner.unary(req, path, codec).await
}
}
}