Files
sdk/model_exec_code_run.go

388 lines
11 KiB
Go

/*
Hanzo Cloud API
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/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"encoding/json"
"fmt"
)
// checks if the ExecCodeRun type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &ExecCodeRun{}
// ExecCodeRun struct for ExecCodeRun
type ExecCodeRun struct {
// 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.
Args []string `json:"args,omitempty"`
// 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.
Code string `json:"code"`
// 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.
Files []ExecCodeFile `json:"files,omitempty"`
// 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.
Lang string `json:"lang"`
// 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.
RuntimeSessionHint *string `json:"runtime_session_hint,omitempty"`
// 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.
SessionId *string `json:"session_id,omitempty"`
// 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.
UserId *string `json:"user_id,omitempty"`
AdditionalProperties map[string]interface{}
}
type _ExecCodeRun ExecCodeRun
// NewExecCodeRun instantiates a new ExecCodeRun object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewExecCodeRun(code string, lang string) *ExecCodeRun {
this := ExecCodeRun{}
this.Code = code
this.Lang = lang
return &this
}
// NewExecCodeRunWithDefaults instantiates a new ExecCodeRun object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewExecCodeRunWithDefaults() *ExecCodeRun {
this := ExecCodeRun{}
return &this
}
// GetArgs returns the Args field value if set, zero value otherwise.
func (o *ExecCodeRun) GetArgs() []string {
if o == nil || IsNil(o.Args) {
var ret []string
return ret
}
return o.Args
}
// GetArgsOk returns a tuple with the Args field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetArgsOk() ([]string, bool) {
if o == nil || IsNil(o.Args) {
return nil, false
}
return o.Args, true
}
// HasArgs returns a boolean if a field has been set.
func (o *ExecCodeRun) HasArgs() bool {
if o != nil && !IsNil(o.Args) {
return true
}
return false
}
// SetArgs gets a reference to the given []string and assigns it to the Args field.
func (o *ExecCodeRun) SetArgs(v []string) {
o.Args = v
}
// GetCode returns the Code field value
func (o *ExecCodeRun) GetCode() string {
if o == nil {
var ret string
return ret
}
return o.Code
}
// GetCodeOk returns a tuple with the Code field value
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetCodeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Code, true
}
// SetCode sets field value
func (o *ExecCodeRun) SetCode(v string) {
o.Code = v
}
// GetFiles returns the Files field value if set, zero value otherwise.
func (o *ExecCodeRun) GetFiles() []ExecCodeFile {
if o == nil || IsNil(o.Files) {
var ret []ExecCodeFile
return ret
}
return o.Files
}
// GetFilesOk returns a tuple with the Files field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetFilesOk() ([]ExecCodeFile, bool) {
if o == nil || IsNil(o.Files) {
return nil, false
}
return o.Files, true
}
// HasFiles returns a boolean if a field has been set.
func (o *ExecCodeRun) HasFiles() bool {
if o != nil && !IsNil(o.Files) {
return true
}
return false
}
// SetFiles gets a reference to the given []ExecCodeFile and assigns it to the Files field.
func (o *ExecCodeRun) SetFiles(v []ExecCodeFile) {
o.Files = v
}
// GetLang returns the Lang field value
func (o *ExecCodeRun) GetLang() string {
if o == nil {
var ret string
return ret
}
return o.Lang
}
// GetLangOk returns a tuple with the Lang field value
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetLangOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Lang, true
}
// SetLang sets field value
func (o *ExecCodeRun) SetLang(v string) {
o.Lang = v
}
// GetRuntimeSessionHint returns the RuntimeSessionHint field value if set, zero value otherwise.
func (o *ExecCodeRun) GetRuntimeSessionHint() string {
if o == nil || IsNil(o.RuntimeSessionHint) {
var ret string
return ret
}
return *o.RuntimeSessionHint
}
// GetRuntimeSessionHintOk returns a tuple with the RuntimeSessionHint field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetRuntimeSessionHintOk() (*string, bool) {
if o == nil || IsNil(o.RuntimeSessionHint) {
return nil, false
}
return o.RuntimeSessionHint, true
}
// HasRuntimeSessionHint returns a boolean if a field has been set.
func (o *ExecCodeRun) HasRuntimeSessionHint() bool {
if o != nil && !IsNil(o.RuntimeSessionHint) {
return true
}
return false
}
// SetRuntimeSessionHint gets a reference to the given string and assigns it to the RuntimeSessionHint field.
func (o *ExecCodeRun) SetRuntimeSessionHint(v string) {
o.RuntimeSessionHint = &v
}
// GetSessionId returns the SessionId field value if set, zero value otherwise.
func (o *ExecCodeRun) GetSessionId() string {
if o == nil || IsNil(o.SessionId) {
var ret string
return ret
}
return *o.SessionId
}
// GetSessionIdOk returns a tuple with the SessionId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetSessionIdOk() (*string, bool) {
if o == nil || IsNil(o.SessionId) {
return nil, false
}
return o.SessionId, true
}
// HasSessionId returns a boolean if a field has been set.
func (o *ExecCodeRun) HasSessionId() bool {
if o != nil && !IsNil(o.SessionId) {
return true
}
return false
}
// SetSessionId gets a reference to the given string and assigns it to the SessionId field.
func (o *ExecCodeRun) SetSessionId(v string) {
o.SessionId = &v
}
// GetUserId returns the UserId field value if set, zero value otherwise.
func (o *ExecCodeRun) GetUserId() string {
if o == nil || IsNil(o.UserId) {
var ret string
return ret
}
return *o.UserId
}
// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *ExecCodeRun) GetUserIdOk() (*string, bool) {
if o == nil || IsNil(o.UserId) {
return nil, false
}
return o.UserId, true
}
// HasUserId returns a boolean if a field has been set.
func (o *ExecCodeRun) HasUserId() bool {
if o != nil && !IsNil(o.UserId) {
return true
}
return false
}
// SetUserId gets a reference to the given string and assigns it to the UserId field.
func (o *ExecCodeRun) SetUserId(v string) {
o.UserId = &v
}
func (o ExecCodeRun) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o ExecCodeRun) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Args) {
toSerialize["args"] = o.Args
}
toSerialize["code"] = o.Code
if !IsNil(o.Files) {
toSerialize["files"] = o.Files
}
toSerialize["lang"] = o.Lang
if !IsNil(o.RuntimeSessionHint) {
toSerialize["runtime_session_hint"] = o.RuntimeSessionHint
}
if !IsNil(o.SessionId) {
toSerialize["session_id"] = o.SessionId
}
if !IsNil(o.UserId) {
toSerialize["user_id"] = o.UserId
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *ExecCodeRun) UnmarshalJSON(data []byte) (err error) {
// This validates that all required properties are included in the JSON object
// by unmarshalling the object into a generic map with string keys and checking
// that every required field exists as a key in the generic map.
requiredProperties := []string{
"code",
"lang",
}
allProperties := make(map[string]interface{})
err = json.Unmarshal(data, &allProperties)
if err != nil {
return err
}
for _, requiredProperty := range requiredProperties {
if _, exists := allProperties[requiredProperty]; !exists {
return fmt.Errorf("no value given for required property %v", requiredProperty)
}
}
varExecCodeRun := _ExecCodeRun{}
err = json.Unmarshal(data, &varExecCodeRun)
if err != nil {
return err
}
*o = ExecCodeRun(varExecCodeRun)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "args")
delete(additionalProperties, "code")
delete(additionalProperties, "files")
delete(additionalProperties, "lang")
delete(additionalProperties, "runtime_session_hint")
delete(additionalProperties, "session_id")
delete(additionalProperties, "user_id")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableExecCodeRun struct {
value *ExecCodeRun
isSet bool
}
func (v NullableExecCodeRun) Get() *ExecCodeRun {
return v.value
}
func (v *NullableExecCodeRun) Set(val *ExecCodeRun) {
v.value = val
v.isSet = true
}
func (v NullableExecCodeRun) IsSet() bool {
return v.isSet
}
func (v *NullableExecCodeRun) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableExecCodeRun(val *ExecCodeRun) *NullableExecCodeRun {
return &NullableExecCodeRun{value: val, isSet: true}
}
func (v NullableExecCodeRun) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableExecCodeRun) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}