model_persistence_settings.go•7.14 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 PersistenceSettings type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &PersistenceSettings{}
// PersistenceSettings struct for PersistenceSettings
type PersistenceSettings struct {
// Number of data points that must breach the threshold within the evaluation window to trigger an alert.
DatapointsToAlarm int64 `json:"datapointsToAlarm"`
// Total number of data points in the evaluation window. If your bucketSize is 60 (seconds) and datapointsInEvaluationWindow is 5, then the evaluation window is 5 minutes.
DatapointsInEvaluationWindow int64 `json:"datapointsInEvaluationWindow"`
// Determines how missing data points are treated - either as breaching the threshold or not breaching.
MissingDatapointBehavior *string `json:"missingDatapointBehavior,omitempty"`
}
type _PersistenceSettings PersistenceSettings
// NewPersistenceSettings instantiates a new PersistenceSettings 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 NewPersistenceSettings(datapointsToAlarm int64, datapointsInEvaluationWindow int64) *PersistenceSettings {
this := PersistenceSettings{}
this.DatapointsToAlarm = datapointsToAlarm
this.DatapointsInEvaluationWindow = datapointsInEvaluationWindow
var missingDatapointBehavior string = "notBreaching"
this.MissingDatapointBehavior = &missingDatapointBehavior
return &this
}
// NewPersistenceSettingsWithDefaults instantiates a new PersistenceSettings 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 NewPersistenceSettingsWithDefaults() *PersistenceSettings {
this := PersistenceSettings{}
var missingDatapointBehavior string = "notBreaching"
this.MissingDatapointBehavior = &missingDatapointBehavior
return &this
}
// GetDatapointsToAlarm returns the DatapointsToAlarm field value
func (o *PersistenceSettings) GetDatapointsToAlarm() int64 {
if o == nil {
var ret int64
return ret
}
return o.DatapointsToAlarm
}
// GetDatapointsToAlarmOk returns a tuple with the DatapointsToAlarm field value
// and a boolean to check if the value has been set.
func (o *PersistenceSettings) GetDatapointsToAlarmOk() (*int64, bool) {
if o == nil {
return nil, false
}
return &o.DatapointsToAlarm, true
}
// SetDatapointsToAlarm sets field value
func (o *PersistenceSettings) SetDatapointsToAlarm(v int64) {
o.DatapointsToAlarm = v
}
// GetDatapointsInEvaluationWindow returns the DatapointsInEvaluationWindow field value
func (o *PersistenceSettings) GetDatapointsInEvaluationWindow() int64 {
if o == nil {
var ret int64
return ret
}
return o.DatapointsInEvaluationWindow
}
// GetDatapointsInEvaluationWindowOk returns a tuple with the DatapointsInEvaluationWindow field value
// and a boolean to check if the value has been set.
func (o *PersistenceSettings) GetDatapointsInEvaluationWindowOk() (*int64, bool) {
if o == nil {
return nil, false
}
return &o.DatapointsInEvaluationWindow, true
}
// SetDatapointsInEvaluationWindow sets field value
func (o *PersistenceSettings) SetDatapointsInEvaluationWindow(v int64) {
o.DatapointsInEvaluationWindow = v
}
// GetMissingDatapointBehavior returns the MissingDatapointBehavior field value if set, zero value otherwise.
func (o *PersistenceSettings) GetMissingDatapointBehavior() string {
if o == nil || IsNil(o.MissingDatapointBehavior) {
var ret string
return ret
}
return *o.MissingDatapointBehavior
}
// GetMissingDatapointBehaviorOk returns a tuple with the MissingDatapointBehavior field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *PersistenceSettings) GetMissingDatapointBehaviorOk() (*string, bool) {
if o == nil || IsNil(o.MissingDatapointBehavior) {
return nil, false
}
return o.MissingDatapointBehavior, true
}
// HasMissingDatapointBehavior returns a boolean if a field has been set.
func (o *PersistenceSettings) HasMissingDatapointBehavior() bool {
if o != nil && !IsNil(o.MissingDatapointBehavior) {
return true
}
return false
}
// SetMissingDatapointBehavior gets a reference to the given string and assigns it to the MissingDatapointBehavior field.
func (o *PersistenceSettings) SetMissingDatapointBehavior(v string) {
o.MissingDatapointBehavior = &v
}
func (o PersistenceSettings) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o PersistenceSettings) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["datapointsToAlarm"] = o.DatapointsToAlarm
toSerialize["datapointsInEvaluationWindow"] = o.DatapointsInEvaluationWindow
if !IsNil(o.MissingDatapointBehavior) {
toSerialize["missingDatapointBehavior"] = o.MissingDatapointBehavior
}
return toSerialize, nil
}
func (o *PersistenceSettings) 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{
"datapointsToAlarm",
"datapointsInEvaluationWindow",
}
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)
}
}
varPersistenceSettings := _PersistenceSettings{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varPersistenceSettings)
if err != nil {
return err
}
*o = PersistenceSettings(varPersistenceSettings)
return err
}
type NullablePersistenceSettings struct {
value *PersistenceSettings
isSet bool
}
func (v NullablePersistenceSettings) Get() *PersistenceSettings {
return v.value
}
func (v *NullablePersistenceSettings) Set(val *PersistenceSettings) {
v.value = val
v.isSet = true
}
func (v NullablePersistenceSettings) IsSet() bool {
return v.isSet
}
func (v *NullablePersistenceSettings) Unset() {
v.value = nil
v.isSet = false
}
func NewNullablePersistenceSettings(val *PersistenceSettings) *NullablePersistenceSettings {
return &NullablePersistenceSettings{value: val, isSet: true}
}
func (v NullablePersistenceSettings) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullablePersistenceSettings) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}