model_action.go•8.41 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 Action type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Action{}
// Action struct for Action
type Action struct {
// Type of action destination
Type string `json:"type"`
SlackDestination *ActionSlackDestination `json:"slackDestination,omitempty"`
PagerDutyDestination *ActionPagerDutyDestination `json:"pagerDutyDestination,omitempty"`
EmailDestination *ActionEmailDestination `json:"emailDestination,omitempty"`
WebhookDestination *ActionWebhookDestination `json:"webhookDestination,omitempty"`
}
type _Action Action
// NewAction instantiates a new Action 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 NewAction(type_ string) *Action {
this := Action{}
this.Type = type_
return &this
}
// NewActionWithDefaults instantiates a new Action 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 NewActionWithDefaults() *Action {
this := Action{}
return &this
}
// GetType returns the Type field value
func (o *Action) GetType() string {
if o == nil {
var ret string
return ret
}
return o.Type
}
// GetTypeOk returns a tuple with the Type field value
// and a boolean to check if the value has been set.
func (o *Action) GetTypeOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Type, true
}
// SetType sets field value
func (o *Action) SetType(v string) {
o.Type = v
}
// GetSlackDestination returns the SlackDestination field value if set, zero value otherwise.
func (o *Action) GetSlackDestination() ActionSlackDestination {
if o == nil || IsNil(o.SlackDestination) {
var ret ActionSlackDestination
return ret
}
return *o.SlackDestination
}
// GetSlackDestinationOk returns a tuple with the SlackDestination field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Action) GetSlackDestinationOk() (*ActionSlackDestination, bool) {
if o == nil || IsNil(o.SlackDestination) {
return nil, false
}
return o.SlackDestination, true
}
// HasSlackDestination returns a boolean if a field has been set.
func (o *Action) HasSlackDestination() bool {
if o != nil && !IsNil(o.SlackDestination) {
return true
}
return false
}
// SetSlackDestination gets a reference to the given ActionSlackDestination and assigns it to the SlackDestination field.
func (o *Action) SetSlackDestination(v ActionSlackDestination) {
o.SlackDestination = &v
}
// GetPagerDutyDestination returns the PagerDutyDestination field value if set, zero value otherwise.
func (o *Action) GetPagerDutyDestination() ActionPagerDutyDestination {
if o == nil || IsNil(o.PagerDutyDestination) {
var ret ActionPagerDutyDestination
return ret
}
return *o.PagerDutyDestination
}
// GetPagerDutyDestinationOk returns a tuple with the PagerDutyDestination field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Action) GetPagerDutyDestinationOk() (*ActionPagerDutyDestination, bool) {
if o == nil || IsNil(o.PagerDutyDestination) {
return nil, false
}
return o.PagerDutyDestination, true
}
// HasPagerDutyDestination returns a boolean if a field has been set.
func (o *Action) HasPagerDutyDestination() bool {
if o != nil && !IsNil(o.PagerDutyDestination) {
return true
}
return false
}
// SetPagerDutyDestination gets a reference to the given ActionPagerDutyDestination and assigns it to the PagerDutyDestination field.
func (o *Action) SetPagerDutyDestination(v ActionPagerDutyDestination) {
o.PagerDutyDestination = &v
}
// GetEmailDestination returns the EmailDestination field value if set, zero value otherwise.
func (o *Action) GetEmailDestination() ActionEmailDestination {
if o == nil || IsNil(o.EmailDestination) {
var ret ActionEmailDestination
return ret
}
return *o.EmailDestination
}
// GetEmailDestinationOk returns a tuple with the EmailDestination field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Action) GetEmailDestinationOk() (*ActionEmailDestination, bool) {
if o == nil || IsNil(o.EmailDestination) {
return nil, false
}
return o.EmailDestination, true
}
// HasEmailDestination returns a boolean if a field has been set.
func (o *Action) HasEmailDestination() bool {
if o != nil && !IsNil(o.EmailDestination) {
return true
}
return false
}
// SetEmailDestination gets a reference to the given ActionEmailDestination and assigns it to the EmailDestination field.
func (o *Action) SetEmailDestination(v ActionEmailDestination) {
o.EmailDestination = &v
}
// GetWebhookDestination returns the WebhookDestination field value if set, zero value otherwise.
func (o *Action) GetWebhookDestination() ActionWebhookDestination {
if o == nil || IsNil(o.WebhookDestination) {
var ret ActionWebhookDestination
return ret
}
return *o.WebhookDestination
}
// GetWebhookDestinationOk returns a tuple with the WebhookDestination field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Action) GetWebhookDestinationOk() (*ActionWebhookDestination, bool) {
if o == nil || IsNil(o.WebhookDestination) {
return nil, false
}
return o.WebhookDestination, true
}
// HasWebhookDestination returns a boolean if a field has been set.
func (o *Action) HasWebhookDestination() bool {
if o != nil && !IsNil(o.WebhookDestination) {
return true
}
return false
}
// SetWebhookDestination gets a reference to the given ActionWebhookDestination and assigns it to the WebhookDestination field.
func (o *Action) SetWebhookDestination(v ActionWebhookDestination) {
o.WebhookDestination = &v
}
func (o Action) MarshalJSON() ([]byte, error) {
toSerialize, err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o Action) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["type"] = o.Type
if !IsNil(o.SlackDestination) {
toSerialize["slackDestination"] = o.SlackDestination
}
if !IsNil(o.PagerDutyDestination) {
toSerialize["pagerDutyDestination"] = o.PagerDutyDestination
}
if !IsNil(o.EmailDestination) {
toSerialize["emailDestination"] = o.EmailDestination
}
if !IsNil(o.WebhookDestination) {
toSerialize["webhookDestination"] = o.WebhookDestination
}
return toSerialize, nil
}
func (o *Action) 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{
"type",
}
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)
}
}
varAction := _Action{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varAction)
if err != nil {
return err
}
*o = Action(varAction)
return err
}
type NullableAction struct {
value *Action
isSet bool
}
func (v NullableAction) Get() *Action {
return v.value
}
func (v *NullableAction) Set(val *Action) {
v.value = val
v.isSet = true
}
func (v NullableAction) IsSet() bool {
return v.isSet
}
func (v *NullableAction) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableAction(val *Action) *NullableAction {
return &NullableAction{value: val, isSet: true}
}
func (v NullableAction) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableAction) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}