model_timeseries_specifier_function.go•5.81 kB
/*
Metoro Alerts API
API for managing alerts in the Metoro observability platform.
API version: 1.0.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package model
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the TimeseriesSpecifierFunction type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &TimeseriesSpecifierFunction{}
// TimeseriesSpecifierFunction Function to apply to the timeseries
type TimeseriesSpecifierFunction struct {
// Type of function to apply
FunctionType string `json:"functionType"`
MathExpression *TimeseriesSpecifierFunctionsMathExpression `json:"mathExpression,omitempty"`
}
type _TimeseriesSpecifierFunction TimeseriesSpecifierFunction
// NewTimeseriesSpecifierFunction instantiates a new TimeseriesSpecifierFunction 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 NewTimeseriesSpecifierFunction(functionType string) *TimeseriesSpecifierFunction {
this := TimeseriesSpecifierFunction{}
this.FunctionType = functionType
return &this
}
// NewTimeseriesSpecifierFunctionWithDefaults instantiates a new TimeseriesSpecifierFunction 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 NewTimeseriesSpecifierFunctionWithDefaults() *TimeseriesSpecifierFunction {
this := TimeseriesSpecifierFunction{}
return &this
}
// GetFunctionType returns the FunctionType field value
func (o *TimeseriesSpecifierFunction) GetFunctionType() string {
if o == nil {
var ret string
return ret
}
return o.FunctionType
}
// GetFunctionTypeOk returns a tuple with the FunctionType field value
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifierFunction) GetFunctionTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.FunctionType, true
}
// SetFunctionType sets field value
func (o *TimeseriesSpecifierFunction) SetFunctionType(v string) {
o.FunctionType = v
}
// GetMathExpression returns the MathExpression field value if set, zero value otherwise.
func (o *TimeseriesSpecifierFunction) GetMathExpression() TimeseriesSpecifierFunctionsMathExpression {
if o == nil || IsNil(o.MathExpression) {
var ret TimeseriesSpecifierFunctionsMathExpression
return ret
}
return *o.MathExpression
}
// GetMathExpressionOk returns a tuple with the MathExpression field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *TimeseriesSpecifierFunction) GetMathExpressionOk() (*TimeseriesSpecifierFunctionsMathExpression, bool) {
if o == nil || IsNil(o.MathExpression) {
return nil, false
}
return o.MathExpression, true
}
// HasMathExpression returns a boolean if a field has been set.
func (o *TimeseriesSpecifierFunction) HasMathExpression() bool {
if o != nil && !IsNil(o.MathExpression) {
return true
}
return false
}
// SetMathExpression gets a reference to the given TimeseriesSpecifierFunctionsMathExpression and assigns it to the MathExpression field.
func (o *TimeseriesSpecifierFunction) SetMathExpression(v TimeseriesSpecifierFunctionsMathExpression) {
o.MathExpression = &v
}
func (o TimeseriesSpecifierFunction) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o TimeseriesSpecifierFunction) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["functionType"] = o.FunctionType
if !IsNil(o.MathExpression) {
toSerialize["mathExpression"] = o.MathExpression
}
return toSerialize, nil
}
func (o *TimeseriesSpecifierFunction) 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{
"functionType",
}
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)
}
}
varTimeseriesSpecifierFunction := _TimeseriesSpecifierFunction{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varTimeseriesSpecifierFunction)
if err != nil {
return err
}
*o = TimeseriesSpecifierFunction(varTimeseriesSpecifierFunction)
return err
}
type NullableTimeseriesSpecifierFunction struct {
value *TimeseriesSpecifierFunction
isSet bool
}
func (v NullableTimeseriesSpecifierFunction) Get() *TimeseriesSpecifierFunction {
return v.value
}
func (v *NullableTimeseriesSpecifierFunction) Set(val *TimeseriesSpecifierFunction) {
v.value = val
v.isSet = true
}
func (v NullableTimeseriesSpecifierFunction) IsSet() bool {
return v.isSet
}
func (v *NullableTimeseriesSpecifierFunction) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableTimeseriesSpecifierFunction(val *TimeseriesSpecifierFunction) *NullableTimeseriesSpecifierFunction {
return &NullableTimeseriesSpecifierFunction{value: val, isSet: true}
}
func (v NullableTimeseriesSpecifierFunction) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableTimeseriesSpecifierFunction) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}