model_condition.go•6.34 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 Condition type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Condition{}
// Condition struct for Condition
type Condition struct {
// Name of the condition
Name string `json:"name"`
Type *ConditionType `json:"type,omitempty"`
Static *StaticCondition `json:"static,omitempty"`
// Actions to take when condition is met
Actions []Action `json:"actions,omitempty"`
}
type _Condition Condition
// NewCondition instantiates a new Condition 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 NewCondition(name string) *Condition {
this := Condition{}
this.Name = name
return &this
}
// NewConditionWithDefaults instantiates a new Condition 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 NewConditionWithDefaults() *Condition {
this := Condition{}
return &this
}
// GetName returns the Name field value
func (o *Condition) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *Condition) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *Condition) SetName(v string) {
o.Name = v
}
// GetType returns the Type field value if set, zero value otherwise.
func (o *Condition) GetType() ConditionType {
if o == nil || IsNil(o.Type) {
var ret ConditionType
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 *Condition) GetTypeOk() (*ConditionType, 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 *Condition) HasType() bool {
if o != nil && !IsNil(o.Type) {
return true
}
return false
}
// SetType gets a reference to the given ConditionType and assigns it to the Type field.
func (o *Condition) SetType(v ConditionType) {
o.Type = &v
}
// GetStatic returns the Static field value if set, zero value otherwise.
func (o *Condition) GetStatic() StaticCondition {
if o == nil || IsNil(o.Static) {
var ret StaticCondition
return ret
}
return *o.Static
}
// GetStaticOk returns a tuple with the Static field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Condition) GetStaticOk() (*StaticCondition, bool) {
if o == nil || IsNil(o.Static) {
return nil, false
}
return o.Static, true
}
// HasStatic returns a boolean if a field has been set.
func (o *Condition) HasStatic() bool {
if o != nil && !IsNil(o.Static) {
return true
}
return false
}
// SetStatic gets a reference to the given StaticCondition and assigns it to the Static field.
func (o *Condition) SetStatic(v StaticCondition) {
o.Static = &v
}
// GetActions returns the Actions field value if set, zero value otherwise.
func (o *Condition) GetActions() []Action {
if o == nil || IsNil(o.Actions) {
var ret []Action
return ret
}
return o.Actions
}
// GetActionsOk returns a tuple with the Actions field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Condition) GetActionsOk() ([]Action, bool) {
if o == nil || IsNil(o.Actions) {
return nil, false
}
return o.Actions, true
}
// HasActions returns a boolean if a field has been set.
func (o *Condition) HasActions() bool {
if o != nil && !IsNil(o.Actions) {
return true
}
return false
}
// SetActions gets a reference to the given []Action and assigns it to the Actions field.
func (o *Condition) SetActions(v []Action) {
o.Actions = v
}
func (o Condition) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o Condition) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["name"] = o.Name
if !IsNil(o.Type) {
toSerialize["type"] = o.Type
}
if !IsNil(o.Static) {
toSerialize["static"] = o.Static
}
if !IsNil(o.Actions) {
toSerialize["actions"] = o.Actions
}
return toSerialize, nil
}
func (o *Condition) 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{
"name",
}
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)
}
}
varCondition := _Condition{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCondition)
if err != nil {
return err
}
*o = Condition(varCondition)
return err
}
type NullableCondition struct {
value *Condition
isSet bool
}
func (v NullableCondition) Get() *Condition {
return v.value
}
func (v *NullableCondition) Set(val *Condition) {
v.value = val
v.isSet = true
}
func (v NullableCondition) IsSet() bool {
return v.isSet
}
func (v *NullableCondition) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCondition(val *Condition) *NullableCondition {
return &NullableCondition{value: val, isSet: true}
}
func (v NullableCondition) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCondition) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}