Skip to main content

hanzo_client/models/
code_run.rs

1/*
2 * Hanzo Cloud API
3 *
4 * The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
5 *
6 * The version of the OpenAPI document: v1
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct CodeRun {
16    /// Args become the PROGRAM's argv, never the compiler's. For the compiled languages the toolchain builds first and these are passed to the binary it produced.
17    #[serde(rename = "args", skip_serializing_if = "Option::is_none")]
18    pub args: Option<Vec<String>>,
19    /// Code is the WHOLE program, not a fragment: it is written to a single file and that file is what runs, so a compiled language needs its entry point and an interpreted one runs top to bottom.
20    #[serde(rename = "code")]
21    pub code: String,
22    /// Files are inputs the host already put in some session. Each names the session its bytes live in, which is usually — and ideally — the session this run wants.
23    #[serde(rename = "files", skip_serializing_if = "Option::is_none")]
24    pub files: Option<Vec<models::CodeFile>>,
25    /// Lang selects the toolchain, and with it the filename the code is written to and the line that runs it: py, js, ts, bash, r, php, go, rs, c, cpp, java, d, f90. Anything else is refused rather than guessed at — a run in the wrong language fails somewhere deep in a compiler, which reads as an outage.
26    #[serde(rename = "lang")]
27    pub lang: String,
28    /// RuntimeSessionHint is the stateful-session hint. It is carried so a client that sends it is not silently misread, and it selects nothing here: every session in this implementation is already a warm sandbox, so there is no second kind of runtime for a hint to choose between.
29    #[serde(rename = "runtime_session_hint", skip_serializing_if = "Option::is_none")]
30    pub runtime_session_hint: Option<String>,
31    /// SessionID continues an EXISTING sandbox, which is what makes runs stateful: the same filesystem, so one run's output file is the next run's input. Empty leases a fresh sandbox and the id it got comes back on the result.
32    #[serde(rename = "session_id", skip_serializing_if = "Option::is_none")]
33    pub session_id: Option<String>,
34    /// UserID attributes the run inside the caller's org. It is a label, never a tenant: the org is resolved from the validated principal and a value here cannot widen what the run may reach.
35    #[serde(rename = "user_id", skip_serializing_if = "Option::is_none")]
36    pub user_id: Option<String>,
37}
38
39impl CodeRun {
40    pub fn new(code: String, lang: String) -> CodeRun {
41        CodeRun {
42            args: None,
43            code,
44            files: None,
45            lang,
46            runtime_session_hint: None,
47            session_id: None,
48            user_id: None,
49        }
50    }
51}
52