From bf9420fc3fc49dd23773788373f0a3cc220936ac Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 10 Jul 2026 14:35:17 +0000 Subject: [PATCH] Regenerate client from commit 492dc21 of spec repo --- .generator/schemas/v1/openapi.yaml | 78 +++++ ...hboardAvailableValuesEventsDataSource.java | 67 ++++ .../DashboardAvailableValuesEventsQuery.java | 173 ++++++++++ ...vailableValuesEventsQueryGroupByItems.java | 91 +++++ ...boardAvailableValuesEventsQuerySearch.java | 90 +++++ .../DashboardAvailableValuesMetricsQuery.java | 127 +++++++ .../v1/model/DashboardTemplateVariable.java | 78 ++++- ...dTemplateVariableAvailableValuesQuery.java | 312 ++++++++++++++++++ .../api/client/v1/api/dashboards.feature | 6 +- 9 files changed, 1018 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsDataSource.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuery.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQueryGroupByItems.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuerySearch.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesMetricsQuery.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariableAvailableValuesQuery.java diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index b41f414fd36..05258906e67 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1530,6 +1530,72 @@ components: - layout_type - widgets type: object + DashboardAvailableValuesEventsDataSource: + description: The events-based data source for the query. + enum: + - spans + - logs + - rum + example: spans + type: string + x-enum-varnames: + - SPANS + - LOGS + - RUM + DashboardAvailableValuesEventsQuery: + additionalProperties: false + description: Query for available values using an events-based data source (spans, logs, or rum). + properties: + data_source: + $ref: "#/components/schemas/DashboardAvailableValuesEventsDataSource" + group_by: + description: The fields to group by in the query. + items: + $ref: "#/components/schemas/DashboardAvailableValuesEventsQueryGroupByItems" + type: array + search: + $ref: "#/components/schemas/DashboardAvailableValuesEventsQuerySearch" + required: + - data_source + - search + - group_by + type: object + DashboardAvailableValuesEventsQueryGroupByItems: + additionalProperties: false + description: A field to group by in the available values query. + properties: + facet: + description: The facet to group by. + example: "" + type: string + required: + - facet + type: object + DashboardAvailableValuesEventsQuerySearch: + additionalProperties: false + description: The search filter for the query. + properties: + query: + description: The search query string. + example: "" + type: string + required: + - query + type: object + DashboardAvailableValuesMetricsQuery: + additionalProperties: false + description: Query for available values using the metrics data source. + properties: + data_source: + $ref: "#/components/schemas/FormulaAndFunctionMetricDataSource" + query: + description: The metrics query string. + example: "" + type: string + required: + - data_source + - query + type: object DashboardBulkActionData: description: Dashboard bulk action request data. example: {"id": "123-abc-456", "type": "dashboard"} @@ -1800,6 +1866,13 @@ components: type: string nullable: true type: array + available_values_query: + $ref: "#/components/schemas/DashboardTemplateVariableAvailableValuesQuery" + data_source_mappings: + additionalProperties: + type: string + description: A mapping from data source type to the variable value to use for that data source. + type: object default: deprecated: true description: (deprecated) The default value for the template variable on dashboard load. Cannot be used in conjunction with `defaults`. @@ -1831,6 +1904,11 @@ components: required: - name type: object + DashboardTemplateVariableAvailableValuesQuery: + description: A query that dynamically computes the list of values available for this template variable. + oneOf: + - $ref: "#/components/schemas/DashboardAvailableValuesEventsQuery" + - $ref: "#/components/schemas/DashboardAvailableValuesMetricsQuery" DashboardTemplateVariablePreset: description: Template variables saved views. properties: diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsDataSource.java b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsDataSource.java new file mode 100644 index 00000000000..21d29d3320d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsDataSource.java @@ -0,0 +1,67 @@ +/* + * 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.v1.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; + +/** The events-based data source for the query. */ +@JsonSerialize( + using = + DashboardAvailableValuesEventsDataSource.DashboardAvailableValuesEventsDataSourceSerializer + .class) +public class DashboardAvailableValuesEventsDataSource extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("spans", "logs", "rum")); + + public static final DashboardAvailableValuesEventsDataSource SPANS = + new DashboardAvailableValuesEventsDataSource("spans"); + public static final DashboardAvailableValuesEventsDataSource LOGS = + new DashboardAvailableValuesEventsDataSource("logs"); + public static final DashboardAvailableValuesEventsDataSource RUM = + new DashboardAvailableValuesEventsDataSource("rum"); + + DashboardAvailableValuesEventsDataSource(String value) { + super(value, allowedValues); + } + + public static class DashboardAvailableValuesEventsDataSourceSerializer + extends StdSerializer { + public DashboardAvailableValuesEventsDataSourceSerializer( + Class t) { + super(t); + } + + public DashboardAvailableValuesEventsDataSourceSerializer() { + this(null); + } + + @Override + public void serialize( + DashboardAvailableValuesEventsDataSource value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static DashboardAvailableValuesEventsDataSource fromValue(String value) { + return new DashboardAvailableValuesEventsDataSource(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuery.java b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuery.java new file mode 100644 index 00000000000..1f88566a9fc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuery.java @@ -0,0 +1,173 @@ +/* + * 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.v1.model; + +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.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Query for available values using an events-based data source (spans, logs, or rum). */ +@JsonPropertyOrder({ + DashboardAvailableValuesEventsQuery.JSON_PROPERTY_DATA_SOURCE, + DashboardAvailableValuesEventsQuery.JSON_PROPERTY_GROUP_BY, + DashboardAvailableValuesEventsQuery.JSON_PROPERTY_SEARCH +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardAvailableValuesEventsQuery { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA_SOURCE = "data_source"; + private DashboardAvailableValuesEventsDataSource dataSource; + + public static final String JSON_PROPERTY_GROUP_BY = "group_by"; + private List groupBy = new ArrayList<>(); + + public static final String JSON_PROPERTY_SEARCH = "search"; + private DashboardAvailableValuesEventsQuerySearch search; + + public DashboardAvailableValuesEventsQuery() {} + + @JsonCreator + public DashboardAvailableValuesEventsQuery( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA_SOURCE) + DashboardAvailableValuesEventsDataSource dataSource, + @JsonProperty(required = true, value = JSON_PROPERTY_GROUP_BY) + List groupBy, + @JsonProperty(required = true, value = JSON_PROPERTY_SEARCH) + DashboardAvailableValuesEventsQuerySearch search) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + this.groupBy = groupBy; + this.search = search; + this.unparsed |= search.unparsed; + } + + public DashboardAvailableValuesEventsQuery dataSource( + DashboardAvailableValuesEventsDataSource dataSource) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + return this; + } + + /** + * The events-based data source for the query. + * + * @return dataSource + */ + @JsonProperty(JSON_PROPERTY_DATA_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DashboardAvailableValuesEventsDataSource getDataSource() { + return dataSource; + } + + public void setDataSource(DashboardAvailableValuesEventsDataSource dataSource) { + if (!dataSource.isValid()) { + this.unparsed = true; + } + this.dataSource = dataSource; + } + + public DashboardAvailableValuesEventsQuery groupBy( + List groupBy) { + this.groupBy = groupBy; + for (DashboardAvailableValuesEventsQueryGroupByItems item : groupBy) { + this.unparsed |= item.unparsed; + } + return this; + } + + public DashboardAvailableValuesEventsQuery addGroupByItem( + DashboardAvailableValuesEventsQueryGroupByItems groupByItem) { + this.groupBy.add(groupByItem); + this.unparsed |= groupByItem.unparsed; + return this; + } + + /** + * The fields to group by in the query. + * + * @return groupBy + */ + @JsonProperty(JSON_PROPERTY_GROUP_BY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getGroupBy() { + return groupBy; + } + + public void setGroupBy(List groupBy) { + this.groupBy = groupBy; + } + + public DashboardAvailableValuesEventsQuery search( + DashboardAvailableValuesEventsQuerySearch search) { + this.search = search; + this.unparsed |= search.unparsed; + return this; + } + + /** + * The search filter for the query. + * + * @return search + */ + @JsonProperty(JSON_PROPERTY_SEARCH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public DashboardAvailableValuesEventsQuerySearch getSearch() { + return search; + } + + public void setSearch(DashboardAvailableValuesEventsQuerySearch search) { + this.search = search; + } + + /** Return true if this DashboardAvailableValuesEventsQuery object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardAvailableValuesEventsQuery dashboardAvailableValuesEventsQuery = + (DashboardAvailableValuesEventsQuery) o; + return Objects.equals(this.dataSource, dashboardAvailableValuesEventsQuery.dataSource) + && Objects.equals(this.groupBy, dashboardAvailableValuesEventsQuery.groupBy) + && Objects.equals(this.search, dashboardAvailableValuesEventsQuery.search); + } + + @Override + public int hashCode() { + return Objects.hash(dataSource, groupBy, search); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardAvailableValuesEventsQuery {\n"); + sb.append(" dataSource: ").append(toIndentedString(dataSource)).append("\n"); + sb.append(" groupBy: ").append(toIndentedString(groupBy)).append("\n"); + sb.append(" search: ").append(toIndentedString(search)).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/v1/model/DashboardAvailableValuesEventsQueryGroupByItems.java b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQueryGroupByItems.java new file mode 100644 index 00000000000..2b0e0fb02b9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQueryGroupByItems.java @@ -0,0 +1,91 @@ +/* + * 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.v1.model; + +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.Objects; + +/** A field to group by in the available values query. */ +@JsonPropertyOrder({DashboardAvailableValuesEventsQueryGroupByItems.JSON_PROPERTY_FACET}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardAvailableValuesEventsQueryGroupByItems { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FACET = "facet"; + private String facet; + + public DashboardAvailableValuesEventsQueryGroupByItems() {} + + @JsonCreator + public DashboardAvailableValuesEventsQueryGroupByItems( + @JsonProperty(required = true, value = JSON_PROPERTY_FACET) String facet) { + this.facet = facet; + } + + public DashboardAvailableValuesEventsQueryGroupByItems facet(String facet) { + this.facet = facet; + return this; + } + + /** + * The facet to group by. + * + * @return facet + */ + @JsonProperty(JSON_PROPERTY_FACET) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFacet() { + return facet; + } + + public void setFacet(String facet) { + this.facet = facet; + } + + /** Return true if this DashboardAvailableValuesEventsQueryGroupByItems object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardAvailableValuesEventsQueryGroupByItems + dashboardAvailableValuesEventsQueryGroupByItems = + (DashboardAvailableValuesEventsQueryGroupByItems) o; + return Objects.equals(this.facet, dashboardAvailableValuesEventsQueryGroupByItems.facet); + } + + @Override + public int hashCode() { + return Objects.hash(facet); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardAvailableValuesEventsQueryGroupByItems {\n"); + sb.append(" facet: ").append(toIndentedString(facet)).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/v1/model/DashboardAvailableValuesEventsQuerySearch.java b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuerySearch.java new file mode 100644 index 00000000000..4656f1c376e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesEventsQuerySearch.java @@ -0,0 +1,90 @@ +/* + * 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.v1.model; + +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.Objects; + +/** The search filter for the query. */ +@JsonPropertyOrder({DashboardAvailableValuesEventsQuerySearch.JSON_PROPERTY_QUERY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardAvailableValuesEventsQuerySearch { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public DashboardAvailableValuesEventsQuerySearch() {} + + @JsonCreator + public DashboardAvailableValuesEventsQuerySearch( + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) { + this.query = query; + } + + public DashboardAvailableValuesEventsQuerySearch query(String query) { + this.query = query; + return this; + } + + /** + * The search query string. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** Return true if this DashboardAvailableValuesEventsQuerySearch object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardAvailableValuesEventsQuerySearch dashboardAvailableValuesEventsQuerySearch = + (DashboardAvailableValuesEventsQuerySearch) o; + return Objects.equals(this.query, dashboardAvailableValuesEventsQuerySearch.query); + } + + @Override + public int hashCode() { + return Objects.hash(query); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardAvailableValuesEventsQuerySearch {\n"); + sb.append(" query: ").append(toIndentedString(query)).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/v1/model/DashboardAvailableValuesMetricsQuery.java b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesMetricsQuery.java new file mode 100644 index 00000000000..d6b5938af93 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardAvailableValuesMetricsQuery.java @@ -0,0 +1,127 @@ +/* + * 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.v1.model; + +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.Objects; + +/** Query for available values using the metrics data source. */ +@JsonPropertyOrder({ + DashboardAvailableValuesMetricsQuery.JSON_PROPERTY_DATA_SOURCE, + DashboardAvailableValuesMetricsQuery.JSON_PROPERTY_QUERY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class DashboardAvailableValuesMetricsQuery { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA_SOURCE = "data_source"; + private FormulaAndFunctionMetricDataSource dataSource; + + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public DashboardAvailableValuesMetricsQuery() {} + + @JsonCreator + public DashboardAvailableValuesMetricsQuery( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA_SOURCE) + FormulaAndFunctionMetricDataSource dataSource, + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + this.query = query; + } + + public DashboardAvailableValuesMetricsQuery dataSource( + FormulaAndFunctionMetricDataSource dataSource) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + return this; + } + + /** + * Data source for metrics queries. + * + * @return dataSource + */ + @JsonProperty(JSON_PROPERTY_DATA_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public FormulaAndFunctionMetricDataSource getDataSource() { + return dataSource; + } + + public void setDataSource(FormulaAndFunctionMetricDataSource dataSource) { + if (!dataSource.isValid()) { + this.unparsed = true; + } + this.dataSource = dataSource; + } + + public DashboardAvailableValuesMetricsQuery query(String query) { + this.query = query; + return this; + } + + /** + * The metrics query string. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** Return true if this DashboardAvailableValuesMetricsQuery object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DashboardAvailableValuesMetricsQuery dashboardAvailableValuesMetricsQuery = + (DashboardAvailableValuesMetricsQuery) o; + return Objects.equals(this.dataSource, dashboardAvailableValuesMetricsQuery.dataSource) + && Objects.equals(this.query, dashboardAvailableValuesMetricsQuery.query); + } + + @Override + public int hashCode() { + return Objects.hash(dataSource, query); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DashboardAvailableValuesMetricsQuery {\n"); + sb.append(" dataSource: ").append(toIndentedString(dataSource)).append("\n"); + sb.append(" query: ").append(toIndentedString(query)).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/v1/model/DashboardTemplateVariable.java b/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariable.java index 85a6e8d9099..be5ded7c9bf 100644 --- a/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariable.java +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariable.java @@ -23,6 +23,8 @@ /** Template variable. */ @JsonPropertyOrder({ DashboardTemplateVariable.JSON_PROPERTY_AVAILABLE_VALUES, + DashboardTemplateVariable.JSON_PROPERTY_AVAILABLE_VALUES_QUERY, + DashboardTemplateVariable.JSON_PROPERTY_DATA_SOURCE_MAPPINGS, DashboardTemplateVariable.JSON_PROPERTY_DEFAULT, DashboardTemplateVariable.JSON_PROPERTY_DEFAULTS, DashboardTemplateVariable.JSON_PROPERTY_NAME, @@ -36,6 +38,12 @@ public class DashboardTemplateVariable { public static final String JSON_PROPERTY_AVAILABLE_VALUES = "available_values"; private JsonNullable> availableValues = JsonNullable.>undefined(); + public static final String JSON_PROPERTY_AVAILABLE_VALUES_QUERY = "available_values_query"; + private DashboardTemplateVariableAvailableValuesQuery availableValuesQuery; + + public static final String JSON_PROPERTY_DATA_SOURCE_MAPPINGS = "data_source_mappings"; + private Map dataSourceMappings = null; + public static final String JSON_PROPERTY_DEFAULT = "default"; private JsonNullable _default = JsonNullable.undefined(); @@ -102,6 +110,60 @@ public void setAvailableValues(List availableValues) { this.availableValues = JsonNullable.>of(availableValues); } + public DashboardTemplateVariable availableValuesQuery( + DashboardTemplateVariableAvailableValuesQuery availableValuesQuery) { + this.availableValuesQuery = availableValuesQuery; + this.unparsed |= availableValuesQuery.unparsed; + return this; + } + + /** + * A query that dynamically computes the list of values available for this template variable. + * + * @return availableValuesQuery + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AVAILABLE_VALUES_QUERY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public DashboardTemplateVariableAvailableValuesQuery getAvailableValuesQuery() { + return availableValuesQuery; + } + + public void setAvailableValuesQuery( + DashboardTemplateVariableAvailableValuesQuery availableValuesQuery) { + this.availableValuesQuery = availableValuesQuery; + } + + public DashboardTemplateVariable dataSourceMappings(Map dataSourceMappings) { + this.dataSourceMappings = dataSourceMappings; + return this; + } + + public DashboardTemplateVariable putDataSourceMappingsItem( + String key, String dataSourceMappingsItem) { + if (this.dataSourceMappings == null) { + this.dataSourceMappings = new HashMap<>(); + } + this.dataSourceMappings.put(key, dataSourceMappingsItem); + return this; + } + + /** + * A mapping from data source type to the variable value to use for that data source. + * + * @return dataSourceMappings + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA_SOURCE_MAPPINGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Map getDataSourceMappings() { + return dataSourceMappings; + } + + public void setDataSourceMappings(Map dataSourceMappings) { + this.dataSourceMappings = dataSourceMappings; + } + public DashboardTemplateVariable _default(String _default) { this._default = JsonNullable.of(_default); return this; @@ -309,6 +371,8 @@ public boolean equals(Object o) { } DashboardTemplateVariable dashboardTemplateVariable = (DashboardTemplateVariable) o; return Objects.equals(this.availableValues, dashboardTemplateVariable.availableValues) + && Objects.equals(this.availableValuesQuery, dashboardTemplateVariable.availableValuesQuery) + && Objects.equals(this.dataSourceMappings, dashboardTemplateVariable.dataSourceMappings) && Objects.equals(this._default, dashboardTemplateVariable._default) && Objects.equals(this.defaults, dashboardTemplateVariable.defaults) && Objects.equals(this.name, dashboardTemplateVariable.name) @@ -321,7 +385,15 @@ public boolean equals(Object o) { @Override public int hashCode() { return Objects.hash( - availableValues, _default, defaults, name, prefix, type, additionalProperties); + availableValues, + availableValuesQuery, + dataSourceMappings, + _default, + defaults, + name, + prefix, + type, + additionalProperties); } @Override @@ -329,6 +401,10 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DashboardTemplateVariable {\n"); sb.append(" availableValues: ").append(toIndentedString(availableValues)).append("\n"); + sb.append(" availableValuesQuery: ") + .append(toIndentedString(availableValuesQuery)) + .append("\n"); + sb.append(" dataSourceMappings: ").append(toIndentedString(dataSourceMappings)).append("\n"); sb.append(" _default: ").append(toIndentedString(_default)).append("\n"); sb.append(" defaults: ").append(toIndentedString(defaults)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariableAvailableValuesQuery.java b/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariableAvailableValuesQuery.java new file mode 100644 index 00000000000..81467dbff66 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/DashboardTemplateVariableAvailableValuesQuery.java @@ -0,0 +1,312 @@ +/* + * 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.v1.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.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 = + DashboardTemplateVariableAvailableValuesQuery + .DashboardTemplateVariableAvailableValuesQueryDeserializer.class) +@JsonSerialize( + using = + DashboardTemplateVariableAvailableValuesQuery + .DashboardTemplateVariableAvailableValuesQuerySerializer.class) +public class DashboardTemplateVariableAvailableValuesQuery extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(DashboardTemplateVariableAvailableValuesQuery.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DashboardTemplateVariableAvailableValuesQuerySerializer + extends StdSerializer { + public DashboardTemplateVariableAvailableValuesQuerySerializer( + Class t) { + super(t); + } + + public DashboardTemplateVariableAvailableValuesQuerySerializer() { + this(null); + } + + @Override + public void serialize( + DashboardTemplateVariableAvailableValuesQuery value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DashboardTemplateVariableAvailableValuesQueryDeserializer + extends StdDeserializer { + public DashboardTemplateVariableAvailableValuesQueryDeserializer() { + this(DashboardTemplateVariableAvailableValuesQuery.class); + } + + public DashboardTemplateVariableAvailableValuesQueryDeserializer(Class vc) { + super(vc); + } + + @Override + public DashboardTemplateVariableAvailableValuesQuery 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; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize DashboardAvailableValuesEventsQuery + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DashboardAvailableValuesEventsQuery.class.equals(Integer.class) + || DashboardAvailableValuesEventsQuery.class.equals(Long.class) + || DashboardAvailableValuesEventsQuery.class.equals(Float.class) + || DashboardAvailableValuesEventsQuery.class.equals(Double.class) + || DashboardAvailableValuesEventsQuery.class.equals(Boolean.class) + || DashboardAvailableValuesEventsQuery.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DashboardAvailableValuesEventsQuery.class.equals(Integer.class) + || DashboardAvailableValuesEventsQuery.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DashboardAvailableValuesEventsQuery.class.equals(Float.class) + || DashboardAvailableValuesEventsQuery.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DashboardAvailableValuesEventsQuery.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DashboardAvailableValuesEventsQuery.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(DashboardAvailableValuesEventsQuery.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 (!((DashboardAvailableValuesEventsQuery) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DashboardAvailableValuesEventsQuery'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DashboardAvailableValuesEventsQuery'", + e); + } + + // deserialize DashboardAvailableValuesMetricsQuery + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DashboardAvailableValuesMetricsQuery.class.equals(Integer.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Long.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Float.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Double.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Boolean.class) + || DashboardAvailableValuesMetricsQuery.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DashboardAvailableValuesMetricsQuery.class.equals(Integer.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DashboardAvailableValuesMetricsQuery.class.equals(Float.class) + || DashboardAvailableValuesMetricsQuery.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (DashboardAvailableValuesMetricsQuery.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DashboardAvailableValuesMetricsQuery.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()).readValueAs(DashboardAvailableValuesMetricsQuery.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 (!((DashboardAvailableValuesMetricsQuery) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'DashboardAvailableValuesMetricsQuery'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'DashboardAvailableValuesMetricsQuery'", + e); + } + + DashboardTemplateVariableAvailableValuesQuery ret = + new DashboardTemplateVariableAvailableValuesQuery(); + if (match == 1) { + ret.setActualInstance(deserialized); + } 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 DashboardTemplateVariableAvailableValuesQuery getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DashboardTemplateVariableAvailableValuesQuery cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DashboardTemplateVariableAvailableValuesQuery() { + super("oneOf", Boolean.FALSE); + } + + public DashboardTemplateVariableAvailableValuesQuery(DashboardAvailableValuesEventsQuery o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DashboardTemplateVariableAvailableValuesQuery(DashboardAvailableValuesMetricsQuery o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put( + "DashboardAvailableValuesEventsQuery", + new GenericType() {}); + schemas.put( + "DashboardAvailableValuesMetricsQuery", + new GenericType() {}); + JSON.registerDescendants( + DashboardTemplateVariableAvailableValuesQuery.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DashboardTemplateVariableAvailableValuesQuery.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: DashboardAvailableValuesEventsQuery, + * DashboardAvailableValuesMetricsQuery + * + *

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( + DashboardAvailableValuesEventsQuery.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + DashboardAvailableValuesMetricsQuery.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 DashboardAvailableValuesEventsQuery," + + " DashboardAvailableValuesMetricsQuery"); + } + + /** + * Get the actual instance, which can be the following: DashboardAvailableValuesEventsQuery, + * DashboardAvailableValuesMetricsQuery + * + * @return The actual instance (DashboardAvailableValuesEventsQuery, + * DashboardAvailableValuesMetricsQuery) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `DashboardAvailableValuesEventsQuery`. If the actual instance is not + * `DashboardAvailableValuesEventsQuery`, the ClassCastException will be thrown. + * + * @return The actual instance of `DashboardAvailableValuesEventsQuery` + * @throws ClassCastException if the instance is not `DashboardAvailableValuesEventsQuery` + */ + public DashboardAvailableValuesEventsQuery getDashboardAvailableValuesEventsQuery() + throws ClassCastException { + return (DashboardAvailableValuesEventsQuery) super.getActualInstance(); + } + + /** + * Get the actual instance of `DashboardAvailableValuesMetricsQuery`. If the actual instance is + * not `DashboardAvailableValuesMetricsQuery`, the ClassCastException will be thrown. + * + * @return The actual instance of `DashboardAvailableValuesMetricsQuery` + * @throws ClassCastException if the instance is not `DashboardAvailableValuesMetricsQuery` + */ + public DashboardAvailableValuesMetricsQuery getDashboardAvailableValuesMetricsQuery() + throws ClassCastException { + return (DashboardAvailableValuesMetricsQuery) super.getActualInstance(); + } +} diff --git a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature index 28e57ec5e2a..404e2f6d342 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/dashboards.feature @@ -90,7 +90,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards-backend Scenario: Create a new dashboard returns "Bad Request" response Given new "CreateDashboard" request - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "spans", "group_by": [{"facet": ""}], "search": {"query": ""}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1481,7 +1481,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Bad Request" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "spans", "group_by": [{"facet": ""}], "search": {"query": ""}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 400 Bad Request @@ -1489,7 +1489,7 @@ Feature: Dashboards Scenario: Update a dashboard returns "Item Not Found" response Given new "UpdateDashboard" request And request contains "dashboard_id" parameter from "REPLACE.ME" - And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} + And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [], "reflow_type": "auto", "restricted_roles": [], "tabs": [{"id": "", "name": "L", "widget_ids": [0]}], "tags": [], "template_variable_presets": [{"template_variables": [{"values": []}]}], "template_variables": [{"available_values": ["my-host", "host1", "host2"], "available_values_query": {"data_source": "spans", "group_by": [{"facet": ""}], "search": {"query": ""}}, "default": "my-host", "defaults": ["my-host-1", "my-host-2"], "name": "host1", "prefix": "host", "type": "group"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "avg:system.cpu.user{*}"}}, "type": "hostmap"}}]} When the request is sent Then the response status is 404 Item Not Found