From ee38c3a0c0d75950c97b62b045f4e734af47289c Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 11 Jul 2023 16:40:43 +0000 Subject: [PATCH] Regenerate client from commit 824086bb of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 33 +++ .../CreateDashboard_1284514532.java | 82 ++++++ ...FormulaAndFunctionCloudCostDataSource.java | 61 +++++ ...laAndFunctionCloudCostQueryDefinition.java | 243 ++++++++++++++++++ .../FormulaAndFunctionQueryDefinition.java | 88 ++++++- ...ulas_and_functions_cloud_cost_query.freeze | 1 + ...rmulas_and_functions_cloud_cost_query.json | 58 +++++ .../api/client/v1/api/dashboards.feature | 12 + 9 files changed, 578 insertions(+), 8 deletions(-) create mode 100644 examples/v1/dashboards/CreateDashboard_1284514532.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostDataSource.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostQueryDefinition.java create mode 100644 src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.freeze create mode 100644 src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.json diff --git a/.apigentools-info b/.apigentools-info index 000a4d982d2..f0e39811753 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.5", - "regenerated": "2023-07-11 14:36:43.463695", - "spec_repo_commit": "7ca677d6" + "regenerated": "2023-07-11 16:39:23.599213", + "spec_repo_commit": "824086bb" }, "v2": { "apigentools_version": "1.6.5", - "regenerated": "2023-07-11 14:36:43.479079", - "spec_repo_commit": "7ca677d6" + "regenerated": "2023-07-11 16:39:23.611735", + "spec_repo_commit": "824086bb" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index ba7f53a8a08..ee050210f8f 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -2466,6 +2466,38 @@ components: - service - stat type: object + FormulaAndFunctionCloudCostDataSource: + description: Data source for Cloud Cost queries. + enum: + - cloud_cost + example: cloud_cost + type: string + x-enum-varnames: + - CLOUD_COST + FormulaAndFunctionCloudCostQueryDefinition: + description: A formula and functions Cloud Cost query. + example: + data_source: cloud_cost + name: query1 + query: sum:aws.cost.amortized{*} + properties: + aggregator: + $ref: '#/components/schemas/WidgetAggregator' + data_source: + $ref: '#/components/schemas/FormulaAndFunctionCloudCostDataSource' + name: + description: Name of the query for use in formulas. + example: my_query + type: string + query: + description: Query for Cloud Cost data. + example: '' + type: string + required: + - data_source + - query + - name + type: object FormulaAndFunctionEventAggregation: description: Aggregation methods for event platform queries. enum: @@ -2729,6 +2761,7 @@ components: - $ref: '#/components/schemas/FormulaAndFunctionApmDependencyStatsQueryDefinition' - $ref: '#/components/schemas/FormulaAndFunctionApmResourceStatsQueryDefinition' - $ref: '#/components/schemas/FormulaAndFunctionSLOQueryDefinition' + - $ref: '#/components/schemas/FormulaAndFunctionCloudCostQueryDefinition' type: object FormulaAndFunctionResponseFormat: description: Timeseries, scalar, or event list response. Event list response diff --git a/examples/v1/dashboards/CreateDashboard_1284514532.java b/examples/v1/dashboards/CreateDashboard_1284514532.java new file mode 100644 index 00000000000..5b480d685de --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1284514532.java @@ -0,0 +1,82 @@ +// Create a new dashboard with a timeseries widget using formulas and functions cloud cost query + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.DashboardsApi; +import com.datadog.api.client.v1.model.Dashboard; +import com.datadog.api.client.v1.model.DashboardLayoutType; +import com.datadog.api.client.v1.model.FormulaAndFunctionCloudCostDataSource; +import com.datadog.api.client.v1.model.FormulaAndFunctionCloudCostQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat; +import com.datadog.api.client.v1.model.TimeseriesWidgetDefinition; +import com.datadog.api.client.v1.model.TimeseriesWidgetDefinitionType; +import com.datadog.api.client.v1.model.TimeseriesWidgetRequest; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetDefinition; +import com.datadog.api.client.v1.model.WidgetDisplayType; +import com.datadog.api.client.v1.model.WidgetFormula; +import com.datadog.api.client.v1.model.WidgetLineType; +import com.datadog.api.client.v1.model.WidgetLineWidth; +import com.datadog.api.client.v1.model.WidgetRequestStyle; +import com.datadog.api.client.v1.model.WidgetTextAlign; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + Dashboard body = + new Dashboard() + .title("Example-Dashboard") + .widgets( + Collections.singletonList( + new Widget() + .definition( + new WidgetDefinition( + new TimeseriesWidgetDefinition() + .title("Example Cloud Cost Query") + .titleSize("16") + .titleAlign(WidgetTextAlign.LEFT) + .type(TimeseriesWidgetDefinitionType.TIMESERIES) + .requests( + Collections.singletonList( + new TimeseriesWidgetRequest() + .formulas( + Collections.singletonList( + new WidgetFormula().formula("query1"))) + .queries( + Collections.singletonList( + new FormulaAndFunctionQueryDefinition( + new FormulaAndFunctionCloudCostQueryDefinition() + .dataSource( + FormulaAndFunctionCloudCostDataSource + .CLOUD_COST) + .name("query1") + .query( + "sum:aws.cost.amortized{*} by" + + " {aws_product}.rollup(sum," + + " monthly)")))) + .responseFormat( + FormulaAndFunctionResponseFormat.TIMESERIES) + .style( + new WidgetRequestStyle() + .palette("dog_classic") + .lineType(WidgetLineType.SOLID) + .lineWidth(WidgetLineWidth.NORMAL)) + .displayType(WidgetDisplayType.BARS))))))) + .layoutType(DashboardLayoutType.ORDERED); + + try { + Dashboard result = apiInstance.createDashboard(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#createDashboard"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostDataSource.java b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostDataSource.java new file mode 100644 index 00000000000..b3fb1a046e5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostDataSource.java @@ -0,0 +1,61 @@ +/* + * 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; + +/** Data source for Cloud Cost queries. */ +@JsonSerialize( + using = + FormulaAndFunctionCloudCostDataSource.FormulaAndFunctionCloudCostDataSourceSerializer.class) +public class FormulaAndFunctionCloudCostDataSource extends ModelEnum { + + private static final Set allowedValues = new HashSet(Arrays.asList("cloud_cost")); + + public static final FormulaAndFunctionCloudCostDataSource CLOUD_COST = + new FormulaAndFunctionCloudCostDataSource("cloud_cost"); + + FormulaAndFunctionCloudCostDataSource(String value) { + super(value, allowedValues); + } + + public static class FormulaAndFunctionCloudCostDataSourceSerializer + extends StdSerializer { + public FormulaAndFunctionCloudCostDataSourceSerializer( + Class t) { + super(t); + } + + public FormulaAndFunctionCloudCostDataSourceSerializer() { + this(null); + } + + @Override + public void serialize( + FormulaAndFunctionCloudCostDataSource value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FormulaAndFunctionCloudCostDataSource fromValue(String value) { + return new FormulaAndFunctionCloudCostDataSource(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostQueryDefinition.java b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostQueryDefinition.java new file mode 100644 index 00000000000..bbe24340436 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionCloudCostQueryDefinition.java @@ -0,0 +1,243 @@ +/* + * 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.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; + +/** A formula and functions Cloud Cost query. */ +@JsonPropertyOrder({ + FormulaAndFunctionCloudCostQueryDefinition.JSON_PROPERTY_AGGREGATOR, + FormulaAndFunctionCloudCostQueryDefinition.JSON_PROPERTY_DATA_SOURCE, + FormulaAndFunctionCloudCostQueryDefinition.JSON_PROPERTY_NAME, + FormulaAndFunctionCloudCostQueryDefinition.JSON_PROPERTY_QUERY +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FormulaAndFunctionCloudCostQueryDefinition { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_AGGREGATOR = "aggregator"; + private WidgetAggregator aggregator; + + public static final String JSON_PROPERTY_DATA_SOURCE = "data_source"; + private FormulaAndFunctionCloudCostDataSource dataSource; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_QUERY = "query"; + private String query; + + public FormulaAndFunctionCloudCostQueryDefinition() {} + + @JsonCreator + public FormulaAndFunctionCloudCostQueryDefinition( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA_SOURCE) + FormulaAndFunctionCloudCostDataSource dataSource, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_QUERY) String query) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + this.name = name; + this.query = query; + } + + public FormulaAndFunctionCloudCostQueryDefinition aggregator(WidgetAggregator aggregator) { + this.aggregator = aggregator; + this.unparsed |= !aggregator.isValid(); + return this; + } + + /** + * Aggregator used for the request. + * + * @return aggregator + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_AGGREGATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public WidgetAggregator getAggregator() { + return aggregator; + } + + public void setAggregator(WidgetAggregator aggregator) { + if (!aggregator.isValid()) { + this.unparsed = true; + } + this.aggregator = aggregator; + } + + public FormulaAndFunctionCloudCostQueryDefinition dataSource( + FormulaAndFunctionCloudCostDataSource dataSource) { + this.dataSource = dataSource; + this.unparsed |= !dataSource.isValid(); + return this; + } + + /** + * Data source for Cloud Cost queries. + * + * @return dataSource + */ + @JsonProperty(JSON_PROPERTY_DATA_SOURCE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public FormulaAndFunctionCloudCostDataSource getDataSource() { + return dataSource; + } + + public void setDataSource(FormulaAndFunctionCloudCostDataSource dataSource) { + if (!dataSource.isValid()) { + this.unparsed = true; + } + this.dataSource = dataSource; + } + + public FormulaAndFunctionCloudCostQueryDefinition name(String name) { + this.name = name; + return this; + } + + /** + * Name of the query for use in formulas. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public FormulaAndFunctionCloudCostQueryDefinition query(String query) { + this.query = query; + return this; + } + + /** + * Query for Cloud Cost data. + * + * @return query + */ + @JsonProperty(JSON_PROPERTY_QUERY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + /** + * 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 FormulaAndFunctionCloudCostQueryDefinition + */ + @JsonAnySetter + public FormulaAndFunctionCloudCostQueryDefinition 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 FormulaAndFunctionCloudCostQueryDefinition object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormulaAndFunctionCloudCostQueryDefinition formulaAndFunctionCloudCostQueryDefinition = + (FormulaAndFunctionCloudCostQueryDefinition) o; + return Objects.equals(this.aggregator, formulaAndFunctionCloudCostQueryDefinition.aggregator) + && Objects.equals(this.dataSource, formulaAndFunctionCloudCostQueryDefinition.dataSource) + && Objects.equals(this.name, formulaAndFunctionCloudCostQueryDefinition.name) + && Objects.equals(this.query, formulaAndFunctionCloudCostQueryDefinition.query) + && Objects.equals( + this.additionalProperties, + formulaAndFunctionCloudCostQueryDefinition.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(aggregator, dataSource, name, query, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormulaAndFunctionCloudCostQueryDefinition {\n"); + sb.append(" aggregator: ").append(toIndentedString(aggregator)).append("\n"); + sb.append(" dataSource: ").append(toIndentedString(dataSource)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" query: ").append(toIndentedString(query)).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/v1/model/FormulaAndFunctionQueryDefinition.java b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionQueryDefinition.java index 5ea90a94090..2848b8a47c2 100644 --- a/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionQueryDefinition.java +++ b/src/main/java/com/datadog/api/client/v1/model/FormulaAndFunctionQueryDefinition.java @@ -394,6 +394,58 @@ public FormulaAndFunctionQueryDefinition deserialize(JsonParser jp, Deserializat e); } + // deserialize FormulaAndFunctionCloudCostQueryDefinition + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (FormulaAndFunctionCloudCostQueryDefinition.class.equals(Integer.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Long.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Float.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Double.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Boolean.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((FormulaAndFunctionCloudCostQueryDefinition.class.equals(Integer.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((FormulaAndFunctionCloudCostQueryDefinition.class.equals(Float.class) + || FormulaAndFunctionCloudCostQueryDefinition.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (FormulaAndFunctionCloudCostQueryDefinition.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (FormulaAndFunctionCloudCostQueryDefinition.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(FormulaAndFunctionCloudCostQueryDefinition.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 (!((FormulaAndFunctionCloudCostQueryDefinition) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'FormulaAndFunctionCloudCostQueryDefinition'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'FormulaAndFunctionCloudCostQueryDefinition'", + e); + } + FormulaAndFunctionQueryDefinition ret = new FormulaAndFunctionQueryDefinition(); if (match == 1) { ret.setActualInstance(deserialized); @@ -454,6 +506,11 @@ public FormulaAndFunctionQueryDefinition(FormulaAndFunctionSLOQueryDefinition o) setActualInstance(o); } + public FormulaAndFunctionQueryDefinition(FormulaAndFunctionCloudCostQueryDefinition o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + static { schemas.put( "FormulaAndFunctionMetricQueryDefinition", @@ -473,6 +530,9 @@ public FormulaAndFunctionQueryDefinition(FormulaAndFunctionSLOQueryDefinition o) schemas.put( "FormulaAndFunctionSLOQueryDefinition", new GenericType() {}); + schemas.put( + "FormulaAndFunctionCloudCostQueryDefinition", + new GenericType() {}); JSON.registerDescendants( FormulaAndFunctionQueryDefinition.class, Collections.unmodifiableMap(schemas)); } @@ -487,7 +547,8 @@ public Map getSchemas() { * against the oneOf child schemas: FormulaAndFunctionMetricQueryDefinition, * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionProcessQueryDefinition, * FormulaAndFunctionApmDependencyStatsQueryDefinition, - * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition + * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition, + * FormulaAndFunctionCloudCostQueryDefinition * *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a * composed schema (allOf, anyOf, oneOf). @@ -528,6 +589,11 @@ public void setActualInstance(Object instance) { super.setActualInstance(instance); return; } + if (JSON.isInstanceOf( + FormulaAndFunctionCloudCostQueryDefinition.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { super.setActualInstance(instance); @@ -538,19 +604,21 @@ public void setActualInstance(Object instance) { + " FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionProcessQueryDefinition," + " FormulaAndFunctionApmDependencyStatsQueryDefinition," + " FormulaAndFunctionApmResourceStatsQueryDefinition," - + " FormulaAndFunctionSLOQueryDefinition"); + + " FormulaAndFunctionSLOQueryDefinition, FormulaAndFunctionCloudCostQueryDefinition"); } /** * Get the actual instance, which can be the following: FormulaAndFunctionMetricQueryDefinition, * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionProcessQueryDefinition, * FormulaAndFunctionApmDependencyStatsQueryDefinition, - * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition + * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition, + * FormulaAndFunctionCloudCostQueryDefinition * * @return The actual instance (FormulaAndFunctionMetricQueryDefinition, * FormulaAndFunctionEventQueryDefinition, FormulaAndFunctionProcessQueryDefinition, * FormulaAndFunctionApmDependencyStatsQueryDefinition, - * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition) + * FormulaAndFunctionApmResourceStatsQueryDefinition, FormulaAndFunctionSLOQueryDefinition, + * FormulaAndFunctionCloudCostQueryDefinition) */ @Override public Object getActualInstance() { @@ -632,4 +700,16 @@ public FormulaAndFunctionSLOQueryDefinition getFormulaAndFunctionSLOQueryDefinit throws ClassCastException { return (FormulaAndFunctionSLOQueryDefinition) super.getActualInstance(); } + + /** + * Get the actual instance of `FormulaAndFunctionCloudCostQueryDefinition`. If the actual instance + * is not `FormulaAndFunctionCloudCostQueryDefinition`, the ClassCastException will be thrown. + * + * @return The actual instance of `FormulaAndFunctionCloudCostQueryDefinition` + * @throws ClassCastException if the instance is not `FormulaAndFunctionCloudCostQueryDefinition` + */ + public FormulaAndFunctionCloudCostQueryDefinition getFormulaAndFunctionCloudCostQueryDefinition() + throws ClassCastException { + return (FormulaAndFunctionCloudCostQueryDefinition) super.getActualInstance(); + } } diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.freeze new file mode 100644 index 00000000000..c799f9c5fa0 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.freeze @@ -0,0 +1 @@ +2023-07-11T14:32:45.409Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.json new file mode 100644 index 00000000000..0be8b4101e4 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1689085965\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"}}]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"kka-2iz-3jf\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1689085965\",\"description\":null,\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/kka-2iz-3jf/test-createanewdashboardwithatimeserieswidgetusingformulasandfunctionscloudcostq\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"bars\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"cloud_cost\",\"name\":\"query1\",\"query\":\"sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)\"}],\"response_format\":\"timeseries\",\"style\":{\"line_type\":\"solid\",\"line_width\":\"normal\",\"palette\":\"dog_classic\"}}],\"title\":\"Example Cloud Cost Query\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"timeseries\"},\"id\":1004255439340}],\"notify_list\":null,\"created_at\":\"2023-07-11T14:32:45.564617+00:00\",\"modified_at\":\"2023-07-11T14:32:45.564617+00:00\",\"restricted_roles\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "21554e3c-bbf5-1a3f-13fd-398b7622a007" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/dashboard/kka-2iz-3jf", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"kka-2iz-3jf\"}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7c80e62c-3821-49b2-a53a-fcb41ec2fea8" + } +] \ No newline at end of file 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 130f0d04093..cec23fc40ca 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 @@ -159,6 +159,18 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].response_format" is equal to "scalar" And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "sum:my.cool.count.metric{*}" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with a timeseries widget using formulas and functions cloud cost query + Given new "CreateDashboard" request + And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ] } } ], "layout_type": "ordered" } + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].response_format" is equal to "timeseries" + And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "cloud_cost" + And the response "widgets[0].definition.requests[0].queries[0].name" is equal to "query1" + And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" + And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with alert_graph widget Given there is a valid "monitor" in the system