@@ -12,12 +12,14 @@ import (
1212
1313// MonitorNotificationRuleAttributes Attributes of the monitor notification rule.
1414type MonitorNotificationRuleAttributes struct {
15+ // Use conditional recipients to define different recipients for different situations.
16+ ConditionalRecipients * MonitorNotificationRuleConditionalRecipients `json:"conditional_recipients,omitempty"`
1517 // Filter used to associate the notification rule with monitors.
1618 Filter * MonitorNotificationRuleFilter `json:"filter,omitempty"`
1719 // The name of the monitor notification rule.
1820 Name string `json:"name"`
1921 // A list of recipients to notify. Uses the same format as the monitor `message` field. Must not start with an '@'.
20- Recipients []string `json:"recipients"`
22+ Recipients []string `json:"recipients,omitempty "`
2123 // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
2224 UnparsedObject map [string ]interface {} `json:"-"`
2325}
@@ -26,10 +28,9 @@ type MonitorNotificationRuleAttributes struct {
2628// This constructor will assign default values to properties that have it defined,
2729// and makes sure properties required by API are set, but the set of arguments
2830// will change when the set of required properties is changed.
29- func NewMonitorNotificationRuleAttributes (name string , recipients [] string ) * MonitorNotificationRuleAttributes {
31+ func NewMonitorNotificationRuleAttributes (name string ) * MonitorNotificationRuleAttributes {
3032 this := MonitorNotificationRuleAttributes {}
3133 this .Name = name
32- this .Recipients = recipients
3334 return & this
3435}
3536
@@ -41,6 +42,34 @@ func NewMonitorNotificationRuleAttributesWithDefaults() *MonitorNotificationRule
4142 return & this
4243}
4344
45+ // GetConditionalRecipients returns the ConditionalRecipients field value if set, zero value otherwise.
46+ func (o * MonitorNotificationRuleAttributes ) GetConditionalRecipients () MonitorNotificationRuleConditionalRecipients {
47+ if o == nil || o .ConditionalRecipients == nil {
48+ var ret MonitorNotificationRuleConditionalRecipients
49+ return ret
50+ }
51+ return * o .ConditionalRecipients
52+ }
53+
54+ // GetConditionalRecipientsOk returns a tuple with the ConditionalRecipients field value if set, nil otherwise
55+ // and a boolean to check if the value has been set.
56+ func (o * MonitorNotificationRuleAttributes ) GetConditionalRecipientsOk () (* MonitorNotificationRuleConditionalRecipients , bool ) {
57+ if o == nil || o .ConditionalRecipients == nil {
58+ return nil , false
59+ }
60+ return o .ConditionalRecipients , true
61+ }
62+
63+ // HasConditionalRecipients returns a boolean if a field has been set.
64+ func (o * MonitorNotificationRuleAttributes ) HasConditionalRecipients () bool {
65+ return o != nil && o .ConditionalRecipients != nil
66+ }
67+
68+ // SetConditionalRecipients gets a reference to the given MonitorNotificationRuleConditionalRecipients and assigns it to the ConditionalRecipients field.
69+ func (o * MonitorNotificationRuleAttributes ) SetConditionalRecipients (v MonitorNotificationRuleConditionalRecipients ) {
70+ o .ConditionalRecipients = & v
71+ }
72+
4473// GetFilter returns the Filter field value if set, zero value otherwise.
4574func (o * MonitorNotificationRuleAttributes ) GetFilter () MonitorNotificationRuleFilter {
4675 if o == nil || o .Filter == nil {
@@ -92,25 +121,30 @@ func (o *MonitorNotificationRuleAttributes) SetName(v string) {
92121 o .Name = v
93122}
94123
95- // GetRecipients returns the Recipients field value.
124+ // GetRecipients returns the Recipients field value if set, zero value otherwise .
96125func (o * MonitorNotificationRuleAttributes ) GetRecipients () []string {
97- if o == nil {
126+ if o == nil || o . Recipients == nil {
98127 var ret []string
99128 return ret
100129 }
101130 return o .Recipients
102131}
103132
104- // GetRecipientsOk returns a tuple with the Recipients field value
133+ // GetRecipientsOk returns a tuple with the Recipients field value if set, nil otherwise
105134// and a boolean to check if the value has been set.
106135func (o * MonitorNotificationRuleAttributes ) GetRecipientsOk () (* []string , bool ) {
107- if o == nil {
136+ if o == nil || o . Recipients == nil {
108137 return nil , false
109138 }
110139 return & o .Recipients , true
111140}
112141
113- // SetRecipients sets field value.
142+ // HasRecipients returns a boolean if a field has been set.
143+ func (o * MonitorNotificationRuleAttributes ) HasRecipients () bool {
144+ return o != nil && o .Recipients != nil
145+ }
146+
147+ // SetRecipients gets a reference to the given []string and assigns it to the Recipients field.
114148func (o * MonitorNotificationRuleAttributes ) SetRecipients (v []string ) {
115149 o .Recipients = v
116150}
@@ -121,33 +155,46 @@ func (o MonitorNotificationRuleAttributes) MarshalJSON() ([]byte, error) {
121155 if o .UnparsedObject != nil {
122156 return datadog .Marshal (o .UnparsedObject )
123157 }
158+ if o .ConditionalRecipients != nil {
159+ toSerialize ["conditional_recipients" ] = o .ConditionalRecipients
160+ }
124161 if o .Filter != nil {
125162 toSerialize ["filter" ] = o .Filter
126163 }
127164 toSerialize ["name" ] = o .Name
128- toSerialize ["recipients" ] = o .Recipients
165+ if o .Recipients != nil {
166+ toSerialize ["recipients" ] = o .Recipients
167+ }
129168 return datadog .Marshal (toSerialize )
130169}
131170
132171// UnmarshalJSON deserializes the given payload.
133172func (o * MonitorNotificationRuleAttributes ) UnmarshalJSON (bytes []byte ) (err error ) {
134173 all := struct {
135- Filter * MonitorNotificationRuleFilter `json:"filter,omitempty"`
136- Name * string `json:"name"`
137- Recipients * []string `json:"recipients"`
174+ ConditionalRecipients * MonitorNotificationRuleConditionalRecipients `json:"conditional_recipients,omitempty"`
175+ Filter * MonitorNotificationRuleFilter `json:"filter,omitempty"`
176+ Name * string `json:"name"`
177+ Recipients []string `json:"recipients,omitempty"`
138178 }{}
139179 if err = datadog .Unmarshal (bytes , & all ); err != nil {
140180 return datadog .Unmarshal (bytes , & o .UnparsedObject )
141181 }
142182 if all .Name == nil {
143183 return fmt .Errorf ("required field name missing" )
144184 }
145- if all .Recipients == nil {
146- return fmt .Errorf ("required field recipients missing" )
185+
186+ hasInvalidField := false
187+ if all .ConditionalRecipients != nil && all .ConditionalRecipients .UnparsedObject != nil && o .UnparsedObject == nil {
188+ hasInvalidField = true
147189 }
190+ o .ConditionalRecipients = all .ConditionalRecipients
148191 o .Filter = all .Filter
149192 o .Name = * all .Name
150- o .Recipients = * all .Recipients
193+ o .Recipients = all .Recipients
194+
195+ if hasInvalidField {
196+ return datadog .Unmarshal (bytes , & o .UnparsedObject )
197+ }
151198
152199 return nil
153200}
0 commit comments