Skip to content

Commit 85a47ef

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

4 files changed

Lines changed: 340 additions & 4 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:

src/main/java/com/datadog/api/client/v2/model/RoutingRuleAction.java

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,52 @@ public RoutingRuleAction deserialize(JsonParser jp, DeserializationContext ctxt)
167167
log.log(Level.FINER, "Input data does not match schema 'SendTeamsMessageAction'", e);
168168
}
169169

170+
// deserialize TriggerWorkflowAutomationAction
171+
try {
172+
boolean attemptParsing = true;
173+
// ensure that we respect type coercion as set on the client ObjectMapper
174+
if (TriggerWorkflowAutomationAction.class.equals(Integer.class)
175+
|| TriggerWorkflowAutomationAction.class.equals(Long.class)
176+
|| TriggerWorkflowAutomationAction.class.equals(Float.class)
177+
|| TriggerWorkflowAutomationAction.class.equals(Double.class)
178+
|| TriggerWorkflowAutomationAction.class.equals(Boolean.class)
179+
|| TriggerWorkflowAutomationAction.class.equals(String.class)) {
180+
attemptParsing = typeCoercion;
181+
if (!attemptParsing) {
182+
attemptParsing |=
183+
((TriggerWorkflowAutomationAction.class.equals(Integer.class)
184+
|| TriggerWorkflowAutomationAction.class.equals(Long.class))
185+
&& token == JsonToken.VALUE_NUMBER_INT);
186+
attemptParsing |=
187+
((TriggerWorkflowAutomationAction.class.equals(Float.class)
188+
|| TriggerWorkflowAutomationAction.class.equals(Double.class))
189+
&& (token == JsonToken.VALUE_NUMBER_FLOAT
190+
|| token == JsonToken.VALUE_NUMBER_INT));
191+
attemptParsing |=
192+
(TriggerWorkflowAutomationAction.class.equals(Boolean.class)
193+
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
194+
attemptParsing |=
195+
(TriggerWorkflowAutomationAction.class.equals(String.class)
196+
&& token == JsonToken.VALUE_STRING);
197+
}
198+
}
199+
if (attemptParsing) {
200+
tmp = tree.traverse(jp.getCodec()).readValueAs(TriggerWorkflowAutomationAction.class);
201+
// TODO: there is no validation against JSON schema constraints
202+
// (min, max, enum, pattern...), this does not perform a strict JSON
203+
// validation, which means the 'match' count may be higher than it should be.
204+
if (!((TriggerWorkflowAutomationAction) tmp).unparsed) {
205+
deserialized = tmp;
206+
match++;
207+
}
208+
log.log(Level.FINER, "Input data matches schema 'TriggerWorkflowAutomationAction'");
209+
}
210+
} catch (Exception e) {
211+
// deserialization failed, continue
212+
log.log(
213+
Level.FINER, "Input data does not match schema 'TriggerWorkflowAutomationAction'", e);
214+
}
215+
170216
RoutingRuleAction ret = new RoutingRuleAction();
171217
if (match == 1) {
172218
ret.setActualInstance(deserialized);
@@ -205,9 +251,16 @@ public RoutingRuleAction(SendTeamsMessageAction o) {
205251
setActualInstance(o);
206252
}
207253

254+
public RoutingRuleAction(TriggerWorkflowAutomationAction o) {
255+
super("oneOf", Boolean.FALSE);
256+
setActualInstance(o);
257+
}
258+
208259
static {
209260
schemas.put("SendSlackMessageAction", new GenericType<SendSlackMessageAction>() {});
210261
schemas.put("SendTeamsMessageAction", new GenericType<SendTeamsMessageAction>() {});
262+
schemas.put(
263+
"TriggerWorkflowAutomationAction", new GenericType<TriggerWorkflowAutomationAction>() {});
211264
JSON.registerDescendants(RoutingRuleAction.class, Collections.unmodifiableMap(schemas));
212265
}
213266

@@ -218,7 +271,8 @@ public Map<String, GenericType> getSchemas() {
218271

219272
/**
220273
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
221-
* against the oneOf child schemas: SendSlackMessageAction, SendTeamsMessageAction
274+
* against the oneOf child schemas: SendSlackMessageAction, SendTeamsMessageAction,
275+
* TriggerWorkflowAutomationAction
222276
*
223277
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
224278
* composed schema (allOf, anyOf, oneOf).
@@ -233,20 +287,27 @@ public void setActualInstance(Object instance) {
233287
super.setActualInstance(instance);
234288
return;
235289
}
290+
if (JSON.isInstanceOf(
291+
TriggerWorkflowAutomationAction.class, instance, new HashSet<Class<?>>())) {
292+
super.setActualInstance(instance);
293+
return;
294+
}
236295

237296
if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
238297
super.setActualInstance(instance);
239298
return;
240299
}
241300
throw new RuntimeException(
242-
"Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction");
301+
"Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction,"
302+
+ " TriggerWorkflowAutomationAction");
243303
}
244304

245305
/**
246306
* Get the actual instance, which can be the following: SendSlackMessageAction,
247-
* SendTeamsMessageAction
307+
* SendTeamsMessageAction, TriggerWorkflowAutomationAction
248308
*
249-
* @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction)
309+
* @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction,
310+
* TriggerWorkflowAutomationAction)
250311
*/
251312
@Override
252313
public Object getActualInstance() {
@@ -274,4 +335,16 @@ public SendSlackMessageAction getSendSlackMessageAction() throws ClassCastExcept
274335
public SendTeamsMessageAction getSendTeamsMessageAction() throws ClassCastException {
275336
return (SendTeamsMessageAction) super.getActualInstance();
276337
}
338+
339+
/**
340+
* Get the actual instance of `TriggerWorkflowAutomationAction`. If the actual instance is not
341+
* `TriggerWorkflowAutomationAction`, the ClassCastException will be thrown.
342+
*
343+
* @return The actual instance of `TriggerWorkflowAutomationAction`
344+
* @throws ClassCastException if the instance is not `TriggerWorkflowAutomationAction`
345+
*/
346+
public TriggerWorkflowAutomationAction getTriggerWorkflowAutomationAction()
347+
throws ClassCastException {
348+
return (TriggerWorkflowAutomationAction) super.getActualInstance();
349+
}
277350
}
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/*
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2019-Present Datadog, Inc.
5+
*/
6+
7+
package com.datadog.api.client.v2.model;
8+
9+
import com.fasterxml.jackson.annotation.JsonAnyGetter;
10+
import com.fasterxml.jackson.annotation.JsonAnySetter;
11+
import com.fasterxml.jackson.annotation.JsonCreator;
12+
import com.fasterxml.jackson.annotation.JsonIgnore;
13+
import com.fasterxml.jackson.annotation.JsonInclude;
14+
import com.fasterxml.jackson.annotation.JsonProperty;
15+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
16+
import java.util.HashMap;
17+
import java.util.Map;
18+
import java.util.Objects;
19+
20+
/** Triggers a Workflow Automation. */
21+
@JsonPropertyOrder({
22+
TriggerWorkflowAutomationAction.JSON_PROPERTY_HANDLE,
23+
TriggerWorkflowAutomationAction.JSON_PROPERTY_TYPE
24+
})
25+
@jakarta.annotation.Generated(
26+
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
27+
public class TriggerWorkflowAutomationAction {
28+
@JsonIgnore public boolean unparsed = false;
29+
public static final String JSON_PROPERTY_HANDLE = "handle";
30+
private String handle;
31+
32+
public static final String JSON_PROPERTY_TYPE = "type";
33+
private TriggerWorkflowAutomationActionType type =
34+
TriggerWorkflowAutomationActionType.TRIGGER_WORKFLOW_AUTOMATION;
35+
36+
public TriggerWorkflowAutomationAction() {}
37+
38+
@JsonCreator
39+
public TriggerWorkflowAutomationAction(
40+
@JsonProperty(required = true, value = JSON_PROPERTY_HANDLE) String handle,
41+
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE)
42+
TriggerWorkflowAutomationActionType type) {
43+
this.handle = handle;
44+
this.type = type;
45+
this.unparsed |= !type.isValid();
46+
}
47+
48+
public TriggerWorkflowAutomationAction handle(String handle) {
49+
this.handle = handle;
50+
return this;
51+
}
52+
53+
/**
54+
* The handle of the Workflow Automation to trigger.
55+
*
56+
* @return handle
57+
*/
58+
@JsonProperty(JSON_PROPERTY_HANDLE)
59+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
60+
public String getHandle() {
61+
return handle;
62+
}
63+
64+
public void setHandle(String handle) {
65+
this.handle = handle;
66+
}
67+
68+
public TriggerWorkflowAutomationAction type(TriggerWorkflowAutomationActionType type) {
69+
this.type = type;
70+
this.unparsed |= !type.isValid();
71+
return this;
72+
}
73+
74+
/**
75+
* Indicates that the action triggers a Workflow Automation.
76+
*
77+
* @return type
78+
*/
79+
@JsonProperty(JSON_PROPERTY_TYPE)
80+
@JsonInclude(value = JsonInclude.Include.ALWAYS)
81+
public TriggerWorkflowAutomationActionType getType() {
82+
return type;
83+
}
84+
85+
public void setType(TriggerWorkflowAutomationActionType type) {
86+
if (!type.isValid()) {
87+
this.unparsed = true;
88+
}
89+
this.type = type;
90+
}
91+
92+
/**
93+
* A container for additional, undeclared properties. This is a holder for any undeclared
94+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
95+
*/
96+
private Map<String, Object> additionalProperties;
97+
98+
/**
99+
* Set the additional (undeclared) property with the specified name and value. If the property
100+
* does not already exist, create it otherwise replace it.
101+
*
102+
* @param key The arbitrary key to set
103+
* @param value The associated value
104+
* @return TriggerWorkflowAutomationAction
105+
*/
106+
@JsonAnySetter
107+
public TriggerWorkflowAutomationAction putAdditionalProperty(String key, Object value) {
108+
if (this.additionalProperties == null) {
109+
this.additionalProperties = new HashMap<String, Object>();
110+
}
111+
this.additionalProperties.put(key, value);
112+
return this;
113+
}
114+
115+
/**
116+
* Return the additional (undeclared) property.
117+
*
118+
* @return The additional properties
119+
*/
120+
@JsonAnyGetter
121+
public Map<String, Object> getAdditionalProperties() {
122+
return additionalProperties;
123+
}
124+
125+
/**
126+
* Return the additional (undeclared) property with the specified name.
127+
*
128+
* @param key The arbitrary key to get
129+
* @return The specific additional property for the given key
130+
*/
131+
public Object getAdditionalProperty(String key) {
132+
if (this.additionalProperties == null) {
133+
return null;
134+
}
135+
return this.additionalProperties.get(key);
136+
}
137+
138+
/** Return true if this TriggerWorkflowAutomationAction object is equal to o. */
139+
@Override
140+
public boolean equals(Object o) {
141+
if (this == o) {
142+
return true;
143+
}
144+
if (o == null || getClass() != o.getClass()) {
145+
return false;
146+
}
147+
TriggerWorkflowAutomationAction triggerWorkflowAutomationAction =
148+
(TriggerWorkflowAutomationAction) o;
149+
return Objects.equals(this.handle, triggerWorkflowAutomationAction.handle)
150+
&& Objects.equals(this.type, triggerWorkflowAutomationAction.type)
151+
&& Objects.equals(
152+
this.additionalProperties, triggerWorkflowAutomationAction.additionalProperties);
153+
}
154+
155+
@Override
156+
public int hashCode() {
157+
return Objects.hash(handle, type, additionalProperties);
158+
}
159+
160+
@Override
161+
public String toString() {
162+
StringBuilder sb = new StringBuilder();
163+
sb.append("class TriggerWorkflowAutomationAction {\n");
164+
sb.append(" handle: ").append(toIndentedString(handle)).append("\n");
165+
sb.append(" type: ").append(toIndentedString(type)).append("\n");
166+
sb.append(" additionalProperties: ")
167+
.append(toIndentedString(additionalProperties))
168+
.append("\n");
169+
sb.append('}');
170+
return sb.toString();
171+
}
172+
173+
/**
174+
* Convert the given object to string with each line indented by 4 spaces (except the first line).
175+
*/
176+
private String toIndentedString(Object o) {
177+
if (o == null) {
178+
return "null";
179+
}
180+
return o.toString().replace("\n", "\n ");
181+
}
182+
}

0 commit comments

Comments
 (0)