From 1c523304403b6244c2a25a92f32a64de2867a748 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 24 Jul 2026 21:49:14 +0000 Subject: [PATCH] Regenerate client from commit 0f642af of spec repo --- .generator/schemas/v2/openapi.yaml | 48 ++- .../model/MetricAvailableAggrFunctions.java | 64 ++++ .../v2/model/MetricCustomAggregations.java | 304 ++++++++++++++++++ .../MetricTagConfigurationAttributes.java | 28 +- ...etricTagConfigurationCreateAttributes.java | 28 +- ...etricTagConfigurationUpdateAttributes.java | 28 +- 6 files changed, 426 insertions(+), 74 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v2/model/MetricAvailableAggrFunctions.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/MetricCustomAggregations.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 92d598bce34..c8eaa834914 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -61652,6 +61652,26 @@ components: $ref: "#/components/schemas/MetricAssetResponseIncluded" type: array type: object + MetricAvailableAggrFunctions: + description: A single aggregation function used to query a metric. + enum: + - avg + - min + - max + - sum + - count + - stddev + - pxx + example: avg + type: string + x-enum-varnames: + - AVG + - MIN + - MAX + - SUM + - COUNT + - STDDEV + - PXX MetricBulkConfigureTagsType: default: metric_bulk_configure_tags description: The metric bulk configure tags resource. @@ -61830,14 +61850,26 @@ components: MetricCustomAggregations: description: |- Deprecated. You no longer need to configure specific time and space aggregations for Metrics Without Limits. - example: - - space: sum - time: sum - - space: sum - time: count - items: - $ref: "#/components/schemas/MetricCustomAggregation" - type: array + oneOf: + - example: + - space: sum + time: sum + - space: sum + time: count + items: + $ref: "#/components/schemas/MetricCustomAggregation" + type: array + - example: + - avg + - min + - max + - sum + - count + - stddev + - pxx + items: + $ref: "#/components/schemas/MetricAvailableAggrFunctions" + type: array MetricCustomSpaceAggregation: description: A space aggregation for use in query. enum: diff --git a/src/main/java/com/datadog/api/client/v2/model/MetricAvailableAggrFunctions.java b/src/main/java/com/datadog/api/client/v2/model/MetricAvailableAggrFunctions.java new file mode 100644 index 00000000000..7513d516382 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MetricAvailableAggrFunctions.java @@ -0,0 +1,64 @@ +/* + * 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; + +/** A single aggregation function used to query a metric. */ +@JsonSerialize(using = MetricAvailableAggrFunctions.MetricAvailableAggrFunctionsSerializer.class) +public class MetricAvailableAggrFunctions extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("avg", "min", "max", "sum", "count", "stddev", "pxx")); + + public static final MetricAvailableAggrFunctions AVG = new MetricAvailableAggrFunctions("avg"); + public static final MetricAvailableAggrFunctions MIN = new MetricAvailableAggrFunctions("min"); + public static final MetricAvailableAggrFunctions MAX = new MetricAvailableAggrFunctions("max"); + public static final MetricAvailableAggrFunctions SUM = new MetricAvailableAggrFunctions("sum"); + public static final MetricAvailableAggrFunctions COUNT = + new MetricAvailableAggrFunctions("count"); + public static final MetricAvailableAggrFunctions STDDEV = + new MetricAvailableAggrFunctions("stddev"); + public static final MetricAvailableAggrFunctions PXX = new MetricAvailableAggrFunctions("pxx"); + + MetricAvailableAggrFunctions(String value) { + super(value, allowedValues); + } + + public static class MetricAvailableAggrFunctionsSerializer + extends StdSerializer { + public MetricAvailableAggrFunctionsSerializer(Class t) { + super(t); + } + + public MetricAvailableAggrFunctionsSerializer() { + this(null); + } + + @Override + public void serialize( + MetricAvailableAggrFunctions value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static MetricAvailableAggrFunctions fromValue(String value) { + return new MetricAvailableAggrFunctions(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MetricCustomAggregations.java b/src/main/java/com/datadog/api/client/v2/model/MetricCustomAggregations.java new file mode 100644 index 00000000000..ad3fbb3e75f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/MetricCustomAggregations.java @@ -0,0 +1,304 @@ +/* + * 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.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize(using = MetricCustomAggregations.MetricCustomAggregationsDeserializer.class) +@JsonSerialize(using = MetricCustomAggregations.MetricCustomAggregationsSerializer.class) +public class MetricCustomAggregations extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(MetricCustomAggregations.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class MetricCustomAggregationsSerializer + extends StdSerializer { + public MetricCustomAggregationsSerializer(Class t) { + super(t); + } + + public MetricCustomAggregationsSerializer() { + this(null); + } + + @Override + public void serialize( + MetricCustomAggregations value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class MetricCustomAggregationsDeserializer + extends StdDeserializer { + public MetricCustomAggregationsDeserializer() { + this(MetricCustomAggregations.class); + } + + public MetricCustomAggregationsDeserializer(Class vc) { + super(vc); + } + + @Override + public MetricCustomAggregations deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + Object deserializedUnparsed = null; + int matchUnparsed = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize List + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (List.class.equals(Integer.class) + || List.class.equals(Long.class) + || List.class.equals(Float.class) + || List.class.equals(Double.class) + || List.class.equals(Boolean.class) + || List.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((List.class.equals(Integer.class) || List.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((List.class.equals(Float.class) || List.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (List.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(new TypeReference>() {}); + // 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. + // keep the matched list, but propagate 'unparsed' from any invalid item + boolean itemsUnparsed = false; + for (MetricCustomAggregation item : (List) tmp) { + itemsUnparsed |= item.unparsed; + } + if (itemsUnparsed) { + deserializedUnparsed = tmp; + matchUnparsed++; + } else { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'List'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'List'", e); + } + + // deserialize List + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (List.class.equals(Integer.class) + || List.class.equals(Long.class) + || List.class.equals(Float.class) + || List.class.equals(Double.class) + || List.class.equals(Boolean.class) + || List.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((List.class.equals(Integer.class) || List.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((List.class.equals(Float.class) || List.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (List.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= (List.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(new TypeReference>() {}); + // 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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'List'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'List'", + e); + } + + MetricCustomAggregations ret = new MetricCustomAggregations(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else if (match == 0 && matchUnparsed == 1) { + ret.setActualInstance(deserializedUnparsed); + ret.unparsed = true; + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public MetricCustomAggregations getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "MetricCustomAggregations cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public MetricCustomAggregations() { + super("oneOf", Boolean.FALSE); + } + + public static MetricCustomAggregations fromMetricCustomAggregationList( + List o) { + MetricCustomAggregations instance = new MetricCustomAggregations(); + instance.setActualInstance(o); + return instance; + } + + public static MetricCustomAggregations fromMetricAvailableAggrFunctionsList( + List o) { + MetricCustomAggregations instance = new MetricCustomAggregations(); + instance.setActualInstance(o); + return instance; + } + + static { + schemas.put( + "List", new GenericType>() {}); + schemas.put( + "List", + new GenericType>() {}); + JSON.registerDescendants(MetricCustomAggregations.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return MetricCustomAggregations.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: List<MetricCustomAggregation>, + * List<MetricAvailableAggrFunctions> + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(List.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf(List.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 List," + + " List"); + } + + /** + * Get the actual instance, which can be the following: List<MetricCustomAggregation>, + * List<MetricAvailableAggrFunctions> + * + * @return The actual instance (List<MetricCustomAggregation>, + * List<MetricAvailableAggrFunctions>) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `List<MetricCustomAggregation>`. If the actual instance is not + * `List<MetricCustomAggregation>`, the ClassCastException will be thrown. + * + * @return The actual instance of `List<MetricCustomAggregation>` + * @throws ClassCastException if the instance is not `List<MetricCustomAggregation>` + */ + public List getMetricCustomAggregationList() throws ClassCastException { + return (List) super.getActualInstance(); + } + + /** + * Get the actual instance of `List<MetricAvailableAggrFunctions>`. If the actual instance + * is not `List<MetricAvailableAggrFunctions>`, the ClassCastException will be thrown. + * + * @return The actual instance of `List<MetricAvailableAggrFunctions>` + * @throws ClassCastException if the instance is not `List<MetricAvailableAggrFunctions>` + */ + public List getMetricAvailableAggrFunctionsList() + throws ClassCastException { + return (List) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationAttributes.java index d53d7c00764..7b3db94e54a 100644 --- a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationAttributes.java @@ -34,7 +34,7 @@ public class MetricTagConfigurationAttributes { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_AGGREGATIONS = "aggregations"; - private List aggregations = null; + private MetricCustomAggregations aggregations; public static final String JSON_PROPERTY_CREATED_AT = "created_at"; private OffsetDateTime createdAt; @@ -54,23 +54,9 @@ public class MetricTagConfigurationAttributes { public static final String JSON_PROPERTY_TAGS = "tags"; private List tags = null; - public MetricTagConfigurationAttributes aggregations(List aggregations) { + public MetricTagConfigurationAttributes aggregations(MetricCustomAggregations aggregations) { this.aggregations = aggregations; - if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } - } - return this; - } - - public MetricTagConfigurationAttributes addAggregationsItem( - MetricCustomAggregation aggregationsItem) { - if (this.aggregations == null) { - this.aggregations = new ArrayList<>(); - } - this.aggregations.add(aggregationsItem); - this.unparsed |= aggregationsItem.unparsed; + this.unparsed |= aggregations.unparsed; return this; } @@ -83,16 +69,14 @@ public MetricTagConfigurationAttributes addAggregationsItem( @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_AGGREGATIONS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public List getAggregations() { + public MetricCustomAggregations getAggregations() { return aggregations; } - public void setAggregations(List aggregations) { + public void setAggregations(MetricCustomAggregations aggregations) { this.aggregations = aggregations; if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } + this.unparsed |= aggregations.unparsed; } } diff --git a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationCreateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationCreateAttributes.java index efc14c62a88..7b7d52ac27f 100644 --- a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationCreateAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationCreateAttributes.java @@ -32,7 +32,7 @@ public class MetricTagConfigurationCreateAttributes { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_AGGREGATIONS = "aggregations"; - private List aggregations = null; + private MetricCustomAggregations aggregations; public static final String JSON_PROPERTY_EXCLUDE_TAGS_MODE = "exclude_tags_mode"; private Boolean excludeTagsMode; @@ -59,23 +59,9 @@ public MetricTagConfigurationCreateAttributes( } public MetricTagConfigurationCreateAttributes aggregations( - List aggregations) { + MetricCustomAggregations aggregations) { this.aggregations = aggregations; - if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } - } - return this; - } - - public MetricTagConfigurationCreateAttributes addAggregationsItem( - MetricCustomAggregation aggregationsItem) { - if (this.aggregations == null) { - this.aggregations = new ArrayList<>(); - } - this.aggregations.add(aggregationsItem); - this.unparsed |= aggregationsItem.unparsed; + this.unparsed |= aggregations.unparsed; return this; } @@ -88,16 +74,14 @@ public MetricTagConfigurationCreateAttributes addAggregationsItem( @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_AGGREGATIONS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public List getAggregations() { + public MetricCustomAggregations getAggregations() { return aggregations; } - public void setAggregations(List aggregations) { + public void setAggregations(MetricCustomAggregations aggregations) { this.aggregations = aggregations; if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } + this.unparsed |= aggregations.unparsed; } } diff --git a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationUpdateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationUpdateAttributes.java index 2a3b90483b3..c87742e3b35 100644 --- a/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationUpdateAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/MetricTagConfigurationUpdateAttributes.java @@ -30,7 +30,7 @@ public class MetricTagConfigurationUpdateAttributes { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_AGGREGATIONS = "aggregations"; - private List aggregations = null; + private MetricCustomAggregations aggregations; public static final String JSON_PROPERTY_EXCLUDE_TAGS_MODE = "exclude_tags_mode"; private Boolean excludeTagsMode; @@ -42,23 +42,9 @@ public class MetricTagConfigurationUpdateAttributes { private List tags = null; public MetricTagConfigurationUpdateAttributes aggregations( - List aggregations) { + MetricCustomAggregations aggregations) { this.aggregations = aggregations; - if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } - } - return this; - } - - public MetricTagConfigurationUpdateAttributes addAggregationsItem( - MetricCustomAggregation aggregationsItem) { - if (this.aggregations == null) { - this.aggregations = new ArrayList<>(); - } - this.aggregations.add(aggregationsItem); - this.unparsed |= aggregationsItem.unparsed; + this.unparsed |= aggregations.unparsed; return this; } @@ -71,16 +57,14 @@ public MetricTagConfigurationUpdateAttributes addAggregationsItem( @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_AGGREGATIONS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public List getAggregations() { + public MetricCustomAggregations getAggregations() { return aggregations; } - public void setAggregations(List aggregations) { + public void setAggregations(MetricCustomAggregations aggregations) { this.aggregations = aggregations; if (aggregations != null) { - for (MetricCustomAggregation item : aggregations) { - this.unparsed |= item.unparsed; - } + this.unparsed |= aggregations.unparsed; } }