model_timeseries_config.go•4.85 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 TimeseriesConfig type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &TimeseriesConfig{}
// TimeseriesConfig struct for TimeseriesConfig
type TimeseriesConfig struct {
Expression ExpressionConfig `json:"expression"`
// Rules for evaluating the metrics and triggering alerts
EvaluationRules []Condition `json:"evaluationRules"`
}
type _TimeseriesConfig TimeseriesConfig
// NewTimeseriesConfig instantiates a new TimeseriesConfig 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 NewTimeseriesConfig(expression ExpressionConfig, evaluationRules []Condition) *TimeseriesConfig {
this := TimeseriesConfig{}
this.Expression = expression
this.EvaluationRules = evaluationRules
return &this
}
// NewTimeseriesConfigWithDefaults instantiates a new TimeseriesConfig 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 NewTimeseriesConfigWithDefaults() *TimeseriesConfig {
this := TimeseriesConfig{}
return &this
}
// GetExpression returns the Expression field value
func (o *TimeseriesConfig) GetExpression() ExpressionConfig {
if o == nil {
var ret ExpressionConfig
return ret
}
return o.Expression
}
// GetExpressionOk returns a tuple with the Expression field value
// and a boolean to check if the value has been set.
func (o *TimeseriesConfig) GetExpressionOk() (*ExpressionConfig, bool) {
if o == nil {
return nil, false
}
return &o.Expression, true
}
// SetExpression sets field value
func (o *TimeseriesConfig) SetExpression(v ExpressionConfig) {
o.Expression = v
}
// GetEvaluationRules returns the EvaluationRules field value
func (o *TimeseriesConfig) GetEvaluationRules() []Condition {
if o == nil {
var ret []Condition
return ret
}
return o.EvaluationRules
}
// GetEvaluationRulesOk returns a tuple with the EvaluationRules field value
// and a boolean to check if the value has been set.
func (o *TimeseriesConfig) GetEvaluationRulesOk() ([]Condition, bool) {
if o == nil {
return nil, false
}
return o.EvaluationRules, true
}
// SetEvaluationRules sets field value
func (o *TimeseriesConfig) SetEvaluationRules(v []Condition) {
o.EvaluationRules = v
}
func (o TimeseriesConfig) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o TimeseriesConfig) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["expression"] = o.Expression
toSerialize["evaluationRules"] = o.EvaluationRules
return toSerialize, nil
}
func (o *TimeseriesConfig) 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{
"expression",
"evaluationRules",
}
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)
}
}
varTimeseriesConfig := _TimeseriesConfig{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varTimeseriesConfig)
if err != nil {
return err
}
*o = TimeseriesConfig(varTimeseriesConfig)
return err
}
type NullableTimeseriesConfig struct {
value *TimeseriesConfig
isSet bool
}
func (v NullableTimeseriesConfig) Get() *TimeseriesConfig {
return v.value
}
func (v *NullableTimeseriesConfig) Set(val *TimeseriesConfig) {
v.value = val
v.isSet = true
}
func (v NullableTimeseriesConfig) IsSet() bool {
return v.isSet
}
func (v *NullableTimeseriesConfig) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTimeseriesConfig(val *TimeseriesConfig) *NullableTimeseriesConfig {
return &NullableTimeseriesConfig{value: val, isSet: true}
}
func (v NullableTimeseriesConfig) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTimeseriesConfig) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}