model_create_update_alert_request.go•4.27 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 CreateUpdateAlertRequest type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateUpdateAlertRequest{}
// CreateUpdateAlertRequest Request to create a new alert or update an existing one. If alert.metadata.id is provided and matches an existing alert, that alert will be updated.
type CreateUpdateAlertRequest struct {
Alert Alert `json:"alert"`
}
type _CreateUpdateAlertRequest CreateUpdateAlertRequest
// NewCreateUpdateAlertRequest instantiates a new CreateUpdateAlertRequest 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 NewCreateUpdateAlertRequest(alert Alert) *CreateUpdateAlertRequest {
this := CreateUpdateAlertRequest{}
this.Alert = alert
return &this
}
// NewCreateUpdateAlertRequestWithDefaults instantiates a new CreateUpdateAlertRequest 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 NewCreateUpdateAlertRequestWithDefaults() *CreateUpdateAlertRequest {
this := CreateUpdateAlertRequest{}
return &this
}
// GetAlert returns the Alert field value
func (o *CreateUpdateAlertRequest) GetAlert() Alert {
if o == nil {
var ret Alert
return ret
}
return o.Alert
}
// GetAlertOk returns a tuple with the Alert field value
// and a boolean to check if the value has been set.
func (o *CreateUpdateAlertRequest) GetAlertOk() (*Alert, bool) {
if o == nil {
return nil, false
}
return &o.Alert, true
}
// SetAlert sets field value
func (o *CreateUpdateAlertRequest) SetAlert(v Alert) {
o.Alert = v
}
func (o CreateUpdateAlertRequest) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o CreateUpdateAlertRequest) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["alert"] = o.Alert
return toSerialize, nil
}
func (o *CreateUpdateAlertRequest) 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{
"alert",
}
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)
}
}
varCreateUpdateAlertRequest := _CreateUpdateAlertRequest{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCreateUpdateAlertRequest)
if err != nil {
return err
}
*o = CreateUpdateAlertRequest(varCreateUpdateAlertRequest)
return err
}
type NullableCreateUpdateAlertRequest struct {
value *CreateUpdateAlertRequest
isSet bool
}
func (v NullableCreateUpdateAlertRequest) Get() *CreateUpdateAlertRequest {
return v.value
}
func (v *NullableCreateUpdateAlertRequest) Set(val *CreateUpdateAlertRequest) {
v.value = val
v.isSet = true
}
func (v NullableCreateUpdateAlertRequest) IsSet() bool {
return v.isSet
}
func (v *NullableCreateUpdateAlertRequest) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCreateUpdateAlertRequest(val *CreateUpdateAlertRequest) *NullableCreateUpdateAlertRequest {
return &NullableCreateUpdateAlertRequest{value: val, isSet: true}
}
func (v NullableCreateUpdateAlertRequest) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCreateUpdateAlertRequest) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}