Files
sdk/model_ai_decisions_usage.go

233 lines
6.0 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 AiDecisionsUsage type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &AiDecisionsUsage{}
// AiDecisionsUsage struct for AiDecisionsUsage
type AiDecisionsUsage struct {
Cost *float32 `json:"cost,omitempty"`
InputTokens int32 `json:"input_tokens"`
OutputTokens int32 `json:"output_tokens"`
AdditionalProperties map[string]interface{}
}
type _AiDecisionsUsage AiDecisionsUsage
// NewAiDecisionsUsage instantiates a new AiDecisionsUsage 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 NewAiDecisionsUsage(inputTokens int32, outputTokens int32) *AiDecisionsUsage {
this := AiDecisionsUsage{}
this.InputTokens = inputTokens
this.OutputTokens = outputTokens
return &this
}
// NewAiDecisionsUsageWithDefaults instantiates a new AiDecisionsUsage 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 NewAiDecisionsUsageWithDefaults() *AiDecisionsUsage {
this := AiDecisionsUsage{}
return &this
}
// GetCost returns the Cost field value if set, zero value otherwise.
func (o *AiDecisionsUsage) GetCost() float32 {
if o == nil || IsNil(o.Cost) {
var ret float32
return ret
}
return *o.Cost
}
// GetCostOk returns a tuple with the Cost field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *AiDecisionsUsage) GetCostOk() (*float32, bool) {
if o == nil || IsNil(o.Cost) {
return nil, false
}
return o.Cost, true
}
// HasCost returns a boolean if a field has been set.
func (o *AiDecisionsUsage) HasCost() bool {
if o != nil && !IsNil(o.Cost) {
return true
}
return false
}
// SetCost gets a reference to the given float32 and assigns it to the Cost field.
func (o *AiDecisionsUsage) SetCost(v float32) {
o.Cost = &v
}
// GetInputTokens returns the InputTokens field value
func (o *AiDecisionsUsage) GetInputTokens() int32 {
if o == nil {
var ret int32
return ret
}
return o.InputTokens
}
// GetInputTokensOk returns a tuple with the InputTokens field value
// and a boolean to check if the value has been set.
func (o *AiDecisionsUsage) GetInputTokensOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.InputTokens, true
}
// SetInputTokens sets field value
func (o *AiDecisionsUsage) SetInputTokens(v int32) {
o.InputTokens = v
}
// GetOutputTokens returns the OutputTokens field value
func (o *AiDecisionsUsage) GetOutputTokens() int32 {
if o == nil {
var ret int32
return ret
}
return o.OutputTokens
}
// GetOutputTokensOk returns a tuple with the OutputTokens field value
// and a boolean to check if the value has been set.
func (o *AiDecisionsUsage) GetOutputTokensOk() (*int32, bool) {
if o == nil {
return nil, false
}
return &o.OutputTokens, true
}
// SetOutputTokens sets field value
func (o *AiDecisionsUsage) SetOutputTokens(v int32) {
o.OutputTokens = v
}
func (o AiDecisionsUsage) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o AiDecisionsUsage) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if !IsNil(o.Cost) {
toSerialize["cost"] = o.Cost
}
toSerialize["input_tokens"] = o.InputTokens
toSerialize["output_tokens"] = o.OutputTokens
for key, value := range o.AdditionalProperties {
toSerialize[key] = value
}
return toSerialize, nil
}
func (o *AiDecisionsUsage) 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{
"input_tokens",
"output_tokens",
}
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)
}
}
varAiDecisionsUsage := _AiDecisionsUsage{}
err = json.Unmarshal(data, &varAiDecisionsUsage)
if err != nil {
return err
}
*o = AiDecisionsUsage(varAiDecisionsUsage)
additionalProperties := make(map[string]interface{})
if err = json.Unmarshal(data, &additionalProperties); err == nil {
delete(additionalProperties, "cost")
delete(additionalProperties, "input_tokens")
delete(additionalProperties, "output_tokens")
o.AdditionalProperties = additionalProperties
}
return err
}
type NullableAiDecisionsUsage struct {
value *AiDecisionsUsage
isSet bool
}
func (v NullableAiDecisionsUsage) Get() *AiDecisionsUsage {
return v.value
}
func (v *NullableAiDecisionsUsage) Set(val *AiDecisionsUsage) {
v.value = val
v.isSet = true
}
func (v NullableAiDecisionsUsage) IsSet() bool {
return v.isSet
}
func (v *NullableAiDecisionsUsage) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableAiDecisionsUsage(val *AiDecisionsUsage) *NullableAiDecisionsUsage {
return &NullableAiDecisionsUsage{value: val, isSet: true}
}
func (v NullableAiDecisionsUsage) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableAiDecisionsUsage) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}