Skip to content

Commit 9bc9319

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add workflow automation to oncall team rules (#4027)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 8cda3cb commit 9bc9319

4 files changed

Lines changed: 266 additions & 2 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59666,6 +59666,7 @@ components:
5966659666
oneOf:
5966759667
- $ref: "#/components/schemas/SendSlackMessageAction"
5966859668
- $ref: "#/components/schemas/SendTeamsMessageAction"
59669+
- $ref: "#/components/schemas/TriggerWorkflowAutomationAction"
5966959670
RoutingRuleAttributes:
5967059671
description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
5967159672
properties:
@@ -79462,6 +79463,28 @@ components:
7946279463
type: string
7946379464
x-enum-varnames:
7946479465
- MONITOR_ALERT_TRIGGER
79466+
TriggerWorkflowAutomationAction:
79467+
description: "Triggers a Workflow Automation."
79468+
properties:
79469+
handle:
79470+
description: "The handle of the Workflow Automation to trigger."
79471+
example: my-workflow-handle
79472+
type: string
79473+
type:
79474+
$ref: "#/components/schemas/TriggerWorkflowAutomationActionType"
79475+
required:
79476+
- type
79477+
- handle
79478+
type: object
79479+
TriggerWorkflowAutomationActionType:
79480+
default: workflow
79481+
description: "Indicates that the action triggers a Workflow Automation."
79482+
enum:
79483+
- workflow
79484+
example: workflow
79485+
type: string
79486+
x-enum-varnames:
79487+
- TRIGGER_WORKFLOW_AUTOMATION
7946579488
UCConfigPair:
7946679489
description: The definition of `UCConfigPair` object.
7946779490
example:

api/datadogV2/model_routing_rule_action.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010

1111
// RoutingRuleAction - Defines an action that is executed when a routing rule matches certain criteria.
1212
type RoutingRuleAction struct {
13-
SendSlackMessageAction *SendSlackMessageAction
14-
SendTeamsMessageAction *SendTeamsMessageAction
13+
SendSlackMessageAction *SendSlackMessageAction
14+
SendTeamsMessageAction *SendTeamsMessageAction
15+
TriggerWorkflowAutomationAction *TriggerWorkflowAutomationAction
1516

1617
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
1718
UnparsedObject interface{}
@@ -27,6 +28,11 @@ func SendTeamsMessageActionAsRoutingRuleAction(v *SendTeamsMessageAction) Routin
2728
return RoutingRuleAction{SendTeamsMessageAction: v}
2829
}
2930

31+
// TriggerWorkflowAutomationActionAsRoutingRuleAction is a convenience function that returns TriggerWorkflowAutomationAction wrapped in RoutingRuleAction.
32+
func TriggerWorkflowAutomationActionAsRoutingRuleAction(v *TriggerWorkflowAutomationAction) RoutingRuleAction {
33+
return RoutingRuleAction{TriggerWorkflowAutomationAction: v}
34+
}
35+
3036
// UnmarshalJSON turns data into one of the pointers in the struct.
3137
func (obj *RoutingRuleAction) UnmarshalJSON(data []byte) error {
3238
var err error
@@ -65,10 +71,28 @@ func (obj *RoutingRuleAction) UnmarshalJSON(data []byte) error {
6571
obj.SendTeamsMessageAction = nil
6672
}
6773

74+
// try to unmarshal data into TriggerWorkflowAutomationAction
75+
err = datadog.Unmarshal(data, &obj.TriggerWorkflowAutomationAction)
76+
if err == nil {
77+
if obj.TriggerWorkflowAutomationAction != nil && obj.TriggerWorkflowAutomationAction.UnparsedObject == nil {
78+
jsonTriggerWorkflowAutomationAction, _ := datadog.Marshal(obj.TriggerWorkflowAutomationAction)
79+
if string(jsonTriggerWorkflowAutomationAction) == "{}" { // empty struct
80+
obj.TriggerWorkflowAutomationAction = nil
81+
} else {
82+
match++
83+
}
84+
} else {
85+
obj.TriggerWorkflowAutomationAction = nil
86+
}
87+
} else {
88+
obj.TriggerWorkflowAutomationAction = nil
89+
}
90+
6891
if match != 1 { // more than 1 match
6992
// reset to nil
7093
obj.SendSlackMessageAction = nil
7194
obj.SendTeamsMessageAction = nil
95+
obj.TriggerWorkflowAutomationAction = nil
7296
return datadog.Unmarshal(data, &obj.UnparsedObject)
7397
}
7498
return nil // exactly one match
@@ -84,6 +108,10 @@ func (obj RoutingRuleAction) MarshalJSON() ([]byte, error) {
84108
return datadog.Marshal(&obj.SendTeamsMessageAction)
85109
}
86110

111+
if obj.TriggerWorkflowAutomationAction != nil {
112+
return datadog.Marshal(&obj.TriggerWorkflowAutomationAction)
113+
}
114+
87115
if obj.UnparsedObject != nil {
88116
return datadog.Marshal(obj.UnparsedObject)
89117
}
@@ -100,6 +128,10 @@ func (obj *RoutingRuleAction) GetActualInstance() interface{} {
100128
return obj.SendTeamsMessageAction
101129
}
102130

131+
if obj.TriggerWorkflowAutomationAction != nil {
132+
return obj.TriggerWorkflowAutomationAction
133+
}
134+
103135
// all schemas are nil
104136
return nil
105137
}
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
// TriggerWorkflowAutomationAction Triggers a Workflow Automation.
14+
type TriggerWorkflowAutomationAction struct {
15+
// The handle of the Workflow Automation to trigger.
16+
Handle string `json:"handle"`
17+
// Indicates that the action triggers a Workflow Automation.
18+
Type TriggerWorkflowAutomationActionType `json:"type"`
19+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
20+
UnparsedObject map[string]interface{} `json:"-"`
21+
AdditionalProperties map[string]interface{} `json:"-"`
22+
}
23+
24+
// NewTriggerWorkflowAutomationAction instantiates a new TriggerWorkflowAutomationAction object.
25+
// This constructor will assign default values to properties that have it defined,
26+
// and makes sure properties required by API are set, but the set of arguments
27+
// will change when the set of required properties is changed.
28+
func NewTriggerWorkflowAutomationAction(handle string, typeVar TriggerWorkflowAutomationActionType) *TriggerWorkflowAutomationAction {
29+
this := TriggerWorkflowAutomationAction{}
30+
this.Handle = handle
31+
this.Type = typeVar
32+
return &this
33+
}
34+
35+
// NewTriggerWorkflowAutomationActionWithDefaults instantiates a new TriggerWorkflowAutomationAction object.
36+
// This constructor will only assign default values to properties that have it defined,
37+
// but it doesn't guarantee that properties required by API are set.
38+
func NewTriggerWorkflowAutomationActionWithDefaults() *TriggerWorkflowAutomationAction {
39+
this := TriggerWorkflowAutomationAction{}
40+
var typeVar TriggerWorkflowAutomationActionType = TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION
41+
this.Type = typeVar
42+
return &this
43+
}
44+
45+
// GetHandle returns the Handle field value.
46+
func (o *TriggerWorkflowAutomationAction) GetHandle() string {
47+
if o == nil {
48+
var ret string
49+
return ret
50+
}
51+
return o.Handle
52+
}
53+
54+
// GetHandleOk returns a tuple with the Handle field value
55+
// and a boolean to check if the value has been set.
56+
func (o *TriggerWorkflowAutomationAction) GetHandleOk() (*string, bool) {
57+
if o == nil {
58+
return nil, false
59+
}
60+
return &o.Handle, true
61+
}
62+
63+
// SetHandle sets field value.
64+
func (o *TriggerWorkflowAutomationAction) SetHandle(v string) {
65+
o.Handle = v
66+
}
67+
68+
// GetType returns the Type field value.
69+
func (o *TriggerWorkflowAutomationAction) GetType() TriggerWorkflowAutomationActionType {
70+
if o == nil {
71+
var ret TriggerWorkflowAutomationActionType
72+
return ret
73+
}
74+
return o.Type
75+
}
76+
77+
// GetTypeOk returns a tuple with the Type field value
78+
// and a boolean to check if the value has been set.
79+
func (o *TriggerWorkflowAutomationAction) GetTypeOk() (*TriggerWorkflowAutomationActionType, bool) {
80+
if o == nil {
81+
return nil, false
82+
}
83+
return &o.Type, true
84+
}
85+
86+
// SetType sets field value.
87+
func (o *TriggerWorkflowAutomationAction) SetType(v TriggerWorkflowAutomationActionType) {
88+
o.Type = v
89+
}
90+
91+
// MarshalJSON serializes the struct using spec logic.
92+
func (o TriggerWorkflowAutomationAction) MarshalJSON() ([]byte, error) {
93+
toSerialize := map[string]interface{}{}
94+
if o.UnparsedObject != nil {
95+
return datadog.Marshal(o.UnparsedObject)
96+
}
97+
toSerialize["handle"] = o.Handle
98+
toSerialize["type"] = o.Type
99+
100+
for key, value := range o.AdditionalProperties {
101+
toSerialize[key] = value
102+
}
103+
return datadog.Marshal(toSerialize)
104+
}
105+
106+
// UnmarshalJSON deserializes the given payload.
107+
func (o *TriggerWorkflowAutomationAction) UnmarshalJSON(bytes []byte) (err error) {
108+
all := struct {
109+
Handle *string `json:"handle"`
110+
Type *TriggerWorkflowAutomationActionType `json:"type"`
111+
}{}
112+
if err = datadog.Unmarshal(bytes, &all); err != nil {
113+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
114+
}
115+
if all.Handle == nil {
116+
return fmt.Errorf("required field handle missing")
117+
}
118+
if all.Type == nil {
119+
return fmt.Errorf("required field type missing")
120+
}
121+
additionalProperties := make(map[string]interface{})
122+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
123+
datadog.DeleteKeys(additionalProperties, &[]string{"handle", "type"})
124+
} else {
125+
return err
126+
}
127+
128+
hasInvalidField := false
129+
o.Handle = *all.Handle
130+
if !all.Type.IsValid() {
131+
hasInvalidField = true
132+
} else {
133+
o.Type = *all.Type
134+
}
135+
136+
if len(additionalProperties) > 0 {
137+
o.AdditionalProperties = additionalProperties
138+
}
139+
140+
if hasInvalidField {
141+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
142+
}
143+
144+
return nil
145+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
// TriggerWorkflowAutomationActionType Indicates that the action triggers a Workflow Automation.
14+
type TriggerWorkflowAutomationActionType string
15+
16+
// List of TriggerWorkflowAutomationActionType.
17+
const (
18+
TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION TriggerWorkflowAutomationActionType = "workflow"
19+
)
20+
21+
var allowedTriggerWorkflowAutomationActionTypeEnumValues = []TriggerWorkflowAutomationActionType{
22+
TRIGGERWORKFLOWAUTOMATIONACTIONTYPE_TRIGGER_WORKFLOW_AUTOMATION,
23+
}
24+
25+
// GetAllowedValues reeturns the list of possible values.
26+
func (v *TriggerWorkflowAutomationActionType) GetAllowedValues() []TriggerWorkflowAutomationActionType {
27+
return allowedTriggerWorkflowAutomationActionTypeEnumValues
28+
}
29+
30+
// UnmarshalJSON deserializes the given payload.
31+
func (v *TriggerWorkflowAutomationActionType) UnmarshalJSON(src []byte) error {
32+
var value string
33+
err := datadog.Unmarshal(src, &value)
34+
if err != nil {
35+
return err
36+
}
37+
*v = TriggerWorkflowAutomationActionType(value)
38+
return nil
39+
}
40+
41+
// NewTriggerWorkflowAutomationActionTypeFromValue returns a pointer to a valid TriggerWorkflowAutomationActionType
42+
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
43+
func NewTriggerWorkflowAutomationActionTypeFromValue(v string) (*TriggerWorkflowAutomationActionType, error) {
44+
ev := TriggerWorkflowAutomationActionType(v)
45+
if ev.IsValid() {
46+
return &ev, nil
47+
}
48+
return nil, fmt.Errorf("invalid value '%v' for TriggerWorkflowAutomationActionType: valid values are %v", v, allowedTriggerWorkflowAutomationActionTypeEnumValues)
49+
}
50+
51+
// IsValid return true if the value is valid for the enum, false otherwise.
52+
func (v TriggerWorkflowAutomationActionType) IsValid() bool {
53+
for _, existing := range allowedTriggerWorkflowAutomationActionTypeEnumValues {
54+
if existing == v {
55+
return true
56+
}
57+
}
58+
return false
59+
}
60+
61+
// Ptr returns reference to TriggerWorkflowAutomationActionType value.
62+
func (v TriggerWorkflowAutomationActionType) Ptr() *TriggerWorkflowAutomationActionType {
63+
return &v
64+
}

0 commit comments

Comments
 (0)