model_operator_config.go•4.54 kB
/*
Metoro API
API for managing Metoro environments, alerts, and dashboards.
API version: 1.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package model
import (
"bytes"
"encoding/json"
"fmt"
)
// checks if the OperatorConfig type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &OperatorConfig{}
// OperatorConfig struct for OperatorConfig
type OperatorConfig struct {
Operator OperatorType `json:"operator"`
// Threshold value for comparison
Threshold float64 `json:"threshold"`
}
type _OperatorConfig OperatorConfig
// NewOperatorConfig instantiates a new OperatorConfig 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 NewOperatorConfig(operator OperatorType, threshold float64) *OperatorConfig {
this := OperatorConfig{}
this.Operator = operator
this.Threshold = threshold
return &this
}
// NewOperatorConfigWithDefaults instantiates a new OperatorConfig 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 NewOperatorConfigWithDefaults() *OperatorConfig {
this := OperatorConfig{}
return &this
}
// GetOperator returns the Operator field value
func (o *OperatorConfig) GetOperator() OperatorType {
if o == nil {
var ret OperatorType
return ret
}
return o.Operator
}
// GetOperatorOk returns a tuple with the Operator field value
// and a boolean to check if the value has been set.
func (o *OperatorConfig) GetOperatorOk() (*OperatorType, bool) {
if o == nil {
return nil, false
}
return &o.Operator, true
}
// SetOperator sets field value
func (o *OperatorConfig) SetOperator(v OperatorType) {
o.Operator = v
}
// GetThreshold returns the Threshold field value
func (o *OperatorConfig) GetThreshold() float64 {
if o == nil {
var ret float64
return ret
}
return o.Threshold
}
// GetThresholdOk returns a tuple with the Threshold field value
// and a boolean to check if the value has been set.
func (o *OperatorConfig) GetThresholdOk() (*float64, bool) {
if o == nil {
return nil, false
}
return &o.Threshold, true
}
// SetThreshold sets field value
func (o *OperatorConfig) SetThreshold(v float64) {
o.Threshold = v
}
func (o OperatorConfig) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o OperatorConfig) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["operator"] = o.Operator
toSerialize["threshold"] = o.Threshold
return toSerialize, nil
}
func (o *OperatorConfig) 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{
"operator",
"threshold",
}
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)
}
}
varOperatorConfig := _OperatorConfig{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varOperatorConfig)
if err != nil {
return err
}
*o = OperatorConfig(varOperatorConfig)
return err
}
type NullableOperatorConfig struct {
value *OperatorConfig
isSet bool
}
func (v NullableOperatorConfig) Get() *OperatorConfig {
return v.value
}
func (v *NullableOperatorConfig) Set(val *OperatorConfig) {
v.value = val
v.isSet = true
}
func (v NullableOperatorConfig) IsSet() bool {
return v.isSet
}
func (v *NullableOperatorConfig) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableOperatorConfig(val *OperatorConfig) *NullableOperatorConfig {
return &NullableOperatorConfig{value: val, isSet: true}
}
func (v NullableOperatorConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableOperatorConfig) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}