Skip to content
Merged
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
23 changes: 23 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59651,6 +59651,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 @@ -79447,6 +79448,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
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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

package com.datadog.api.client.v2.model;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/** Triggers a Workflow Automation. */
@JsonPropertyOrder({
TriggerWorkflowAutomationAction.JSON_PROPERTY_HANDLE,
TriggerWorkflowAutomationAction.JSON_PROPERTY_TYPE
})
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
public class TriggerWorkflowAutomationAction {
@JsonIgnore public boolean unparsed = false;
public static final String JSON_PROPERTY_HANDLE = "handle";
private String handle;

public static final String JSON_PROPERTY_TYPE = "type";
private TriggerWorkflowAutomationActionType type =
TriggerWorkflowAutomationActionType.TRIGGER_WORKFLOW_AUTOMATION;

public TriggerWorkflowAutomationAction() {}

@JsonCreator
public TriggerWorkflowAutomationAction(
@JsonProperty(required = true, value = JSON_PROPERTY_HANDLE) String handle,
@JsonProperty(required = true, value = JSON_PROPERTY_TYPE)
TriggerWorkflowAutomationActionType type) {
this.handle = handle;
this.type = type;
this.unparsed |= !type.isValid();
}

public TriggerWorkflowAutomationAction handle(String handle) {
this.handle = handle;
return this;
}

/**
* The handle of the Workflow Automation to trigger.
*
* @return handle
*/
@JsonProperty(JSON_PROPERTY_HANDLE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public String getHandle() {
return handle;
}

public void setHandle(String handle) {
this.handle = handle;
}

public TriggerWorkflowAutomationAction type(TriggerWorkflowAutomationActionType type) {
this.type = type;
this.unparsed |= !type.isValid();
return this;
}

/**
* Indicates that the action triggers a Workflow Automation.
*
* @return type
*/
@JsonProperty(JSON_PROPERTY_TYPE)
@JsonInclude(value = JsonInclude.Include.ALWAYS)
public TriggerWorkflowAutomationActionType getType() {
return type;
}

public void setType(TriggerWorkflowAutomationActionType type) {
if (!type.isValid()) {
this.unparsed = true;
}
this.type = type;
}

/**
* A container for additional, undeclared properties. This is a holder for any undeclared
* properties as specified with the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;

/**
* Set the additional (undeclared) property with the specified name and value. If the property
* does not already exist, create it otherwise replace it.
*
* @param key The arbitrary key to set
* @param value The associated value
* @return TriggerWorkflowAutomationAction
*/
@JsonAnySetter
public TriggerWorkflowAutomationAction putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}

/**
* Return the additional (undeclared) property.
*
* @return The additional properties
*/
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}

/**
* Return the additional (undeclared) property with the specified name.
*
* @param key The arbitrary key to get
* @return The specific additional property for the given key
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}

/** Return true if this TriggerWorkflowAutomationAction object is equal to o. */
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TriggerWorkflowAutomationAction triggerWorkflowAutomationAction =
(TriggerWorkflowAutomationAction) o;
return Objects.equals(this.handle, triggerWorkflowAutomationAction.handle)
&& Objects.equals(this.type, triggerWorkflowAutomationAction.type)
&& Objects.equals(
this.additionalProperties, triggerWorkflowAutomationAction.additionalProperties);
}

@Override
public int hashCode() {
return Objects.hash(handle, type, additionalProperties);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TriggerWorkflowAutomationAction {\n");
sb.append(" handle: ").append(toIndentedString(handle)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" additionalProperties: ")
.append(toIndentedString(additionalProperties))
.append("\n");
sb.append('}');
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
Loading
Loading