Files
sdk/model_function_definition.go

548 lines
15 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 FunctionDefinition type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &FunctionDefinition{}
// FunctionDefinition struct for FunctionDefinition
type FunctionDefinition struct {
// Code is the source to run, capped so one function cannot amplify the store.
Code *string `json:"code,omitempty"`
// EnvNames are the secret NAMES to mount. Values live in the secret store and are never carried here.
EnvNames []string `json:"envNames,omitempty"`
// Environment is a second spelling of runtime, accepted so a console that says \"environment\" needs no translation.
Environment *string `json:"environment,omitempty"`
// Handler is the entry point within the code.
Handler *string `json:"handler,omitempty"`
// Image names a prebuilt image to run instead of source.
Image *string `json:"image,omitempty"`
// MemoryLimit is the memory the function runs with, defaulting to 256Mi. It is also the multiplier on the GB-seconds compute charge.
MemoryLimit *string `json:"memoryLimit,omitempty"`
// Name is the function's org-unique handle and the segment that addresses it, matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$. The names that would shadow a collection route are reserved.
Name string `json:"name"`
// Namespace groups functions for display. It is cosmetic — the org is the isolation key — and is normalised to a DNS-safe label.
Namespace *string `json:"namespace,omitempty"`
// Runtime is the language the code runs under: node, python or deno.
Runtime *string `json:"runtime,omitempty"`
// Target is where the function runs: sandbox (the default) or fleet, the org's own GPU fleet. fleet supports runtime=python only.
Target *string `json:"target,omitempty"`
// TimeoutSec is the per-invocation deadline, defaulting to 30 and clamped at 900 — a larger value is capped rather than reset to the default.
TimeoutSec *int64 `json:"timeoutSec,omitempty"`
AdditionalProperties map[string]interface{}
}
type _FunctionDefinition FunctionDefinition
// NewFunctionDefinition instantiates a new FunctionDefinition 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 NewFunctionDefinition(name string) *FunctionDefinition {
this := FunctionDefinition{}
this.Name = name
return &this
}
// NewFunctionDefinitionWithDefaults instantiates a new FunctionDefinition 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 NewFunctionDefinitionWithDefaults() *FunctionDefinition {
this := FunctionDefinition{}
return &this
}
// GetCode returns the Code field value if set, zero value otherwise.
func (o *FunctionDefinition) GetCode() string {
if o == nil || IsNil(o.Code) {
var ret string
return ret
}
return *o.Code
}
// GetCodeOk returns a tuple with the Code field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetCodeOk() (*string, bool) {
if o == nil || IsNil(o.Code) {
return nil, false
}
return o.Code, true
}
// HasCode returns a boolean if a field has been set.
func (o *FunctionDefinition) HasCode() bool {
if o != nil && !IsNil(o.Code) {
return true
}
return false
}
// SetCode gets a reference to the given string and assigns it to the Code field.
func (o *FunctionDefinition) SetCode(v string) {
o.Code = &v
}
// GetEnvNames returns the EnvNames field value if set, zero value otherwise.
func (o *FunctionDefinition) GetEnvNames() []string {
if o == nil || IsNil(o.EnvNames) {
var ret []string
return ret
}
return o.EnvNames
}
// GetEnvNamesOk returns a tuple with the EnvNames field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetEnvNamesOk() ([]string, bool) {
if o == nil || IsNil(o.EnvNames) {
return nil, false
}
return o.EnvNames, true
}
// HasEnvNames returns a boolean if a field has been set.
func (o *FunctionDefinition) HasEnvNames() bool {
if o != nil && !IsNil(o.EnvNames) {
return true
}
return false
}
// SetEnvNames gets a reference to the given []string and assigns it to the EnvNames field.
func (o *FunctionDefinition) SetEnvNames(v []string) {
o.EnvNames = v
}
// GetEnvironment returns the Environment field value if set, zero value otherwise.
func (o *FunctionDefinition) GetEnvironment() string {
if o == nil || IsNil(o.Environment) {
var ret string
return ret
}
return *o.Environment
}
// GetEnvironmentOk returns a tuple with the Environment field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetEnvironmentOk() (*string, bool) {
if o == nil || IsNil(o.Environment) {
return nil, false
}
return o.Environment, true
}
// HasEnvironment returns a boolean if a field has been set.
func (o *FunctionDefinition) HasEnvironment() bool {
if o != nil && !IsNil(o.Environment) {
return true
}
return false
}
// SetEnvironment gets a reference to the given string and assigns it to the Environment field.
func (o *FunctionDefinition) SetEnvironment(v string) {
o.Environment = &v
}
// GetHandler returns the Handler field value if set, zero value otherwise.
func (o *FunctionDefinition) GetHandler() string {
if o == nil || IsNil(o.Handler) {
var ret string
return ret
}
return *o.Handler
}
// GetHandlerOk returns a tuple with the Handler field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetHandlerOk() (*string, bool) {
if o == nil || IsNil(o.Handler) {
return nil, false
}
return o.Handler, true
}
// HasHandler returns a boolean if a field has been set.
func (o *FunctionDefinition) HasHandler() bool {
if o != nil && !IsNil(o.Handler) {
return true
}
return false
}
// SetHandler gets a reference to the given string and assigns it to the Handler field.
func (o *FunctionDefinition) SetHandler(v string) {
o.Handler = &v
}
// GetImage returns the Image field value if set, zero value otherwise.
func (o *FunctionDefinition) GetImage() string {
if o == nil || IsNil(o.Image) {
var ret string
return ret
}
return *o.Image
}
// GetImageOk returns a tuple with the Image field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetImageOk() (*string, bool) {
if o == nil || IsNil(o.Image) {
return nil, false
}
return o.Image, true
}
// HasImage returns a boolean if a field has been set.
func (o *FunctionDefinition) HasImage() bool {
if o != nil && !IsNil(o.Image) {
return true
}
return false
}
// SetImage gets a reference to the given string and assigns it to the Image field.
func (o *FunctionDefinition) SetImage(v string) {
o.Image = &v
}
// GetMemoryLimit returns the MemoryLimit field value if set, zero value otherwise.
func (o *FunctionDefinition) GetMemoryLimit() string {
if o == nil || IsNil(o.MemoryLimit) {
var ret string
return ret
}
return *o.MemoryLimit
}
// GetMemoryLimitOk returns a tuple with the MemoryLimit field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetMemoryLimitOk() (*string, bool) {
if o == nil || IsNil(o.MemoryLimit) {
return nil, false
}
return o.MemoryLimit, true
}
// HasMemoryLimit returns a boolean if a field has been set.
func (o *FunctionDefinition) HasMemoryLimit() bool {
if o != nil && !IsNil(o.MemoryLimit) {
return true
}
return false
}
// SetMemoryLimit gets a reference to the given string and assigns it to the MemoryLimit field.
func (o *FunctionDefinition) SetMemoryLimit(v string) {
o.MemoryLimit = &v
}
// GetName returns the Name field value
func (o *FunctionDefinition) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *FunctionDefinition) SetName(v string) {
o.Name = v
}
// GetNamespace returns the Namespace field value if set, zero value otherwise.
func (o *FunctionDefinition) GetNamespace() string {
if o == nil || IsNil(o.Namespace) {
var ret string
return ret
}
return *o.Namespace
}
// GetNamespaceOk returns a tuple with the Namespace field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetNamespaceOk() (*string, bool) {
if o == nil || IsNil(o.Namespace) {
return nil, false
}
return o.Namespace, true
}
// HasNamespace returns a boolean if a field has been set.
func (o *FunctionDefinition) HasNamespace() bool {
if o != nil && !IsNil(o.Namespace) {
return true
}
return false
}
// SetNamespace gets a reference to the given string and assigns it to the Namespace field.
func (o *FunctionDefinition) SetNamespace(v string) {
o.Namespace = &v
}
// GetRuntime returns the Runtime field value if set, zero value otherwise.
func (o *FunctionDefinition) GetRuntime() string {
if o == nil || IsNil(o.Runtime) {
var ret string
return ret
}
return *o.Runtime
}
// GetRuntimeOk returns a tuple with the Runtime field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetRuntimeOk() (*string, bool) {
if o == nil || IsNil(o.Runtime) {
return nil, false
}
return o.Runtime, true
}
// HasRuntime returns a boolean if a field has been set.
func (o *FunctionDefinition) HasRuntime() bool {
if o != nil && !IsNil(o.Runtime) {
return true
}
return false
}
// SetRuntime gets a reference to the given string and assigns it to the Runtime field.
func (o *FunctionDefinition) SetRuntime(v string) {
o.Runtime = &v
}
// GetTarget returns the Target field value if set, zero value otherwise.
func (o *FunctionDefinition) GetTarget() string {
if o == nil || IsNil(o.Target) {
var ret string
return ret
}
return *o.Target
}
// GetTargetOk returns a tuple with the Target field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetTargetOk() (*string, bool) {
if o == nil || IsNil(o.Target) {
return nil, false
}
return o.Target, true
}
// HasTarget returns a boolean if a field has been set.
func (o *FunctionDefinition) HasTarget() bool {
if o != nil && !IsNil(o.Target) {
return true
}
return false
}
// SetTarget gets a reference to the given string and assigns it to the Target field.
func (o *FunctionDefinition) SetTarget(v string) {
o.Target = &v
}
// GetTimeoutSec returns the TimeoutSec field value if set, zero value otherwise.
func (o *FunctionDefinition) GetTimeoutSec() int64 {
if o == nil || IsNil(o.TimeoutSec) {
var ret int64
return ret
}
return *o.TimeoutSec
}
// GetTimeoutSecOk returns a tuple with the TimeoutSec field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *FunctionDefinition) GetTimeoutSecOk() (*int64, bool) {
if o == nil || IsNil(o.TimeoutSec) {
return nil, false
}
return o.TimeoutSec, true
}
// HasTimeoutSec returns a boolean if a field has been set.
func (o *FunctionDefinition) HasTimeoutSec() bool {
if o != nil && !IsNil(o.TimeoutSec) {
return true
}
return false
}
// SetTimeoutSec gets a reference to the given int64 and assigns it to the TimeoutSec field.
func (o *FunctionDefinition) SetTimeoutSec(v int64) {
o.TimeoutSec = &v
}
func (o FunctionDefinition) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o FunctionDefinition) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Code) {
toSerialize["code"] = o.Code
}
if !IsNil(o.EnvNames) {
toSerialize["envNames"] = o.EnvNames
}
if !IsNil(o.Environment) {
toSerialize["environment"] = o.Environment
}
if !IsNil(o.Handler) {
toSerialize["handler"] = o.Handler
}
if !IsNil(o.Image) {
toSerialize["image"] = o.Image
}
if !IsNil(o.MemoryLimit) {
toSerialize["memoryLimit"] = o.MemoryLimit
}
toSerialize["name"] = o.Name
if !IsNil(o.Namespace) {
toSerialize["namespace"] = o.Namespace
}
if !IsNil(o.Runtime) {
toSerialize["runtime"] = o.Runtime
}
if !IsNil(o.Target) {
toSerialize["target"] = o.Target
}
if !IsNil(o.TimeoutSec) {
toSerialize["timeoutSec"] = o.TimeoutSec
}
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *FunctionDefinition) 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{
"name",
}
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)
}
}
varFunctionDefinition := _FunctionDefinition{}
err = json.Unmarshal(data, &varFunctionDefinition)
if err != nil {
return err
}
*o = FunctionDefinition(varFunctionDefinition)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "code")
delete(additionalProperties, "envNames")
delete(additionalProperties, "environment")
delete(additionalProperties, "handler")
delete(additionalProperties, "image")
delete(additionalProperties, "memoryLimit")
delete(additionalProperties, "name")
delete(additionalProperties, "namespace")
delete(additionalProperties, "runtime")
delete(additionalProperties, "target")
delete(additionalProperties, "timeoutSec")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableFunctionDefinition struct {
value *FunctionDefinition
isSet bool
}
func (v NullableFunctionDefinition) Get() *FunctionDefinition {
return v.value
}
func (v *NullableFunctionDefinition) Set(val *FunctionDefinition) {
v.value = val
v.isSet = true
}
func (v NullableFunctionDefinition) IsSet() bool {
return v.isSet
}
func (v *NullableFunctionDefinition) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableFunctionDefinition(val *FunctionDefinition) *NullableFunctionDefinition {
return &NullableFunctionDefinition{value: val, isSet: true}
}
func (v NullableFunctionDefinition) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableFunctionDefinition) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}