Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 29 additions & 61 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59622,6 +59622,7 @@ components:
oneOf:
- $ref: "#/components/schemas/SendSlackMessageAction"
- $ref: "#/components/schemas/SendTeamsMessageAction"
- $ref: "#/components/schemas/TriggerWorkflowAutomationAction"
RoutingRuleAttributes:
description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency.
properties:
Expand Down Expand Up @@ -79418,6 +79419,28 @@ components:
type: string
x-enum-varnames:
- MONITOR_ALERT_TRIGGER
TriggerWorkflowAutomationAction:
description: "Triggers a Workflow Automation."
properties:
handle:
description: "The handle of the Workflow Automation to trigger."
example: my-workflow-handle
type: string
type:
$ref: "#/components/schemas/TriggerWorkflowAutomationActionType"
required:
- type
- handle
type: object
TriggerWorkflowAutomationActionType:
default: workflow
description: "Indicates that the action triggers a Workflow Automation."
enum:
- workflow
example: workflow
type: string
x-enum-varnames:
- TRIGGER_WORKFLOW_AUTOMATION
UCConfigPair:
description: The definition of `UCConfigPair` object.
example:
Expand Down Expand Up @@ -134695,45 +134718,16 @@ paths:
application/json:
examples:
default:
summary: CCM cost summary widget
value:
data:
attributes:
definition:
graph_options:
- type: query_value
view: total
- type: query_value
view: change
- display_type: bars
type: timeseries
- type: cloud_cost_table
view: summary
requests:
- formulas:
- formula: query1
queries:
- data_source: cloud_cost
name: query1
query: sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)
response_format: timeseries
time:
type: live
unit: day
value: 30
title: AWS spend by service (last 30 days)
type: cloud_cost_summary
tags: ["finops", "aws"]
title: My Widget
type: bar_chart
type: widgets
schema:
$ref: "#/components/schemas/CreateOrUpdateWidgetRequest"
description: |-
Widget request body. The `definition` object's required fields vary
by `widget.definition.type`: every type requires `requests`, and
some types require additional fields (e.g. `cloud_cost_summary`
requires `graph_options`, `geomap` requires `style` and `view`).
The example below shows a complete `cloud_cost_summary` payload
for the `ccm_reports` experience type.
description: Widget request body.
required: true
responses:
"200":
Expand Down Expand Up @@ -134903,42 +134897,16 @@ paths:
application/json:
examples:
default:
summary: CCM cost summary widget
value:
data:
attributes:
definition:
graph_options:
- type: query_value
view: total
- type: query_value
view: change
- display_type: bars
type: timeseries
- type: cloud_cost_table
view: summary
requests:
- formulas:
- formula: query1
queries:
- data_source: cloud_cost
name: query1
query: sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, daily)
response_format: timeseries
time:
type: live
unit: day
value: 30
title: AWS spend by service (last 30 days)
type: cloud_cost_summary
tags: ["finops", "aws"]
title: My Widget
type: bar_chart
type: widgets
schema:
$ref: "#/components/schemas/CreateOrUpdateWidgetRequest"
description: |-
Widget request body. The `definition` object's required fields vary
by `widget.definition.type`; see `CreateWidget` above for a complete
worked payload. Update is a full replacement of the widget definition.
description: Widget request body.
required: true
responses:
"200":
Expand Down
44 changes: 8 additions & 36 deletions src/main/java/com/datadog/api/client/v2/api/WidgetsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ public void setApiClient(ApiClient apiClient) {
* <p>See {@link #createWidgetWithHttpInfo}.
*
* @param experienceType The experience type for the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>: every type requires <code>requests</code>, and some
* types require additional fields (e.g. <code>cloud_cost_summary</code> requires <code>
* graph_options</code>, <code>geomap</code> requires <code>style</code> and <code>view</code>
* ). The example below shows a complete <code>cloud_cost_summary</code> payload for the
* <code>ccm_reports</code> experience type. (required)
* @param body Widget request body. (required)
* @return WidgetResponse
* @throws ApiException if fails to make API call
*/
Expand All @@ -75,12 +70,7 @@ public WidgetResponse createWidget(
* <p>See {@link #createWidgetWithHttpInfoAsync}.
*
* @param experienceType The experience type for the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>: every type requires <code>requests</code>, and some
* types require additional fields (e.g. <code>cloud_cost_summary</code> requires <code>
* graph_options</code>, <code>geomap</code> requires <code>style</code> and <code>view</code>
* ). The example below shows a complete <code>cloud_cost_summary</code> payload for the
* <code>ccm_reports</code> experience type. (required)
* @param body Widget request body. (required)
* @return CompletableFuture&lt;WidgetResponse&gt;
*/
public CompletableFuture<WidgetResponse> createWidgetAsync(
Expand All @@ -96,12 +86,7 @@ public CompletableFuture<WidgetResponse> createWidgetAsync(
* Create a new widget for a given experience type.
*
* @param experienceType The experience type for the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>: every type requires <code>requests</code>, and some
* types require additional fields (e.g. <code>cloud_cost_summary</code> requires <code>
* graph_options</code>, <code>geomap</code> requires <code>style</code> and <code>view</code>
* ). The example below shows a complete <code>cloud_cost_summary</code> payload for the
* <code>ccm_reports</code> experience type. (required)
* @param body Widget request body. (required)
* @return ApiResponse&lt;WidgetResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
Expand Down Expand Up @@ -164,12 +149,7 @@ public ApiResponse<WidgetResponse> createWidgetWithHttpInfo(
* <p>See {@link #createWidgetWithHttpInfo}.
*
* @param experienceType The experience type for the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>: every type requires <code>requests</code>, and some
* types require additional fields (e.g. <code>cloud_cost_summary</code> requires <code>
* graph_options</code>, <code>geomap</code> requires <code>style</code> and <code>view</code>
* ). The example below shows a complete <code>cloud_cost_summary</code> payload for the
* <code>ccm_reports</code> experience type. (required)
* @param body Widget request body. (required)
* @return CompletableFuture&lt;ApiResponse&lt;WidgetResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<WidgetResponse>> createWidgetWithHttpInfoAsync(
Expand Down Expand Up @@ -879,9 +859,7 @@ public CompletableFuture<ApiResponse<WidgetListResponse>> searchWidgetsWithHttpI
*
* @param experienceType The experience type for the widget. (required)
* @param uuid The UUID of the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>; see <code>CreateWidget</code> above for a complete
* worked payload. Update is a full replacement of the widget definition. (required)
* @param body Widget request body. (required)
* @return WidgetResponse
* @throws ApiException if fails to make API call
*/
Expand All @@ -898,9 +876,7 @@ public WidgetResponse updateWidget(
*
* @param experienceType The experience type for the widget. (required)
* @param uuid The UUID of the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>; see <code>CreateWidget</code> above for a complete
* worked payload. Update is a full replacement of the widget definition. (required)
* @param body Widget request body. (required)
* @return CompletableFuture&lt;WidgetResponse&gt;
*/
public CompletableFuture<WidgetResponse> updateWidgetAsync(
Expand All @@ -918,9 +894,7 @@ public CompletableFuture<WidgetResponse> updateWidgetAsync(
*
* @param experienceType The experience type for the widget. (required)
* @param uuid The UUID of the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>; see <code>CreateWidget</code> above for a complete
* worked payload. Update is a full replacement of the widget definition. (required)
* @param body Widget request body. (required)
* @return ApiResponse&lt;WidgetResponse&gt;
* @throws ApiException if fails to make API call
* @http.response.details
Expand Down Expand Up @@ -993,9 +967,7 @@ public ApiResponse<WidgetResponse> updateWidgetWithHttpInfo(
*
* @param experienceType The experience type for the widget. (required)
* @param uuid The UUID of the widget. (required)
* @param body Widget request body. The <code>definition</code> object's required fields vary by
* <code>widget.definition.type</code>; see <code>CreateWidget</code> above for a complete
* worked payload. Update is a full replacement of the widget definition. (required)
* @param body Widget request body. (required)
* @return CompletableFuture&lt;ApiResponse&lt;WidgetResponse&gt;&gt;
*/
public CompletableFuture<ApiResponse<WidgetResponse>> updateWidgetWithHttpInfoAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,52 @@ public RoutingRuleAction deserialize(JsonParser jp, DeserializationContext ctxt)
log.log(Level.FINER, "Input data does not match schema 'SendTeamsMessageAction'", e);
}

// deserialize TriggerWorkflowAutomationAction
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (TriggerWorkflowAutomationAction.class.equals(Integer.class)
|| TriggerWorkflowAutomationAction.class.equals(Long.class)
|| TriggerWorkflowAutomationAction.class.equals(Float.class)
|| TriggerWorkflowAutomationAction.class.equals(Double.class)
|| TriggerWorkflowAutomationAction.class.equals(Boolean.class)
|| TriggerWorkflowAutomationAction.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((TriggerWorkflowAutomationAction.class.equals(Integer.class)
|| TriggerWorkflowAutomationAction.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((TriggerWorkflowAutomationAction.class.equals(Float.class)
|| TriggerWorkflowAutomationAction.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(TriggerWorkflowAutomationAction.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(TriggerWorkflowAutomationAction.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(TriggerWorkflowAutomationAction.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
if (!((TriggerWorkflowAutomationAction) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'TriggerWorkflowAutomationAction'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(
Level.FINER, "Input data does not match schema 'TriggerWorkflowAutomationAction'", e);
}

RoutingRuleAction ret = new RoutingRuleAction();
if (match == 1) {
ret.setActualInstance(deserialized);
Expand Down Expand Up @@ -205,9 +251,16 @@ public RoutingRuleAction(SendTeamsMessageAction o) {
setActualInstance(o);
}

public RoutingRuleAction(TriggerWorkflowAutomationAction o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

static {
schemas.put("SendSlackMessageAction", new GenericType<SendSlackMessageAction>() {});
schemas.put("SendTeamsMessageAction", new GenericType<SendTeamsMessageAction>() {});
schemas.put(
"TriggerWorkflowAutomationAction", new GenericType<TriggerWorkflowAutomationAction>() {});
JSON.registerDescendants(RoutingRuleAction.class, Collections.unmodifiableMap(schemas));
}

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

/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: SendSlackMessageAction, SendTeamsMessageAction
* against the oneOf child schemas: SendSlackMessageAction, SendTeamsMessageAction,
* TriggerWorkflowAutomationAction
*
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
Expand All @@ -233,20 +287,27 @@ public void setActualInstance(Object instance) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(
TriggerWorkflowAutomationAction.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}

if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException(
"Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction");
"Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction,"
+ " TriggerWorkflowAutomationAction");
}

/**
* Get the actual instance, which can be the following: SendSlackMessageAction,
* SendTeamsMessageAction
* SendTeamsMessageAction, TriggerWorkflowAutomationAction
*
* @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction)
* @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction,
* TriggerWorkflowAutomationAction)
*/
@Override
public Object getActualInstance() {
Expand Down Expand Up @@ -274,4 +335,16 @@ public SendSlackMessageAction getSendSlackMessageAction() throws ClassCastExcept
public SendTeamsMessageAction getSendTeamsMessageAction() throws ClassCastException {
return (SendTeamsMessageAction) super.getActualInstance();
}

/**
* Get the actual instance of `TriggerWorkflowAutomationAction`. If the actual instance is not
* `TriggerWorkflowAutomationAction`, the ClassCastException will be thrown.
*
* @return The actual instance of `TriggerWorkflowAutomationAction`
* @throws ClassCastException if the instance is not `TriggerWorkflowAutomationAction`
*/
public TriggerWorkflowAutomationAction getTriggerWorkflowAutomationAction()
throws ClassCastException {
return (TriggerWorkflowAutomationAction) super.getActualInstance();
}
}
Loading
Loading