diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index df325279eec..4846e392b59 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -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: @@ -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: diff --git a/src/main/java/com/datadog/api/client/v2/model/RoutingRuleAction.java b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleAction.java index dfdf7884f47..3136393c741 100644 --- a/src/main/java/com/datadog/api/client/v2/model/RoutingRuleAction.java +++ b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleAction.java @@ -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); @@ -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() {}); schemas.put("SendTeamsMessageAction", new GenericType() {}); + schemas.put( + "TriggerWorkflowAutomationAction", new GenericType() {}); JSON.registerDescendants(RoutingRuleAction.class, Collections.unmodifiableMap(schemas)); } @@ -218,7 +271,8 @@ public Map 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 * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -233,20 +287,27 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + TriggerWorkflowAutomationAction.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { 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() { @@ -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(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationAction.java b/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationAction.java new file mode 100644 index 00000000000..d0d463ac986 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationAction.java @@ -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 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(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map 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 "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationActionType.java b/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationActionType.java new file mode 100644 index 00000000000..7ccfa325163 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/TriggerWorkflowAutomationActionType.java @@ -0,0 +1,58 @@ +/* + * 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.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Indicates that the action triggers a Workflow Automation. */ +@JsonSerialize( + using = TriggerWorkflowAutomationActionType.TriggerWorkflowAutomationActionTypeSerializer.class) +public class TriggerWorkflowAutomationActionType extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("workflow")); + + public static final TriggerWorkflowAutomationActionType TRIGGER_WORKFLOW_AUTOMATION = + new TriggerWorkflowAutomationActionType("workflow"); + + TriggerWorkflowAutomationActionType(String value) { + super(value, allowedValues); + } + + public static class TriggerWorkflowAutomationActionTypeSerializer + extends StdSerializer { + public TriggerWorkflowAutomationActionTypeSerializer( + Class t) { + super(t); + } + + public TriggerWorkflowAutomationActionTypeSerializer() { + this(null); + } + + @Override + public void serialize( + TriggerWorkflowAutomationActionType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static TriggerWorkflowAutomationActionType fromValue(String value) { + return new TriggerWorkflowAutomationActionType(value); + } +}