diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 531154bda8c..0797e955dc6 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -103275,6 +103275,7 @@ components: - $ref: "#/components/schemas/SendTeamsMessageAction" - $ref: "#/components/schemas/TriggerWorkflowAutomationAction" - $ref: "#/components/schemas/RoutingRuleEscalationPolicyAction" + - $ref: "#/components/schemas/RoutingRuleRerouteToTeamAction" RoutingRuleAttributes: description: Defines the configurable attributes of a routing rule, such as actions, query, time restriction, and urgency. properties: @@ -103373,6 +103374,29 @@ components: type: string x-enum-varnames: - POLICIES + RoutingRuleRerouteToTeamAction: + description: "Reroutes the page to another team, which then evaluates it against its own routing rules. Each routing rule can include this action only once. It can be combined only with `send_slack_message` and `send_teams_message` actions. It can't be used with `escalation_policy` or `workflow` actions, or when the routing rule sets `policy_id`." + properties: + destination_team_id: + description: "The ID of the team to reroute the page to." + example: "00000000-0000-0000-0000-000000000000" + format: uuid + type: string + type: + $ref: "#/components/schemas/RoutingRuleRerouteToTeamActionType" + required: + - type + - destination_team_id + type: object + RoutingRuleRerouteToTeamActionType: + default: reroute_to_team + description: "Indicates that the action reroutes the page to another team's routing rules." + enum: + - reroute_to_team + example: reroute_to_team + type: string + x-enum-varnames: + - REROUTE_TO_TEAM RoutingRuleType: default: team_routing_rules description: Team routing rules resource type. 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 c2892729956..4cc3a97f46b 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 @@ -259,6 +259,52 @@ public RoutingRuleAction deserialize(JsonParser jp, DeserializationContext ctxt) Level.FINER, "Input data does not match schema 'RoutingRuleEscalationPolicyAction'", e); } + // deserialize RoutingRuleRerouteToTeamAction + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (RoutingRuleRerouteToTeamAction.class.equals(Integer.class) + || RoutingRuleRerouteToTeamAction.class.equals(Long.class) + || RoutingRuleRerouteToTeamAction.class.equals(Float.class) + || RoutingRuleRerouteToTeamAction.class.equals(Double.class) + || RoutingRuleRerouteToTeamAction.class.equals(Boolean.class) + || RoutingRuleRerouteToTeamAction.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((RoutingRuleRerouteToTeamAction.class.equals(Integer.class) + || RoutingRuleRerouteToTeamAction.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((RoutingRuleRerouteToTeamAction.class.equals(Float.class) + || RoutingRuleRerouteToTeamAction.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (RoutingRuleRerouteToTeamAction.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (RoutingRuleRerouteToTeamAction.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(RoutingRuleRerouteToTeamAction.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 (!((RoutingRuleRerouteToTeamAction) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'RoutingRuleRerouteToTeamAction'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'RoutingRuleRerouteToTeamAction'", e); + } + RoutingRuleAction ret = new RoutingRuleAction(); if (match == 1) { ret.setActualInstance(deserialized); @@ -307,6 +353,11 @@ public RoutingRuleAction(RoutingRuleEscalationPolicyAction o) { setActualInstance(o); } + public RoutingRuleAction(RoutingRuleRerouteToTeamAction o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put("SendSlackMessageAction", new GenericType() {}); schemas.put("SendTeamsMessageAction", new GenericType() {}); @@ -315,6 +366,8 @@ public RoutingRuleAction(RoutingRuleEscalationPolicyAction o) { schemas.put( "RoutingRuleEscalationPolicyAction", new GenericType() {}); + schemas.put( + "RoutingRuleRerouteToTeamAction", new GenericType() {}); JSON.registerDescendants(RoutingRuleAction.class, Collections.unmodifiableMap(schemas)); } @@ -326,7 +379,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, - * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction + * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction, + * RoutingRuleRerouteToTeamAction * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -351,6 +405,11 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + RoutingRuleRerouteToTeamAction.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); @@ -358,15 +417,18 @@ public void setActualInstance(Object instance) { } throw new RuntimeException( "Invalid instance type. Must be SendSlackMessageAction, SendTeamsMessageAction," - + " TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction"); + + " TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction," + + " RoutingRuleRerouteToTeamAction"); } /** * Get the actual instance, which can be the following: SendSlackMessageAction, - * SendTeamsMessageAction, TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction + * SendTeamsMessageAction, TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction, + * RoutingRuleRerouteToTeamAction * * @return The actual instance (SendSlackMessageAction, SendTeamsMessageAction, - * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction) + * TriggerWorkflowAutomationAction, RoutingRuleEscalationPolicyAction, + * RoutingRuleRerouteToTeamAction) */ @Override public Object getActualInstance() { @@ -418,4 +480,16 @@ public RoutingRuleEscalationPolicyAction getRoutingRuleEscalationPolicyAction() throws ClassCastException { return (RoutingRuleEscalationPolicyAction) super.getActualInstance(); } + + /** + * Get the actual instance of `RoutingRuleRerouteToTeamAction`. If the actual instance is not + * `RoutingRuleRerouteToTeamAction`, the ClassCastException will be thrown. + * + * @return The actual instance of `RoutingRuleRerouteToTeamAction` + * @throws ClassCastException if the instance is not `RoutingRuleRerouteToTeamAction` + */ + public RoutingRuleRerouteToTeamAction getRoutingRuleRerouteToTeamAction() + throws ClassCastException { + return (RoutingRuleRerouteToTeamAction) super.getActualInstance(); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/RoutingRuleRerouteToTeamAction.java b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleRerouteToTeamAction.java new file mode 100644 index 00000000000..08c290ef24a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleRerouteToTeamAction.java @@ -0,0 +1,190 @@ +/* + * 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; +import java.util.UUID; + +/** + * Reroutes the page to another team, which then evaluates it against its own routing rules. Each + * routing rule can include this action only once. It can be combined only with + * send_slack_message and send_teams_message actions. It can't be used with + * escalation_policy or workflow actions, or when the routing rule sets + * policy_id. + */ +@JsonPropertyOrder({ + RoutingRuleRerouteToTeamAction.JSON_PROPERTY_DESTINATION_TEAM_ID, + RoutingRuleRerouteToTeamAction.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RoutingRuleRerouteToTeamAction { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DESTINATION_TEAM_ID = "destination_team_id"; + private UUID destinationTeamId; + + public static final String JSON_PROPERTY_TYPE = "type"; + private RoutingRuleRerouteToTeamActionType type = + RoutingRuleRerouteToTeamActionType.REROUTE_TO_TEAM; + + public RoutingRuleRerouteToTeamAction() {} + + @JsonCreator + public RoutingRuleRerouteToTeamAction( + @JsonProperty(required = true, value = JSON_PROPERTY_DESTINATION_TEAM_ID) + UUID destinationTeamId, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + RoutingRuleRerouteToTeamActionType type) { + this.destinationTeamId = destinationTeamId; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public RoutingRuleRerouteToTeamAction destinationTeamId(UUID destinationTeamId) { + this.destinationTeamId = destinationTeamId; + return this; + } + + /** + * The ID of the team to reroute the page to. + * + * @return destinationTeamId + */ + @JsonProperty(JSON_PROPERTY_DESTINATION_TEAM_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getDestinationTeamId() { + return destinationTeamId; + } + + public void setDestinationTeamId(UUID destinationTeamId) { + this.destinationTeamId = destinationTeamId; + } + + public RoutingRuleRerouteToTeamAction type(RoutingRuleRerouteToTeamActionType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Indicates that the action reroutes the page to another team's routing rules. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public RoutingRuleRerouteToTeamActionType getType() { + return type; + } + + public void setType(RoutingRuleRerouteToTeamActionType 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 RoutingRuleRerouteToTeamAction + */ + @JsonAnySetter + public RoutingRuleRerouteToTeamAction 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 RoutingRuleRerouteToTeamAction object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RoutingRuleRerouteToTeamAction routingRuleRerouteToTeamAction = + (RoutingRuleRerouteToTeamAction) o; + return Objects.equals(this.destinationTeamId, routingRuleRerouteToTeamAction.destinationTeamId) + && Objects.equals(this.type, routingRuleRerouteToTeamAction.type) + && Objects.equals( + this.additionalProperties, routingRuleRerouteToTeamAction.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(destinationTeamId, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RoutingRuleRerouteToTeamAction {\n"); + sb.append(" destinationTeamId: ").append(toIndentedString(destinationTeamId)).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/RoutingRuleRerouteToTeamActionType.java b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleRerouteToTeamActionType.java new file mode 100644 index 00000000000..60aee3bbc37 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RoutingRuleRerouteToTeamActionType.java @@ -0,0 +1,59 @@ +/* + * 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 reroutes the page to another team's routing rules. */ +@JsonSerialize( + using = RoutingRuleRerouteToTeamActionType.RoutingRuleRerouteToTeamActionTypeSerializer.class) +public class RoutingRuleRerouteToTeamActionType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("reroute_to_team")); + + public static final RoutingRuleRerouteToTeamActionType REROUTE_TO_TEAM = + new RoutingRuleRerouteToTeamActionType("reroute_to_team"); + + RoutingRuleRerouteToTeamActionType(String value) { + super(value, allowedValues); + } + + public static class RoutingRuleRerouteToTeamActionTypeSerializer + extends StdSerializer { + public RoutingRuleRerouteToTeamActionTypeSerializer( + Class t) { + super(t); + } + + public RoutingRuleRerouteToTeamActionTypeSerializer() { + this(null); + } + + @Override + public void serialize( + RoutingRuleRerouteToTeamActionType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static RoutingRuleRerouteToTeamActionType fromValue(String value) { + return new RoutingRuleRerouteToTeamActionType(value); + } +}