Skip to content

Commit f78155d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add routes for managing On-Call user notification rules (#3534)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9d653b6 commit f78155d

40 files changed

Lines changed: 4402 additions & 0 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 495 additions & 0 deletions
Large diffs are not rendered by default.

api/datadogV2/api_on_call.go

Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.

api/datadogV2/doc.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,24 @@
438438
// - [On-CallApi.CreateOnCallEscalationPolicy]
439439
// - [On-CallApi.CreateOnCallSchedule]
440440
// - [On-CallApi.CreateUserNotificationChannel]
441+
// - [On-CallApi.CreateUserNotificationRule]
441442
// - [On-CallApi.DeleteOnCallEscalationPolicy]
442443
// - [On-CallApi.DeleteOnCallSchedule]
443444
// - [On-CallApi.DeleteUserNotificationChannel]
445+
// - [On-CallApi.DeleteUserNotificationRule]
444446
// - [On-CallApi.GetOnCallEscalationPolicy]
445447
// - [On-CallApi.GetOnCallSchedule]
446448
// - [On-CallApi.GetOnCallTeamRoutingRules]
447449
// - [On-CallApi.GetScheduleOnCallUser]
448450
// - [On-CallApi.GetTeamOnCallUsers]
449451
// - [On-CallApi.GetUserNotificationChannel]
452+
// - [On-CallApi.GetUserNotificationRule]
450453
// - [On-CallApi.ListUserNotificationChannels]
454+
// - [On-CallApi.ListUserNotificationRules]
451455
// - [On-CallApi.SetOnCallTeamRoutingRules]
452456
// - [On-CallApi.UpdateOnCallEscalationPolicy]
453457
// - [On-CallApi.UpdateOnCallSchedule]
458+
// - [On-CallApi.UpdateUserNotificationRule]
454459
// - [On-CallPagingApi.AcknowledgeOnCallPage]
455460
// - [On-CallPagingApi.CreateOnCallPage]
456461
// - [On-CallPagingApi.EscalateOnCallPage]
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// CreateOnCallNotificationRuleRequest A top-level wrapper for creating a notification rule for a user
14+
type CreateOnCallNotificationRuleRequest struct {
15+
// Data for creating an on-call notification rule
16+
Data CreateOnCallNotificationRuleRequestData `json:"data"`
17+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
18+
UnparsedObject map[string]interface{} `json:"-"`
19+
AdditionalProperties map[string]interface{} `json:"-"`
20+
}
21+
22+
// NewCreateOnCallNotificationRuleRequest instantiates a new CreateOnCallNotificationRuleRequest object.
23+
// This constructor will assign default values to properties that have it defined,
24+
// and makes sure properties required by API are set, but the set of arguments
25+
// will change when the set of required properties is changed.
26+
func NewCreateOnCallNotificationRuleRequest(data CreateOnCallNotificationRuleRequestData) *CreateOnCallNotificationRuleRequest {
27+
this := CreateOnCallNotificationRuleRequest{}
28+
this.Data = data
29+
return &this
30+
}
31+
32+
// NewCreateOnCallNotificationRuleRequestWithDefaults instantiates a new CreateOnCallNotificationRuleRequest object.
33+
// This constructor will only assign default values to properties that have it defined,
34+
// but it doesn't guarantee that properties required by API are set.
35+
func NewCreateOnCallNotificationRuleRequestWithDefaults() *CreateOnCallNotificationRuleRequest {
36+
this := CreateOnCallNotificationRuleRequest{}
37+
return &this
38+
}
39+
40+
// GetData returns the Data field value.
41+
func (o *CreateOnCallNotificationRuleRequest) GetData() CreateOnCallNotificationRuleRequestData {
42+
if o == nil {
43+
var ret CreateOnCallNotificationRuleRequestData
44+
return ret
45+
}
46+
return o.Data
47+
}
48+
49+
// GetDataOk returns a tuple with the Data field value
50+
// and a boolean to check if the value has been set.
51+
func (o *CreateOnCallNotificationRuleRequest) GetDataOk() (*CreateOnCallNotificationRuleRequestData, bool) {
52+
if o == nil {
53+
return nil, false
54+
}
55+
return &o.Data, true
56+
}
57+
58+
// SetData sets field value.
59+
func (o *CreateOnCallNotificationRuleRequest) SetData(v CreateOnCallNotificationRuleRequestData) {
60+
o.Data = v
61+
}
62+
63+
// MarshalJSON serializes the struct using spec logic.
64+
func (o CreateOnCallNotificationRuleRequest) MarshalJSON() ([]byte, error) {
65+
toSerialize := map[string]interface{}{}
66+
if o.UnparsedObject != nil {
67+
return datadog.Marshal(o.UnparsedObject)
68+
}
69+
toSerialize["data"] = o.Data
70+
71+
for key, value := range o.AdditionalProperties {
72+
toSerialize[key] = value
73+
}
74+
return datadog.Marshal(toSerialize)
75+
}
76+
77+
// UnmarshalJSON deserializes the given payload.
78+
func (o *CreateOnCallNotificationRuleRequest) UnmarshalJSON(bytes []byte) (err error) {
79+
all := struct {
80+
Data *CreateOnCallNotificationRuleRequestData `json:"data"`
81+
}{}
82+
if err = datadog.Unmarshal(bytes, &all); err != nil {
83+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
84+
}
85+
if all.Data == nil {
86+
return fmt.Errorf("required field data missing")
87+
}
88+
additionalProperties := make(map[string]interface{})
89+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
90+
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
91+
} else {
92+
return err
93+
}
94+
95+
hasInvalidField := false
96+
if all.Data.UnparsedObject != nil && o.UnparsedObject == nil {
97+
hasInvalidField = true
98+
}
99+
o.Data = *all.Data
100+
101+
if len(additionalProperties) > 0 {
102+
o.AdditionalProperties = additionalProperties
103+
}
104+
105+
if hasInvalidField {
106+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
107+
}
108+
109+
return nil
110+
}
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"fmt"
9+
10+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
11+
)
12+
13+
// CreateOnCallNotificationRuleRequestData Data for creating an on-call notification rule
14+
type CreateOnCallNotificationRuleRequestData struct {
15+
// Attributes for creating or modifying an on-call notification rule.
16+
Attributes *OnCallNotificationRuleRequestAttributes `json:"attributes,omitempty"`
17+
// Relationship object for creating a notification rule
18+
Relationships *OnCallNotificationRuleRelationships `json:"relationships,omitempty"`
19+
// Indicates that the resource is of type 'notification_rules'.
20+
Type OnCallNotificationRuleType `json:"type"`
21+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
22+
UnparsedObject map[string]interface{} `json:"-"`
23+
AdditionalProperties map[string]interface{} `json:"-"`
24+
}
25+
26+
// NewCreateOnCallNotificationRuleRequestData instantiates a new CreateOnCallNotificationRuleRequestData object.
27+
// This constructor will assign default values to properties that have it defined,
28+
// and makes sure properties required by API are set, but the set of arguments
29+
// will change when the set of required properties is changed.
30+
func NewCreateOnCallNotificationRuleRequestData(typeVar OnCallNotificationRuleType) *CreateOnCallNotificationRuleRequestData {
31+
this := CreateOnCallNotificationRuleRequestData{}
32+
this.Type = typeVar
33+
return &this
34+
}
35+
36+
// NewCreateOnCallNotificationRuleRequestDataWithDefaults instantiates a new CreateOnCallNotificationRuleRequestData object.
37+
// This constructor will only assign default values to properties that have it defined,
38+
// but it doesn't guarantee that properties required by API are set.
39+
func NewCreateOnCallNotificationRuleRequestDataWithDefaults() *CreateOnCallNotificationRuleRequestData {
40+
this := CreateOnCallNotificationRuleRequestData{}
41+
var typeVar OnCallNotificationRuleType = ONCALLNOTIFICATIONRULETYPE_NOTIFICATION_RULES
42+
this.Type = typeVar
43+
return &this
44+
}
45+
46+
// GetAttributes returns the Attributes field value if set, zero value otherwise.
47+
func (o *CreateOnCallNotificationRuleRequestData) GetAttributes() OnCallNotificationRuleRequestAttributes {
48+
if o == nil || o.Attributes == nil {
49+
var ret OnCallNotificationRuleRequestAttributes
50+
return ret
51+
}
52+
return *o.Attributes
53+
}
54+
55+
// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise
56+
// and a boolean to check if the value has been set.
57+
func (o *CreateOnCallNotificationRuleRequestData) GetAttributesOk() (*OnCallNotificationRuleRequestAttributes, bool) {
58+
if o == nil || o.Attributes == nil {
59+
return nil, false
60+
}
61+
return o.Attributes, true
62+
}
63+
64+
// HasAttributes returns a boolean if a field has been set.
65+
func (o *CreateOnCallNotificationRuleRequestData) HasAttributes() bool {
66+
return o != nil && o.Attributes != nil
67+
}
68+
69+
// SetAttributes gets a reference to the given OnCallNotificationRuleRequestAttributes and assigns it to the Attributes field.
70+
func (o *CreateOnCallNotificationRuleRequestData) SetAttributes(v OnCallNotificationRuleRequestAttributes) {
71+
o.Attributes = &v
72+
}
73+
74+
// GetRelationships returns the Relationships field value if set, zero value otherwise.
75+
func (o *CreateOnCallNotificationRuleRequestData) GetRelationships() OnCallNotificationRuleRelationships {
76+
if o == nil || o.Relationships == nil {
77+
var ret OnCallNotificationRuleRelationships
78+
return ret
79+
}
80+
return *o.Relationships
81+
}
82+
83+
// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise
84+
// and a boolean to check if the value has been set.
85+
func (o *CreateOnCallNotificationRuleRequestData) GetRelationshipsOk() (*OnCallNotificationRuleRelationships, bool) {
86+
if o == nil || o.Relationships == nil {
87+
return nil, false
88+
}
89+
return o.Relationships, true
90+
}
91+
92+
// HasRelationships returns a boolean if a field has been set.
93+
func (o *CreateOnCallNotificationRuleRequestData) HasRelationships() bool {
94+
return o != nil && o.Relationships != nil
95+
}
96+
97+
// SetRelationships gets a reference to the given OnCallNotificationRuleRelationships and assigns it to the Relationships field.
98+
func (o *CreateOnCallNotificationRuleRequestData) SetRelationships(v OnCallNotificationRuleRelationships) {
99+
o.Relationships = &v
100+
}
101+
102+
// GetType returns the Type field value.
103+
func (o *CreateOnCallNotificationRuleRequestData) GetType() OnCallNotificationRuleType {
104+
if o == nil {
105+
var ret OnCallNotificationRuleType
106+
return ret
107+
}
108+
return o.Type
109+
}
110+
111+
// GetTypeOk returns a tuple with the Type field value
112+
// and a boolean to check if the value has been set.
113+
func (o *CreateOnCallNotificationRuleRequestData) GetTypeOk() (*OnCallNotificationRuleType, bool) {
114+
if o == nil {
115+
return nil, false
116+
}
117+
return &o.Type, true
118+
}
119+
120+
// SetType sets field value.
121+
func (o *CreateOnCallNotificationRuleRequestData) SetType(v OnCallNotificationRuleType) {
122+
o.Type = v
123+
}
124+
125+
// MarshalJSON serializes the struct using spec logic.
126+
func (o CreateOnCallNotificationRuleRequestData) MarshalJSON() ([]byte, error) {
127+
toSerialize := map[string]interface{}{}
128+
if o.UnparsedObject != nil {
129+
return datadog.Marshal(o.UnparsedObject)
130+
}
131+
if o.Attributes != nil {
132+
toSerialize["attributes"] = o.Attributes
133+
}
134+
if o.Relationships != nil {
135+
toSerialize["relationships"] = o.Relationships
136+
}
137+
toSerialize["type"] = o.Type
138+
139+
for key, value := range o.AdditionalProperties {
140+
toSerialize[key] = value
141+
}
142+
return datadog.Marshal(toSerialize)
143+
}
144+
145+
// UnmarshalJSON deserializes the given payload.
146+
func (o *CreateOnCallNotificationRuleRequestData) UnmarshalJSON(bytes []byte) (err error) {
147+
all := struct {
148+
Attributes *OnCallNotificationRuleRequestAttributes `json:"attributes,omitempty"`
149+
Relationships *OnCallNotificationRuleRelationships `json:"relationships,omitempty"`
150+
Type *OnCallNotificationRuleType `json:"type"`
151+
}{}
152+
if err = datadog.Unmarshal(bytes, &all); err != nil {
153+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
154+
}
155+
if all.Type == nil {
156+
return fmt.Errorf("required field type missing")
157+
}
158+
additionalProperties := make(map[string]interface{})
159+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
160+
datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "relationships", "type"})
161+
} else {
162+
return err
163+
}
164+
165+
hasInvalidField := false
166+
if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil {
167+
hasInvalidField = true
168+
}
169+
o.Attributes = all.Attributes
170+
if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil {
171+
hasInvalidField = true
172+
}
173+
o.Relationships = all.Relationships
174+
if !all.Type.IsValid() {
175+
hasInvalidField = true
176+
} else {
177+
o.Type = *all.Type
178+
}
179+
180+
if len(additionalProperties) > 0 {
181+
o.AdditionalProperties = additionalProperties
182+
}
183+
184+
if hasInvalidField {
185+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
186+
}
187+
188+
return nil
189+
}

0 commit comments

Comments
 (0)