model_alert.go•5.04 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 Alert type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Alert{}
// Alert struct for Alert
type Alert struct {
Metadata MetadataObject `json:"metadata"`
Type *AlertType `json:"type,omitempty"`
Timeseries TimeseriesConfig `json:"timeseries"`
}
type _Alert Alert
// NewAlert instantiates a new Alert 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 NewAlert(metadata MetadataObject, timeseries TimeseriesConfig) *Alert {
this := Alert{}
this.Metadata = metadata
this.Timeseries = timeseries
return &this
}
// NewAlertWithDefaults instantiates a new Alert 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 NewAlertWithDefaults() *Alert {
this := Alert{}
return &this
}
// GetMetadata returns the Metadata field value
func (o *Alert) GetMetadata() MetadataObject {
if o == nil {
var ret MetadataObject
return ret
}
return o.Metadata
}
// GetMetadataOk returns a tuple with the Metadata field value
// and a boolean to check if the value has been set.
func (o *Alert) GetMetadataOk() (*MetadataObject, bool) {
if o == nil {
return nil, false
}
return &o.Metadata, true
}
// SetMetadata sets field value
func (o *Alert) SetMetadata(v MetadataObject) {
o.Metadata = v
}
// GetType returns the Type field value if set, zero value otherwise.
func (o *Alert) GetType() AlertType {
if o == nil || IsNil(o.Type) {
var ret AlertType
return ret
}
return *o.Type
}
// GetTypeOk returns a tuple with the Type field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Alert) GetTypeOk() (*AlertType, bool) {
if o == nil || IsNil(o.Type) {
return nil, false
}
return o.Type, true
}
// HasType returns a boolean if a field has been set.
func (o *Alert) HasType() bool {
if o != nil && !IsNil(o.Type) {
return true
}
return false
}
// SetType gets a reference to the given AlertType and assigns it to the Type field.
func (o *Alert) SetType(v AlertType) {
o.Type = &v
}
// GetTimeseries returns the Timeseries field value
func (o *Alert) GetTimeseries() TimeseriesConfig {
if o == nil {
var ret TimeseriesConfig
return ret
}
return o.Timeseries
}
// GetTimeseriesOk returns a tuple with the Timeseries field value
// and a boolean to check if the value has been set.
func (o *Alert) GetTimeseriesOk() (*TimeseriesConfig, bool) {
if o == nil {
return nil, false
}
return &o.Timeseries, true
}
// SetTimeseries sets field value
func (o *Alert) SetTimeseries(v TimeseriesConfig) {
o.Timeseries = v
}
func (o Alert) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o Alert) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["metadata"] = o.Metadata
if !IsNil(o.Type) {
toSerialize["type"] = o.Type
}
toSerialize["timeseries"] = o.Timeseries
return toSerialize, nil
}
func (o *Alert) 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{
"metadata",
"timeseries",
}
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)
}
}
varAlert := _Alert{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varAlert)
if err != nil {
return err
}
*o = Alert(varAlert)
return err
}
type NullableAlert struct {
value *Alert
isSet bool
}
func (v NullableAlert) Get() *Alert {
return v.value
}
func (v *NullableAlert) Set(val *Alert) {
v.value = val
v.isSet = true
}
func (v NullableAlert) IsSet() bool {
return v.isSet
}
func (v *NullableAlert) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableAlert(val *Alert) *NullableAlert {
return &NullableAlert{value: val, isSet: true}
}
func (v NullableAlert) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableAlert) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}