diff --git a/.apigentools-info b/.apigentools-info index 8e4d57eb69c..c0748727378 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2022-01-12 15:42:19.405514", - "spec_repo_commit": "9a4c69f" + "regenerated": "2022-01-12 16:36:59.841666", + "spec_repo_commit": "9f3c740" }, "v2": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2022-01-12 15:42:20.247481", - "spec_repo_commit": "9a4c69f" + "regenerated": "2022-01-12 16:37:00.753203", + "spec_repo_commit": "9f3c740" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e27bebef834..916739bf5e4 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -12260,9 +12260,6 @@ components: required: - type - requests - - size_by - - color_by - - group_by type: object TreeMapWidgetDefinitionType: default: treemap @@ -12276,9 +12273,23 @@ components: TreeMapWidgetRequest: description: An updated treemap widget. properties: + formulas: + description: List of formulas that operate on queries. **This feature is + currently in beta.** + items: + $ref: '#/components/schemas/WidgetFormula' + type: array q: description: The widget metrics query. type: string + queries: + description: List of queries that can be returned directly or used in formulas. + **This feature is currently in beta.** + items: + $ref: '#/components/schemas/FormulaAndFunctionQueryDefinition' + type: array + response_format: + $ref: '#/components/schemas/FormulaAndFunctionResponseFormat' type: object UsageAnalyzedLogsHour: description: The number of analyzed logs for each hour for a given organization. diff --git a/api_docs/v1/TreeMapWidgetDefinition.md b/api_docs/v1/TreeMapWidgetDefinition.md index 63104a1a81b..97390110eb1 100644 --- a/api_docs/v1/TreeMapWidgetDefinition.md +++ b/api_docs/v1/TreeMapWidgetDefinition.md @@ -6,9 +6,9 @@ The treemap visualization found on the Host Dashboards comes from the output of | Name | Type | Description | Notes | | ------------ | --------------------------------------------------------------- | --------------------------------- | ---------- | -| **colorBy** | **TreeMapColorBy** | | -| **groupBy** | **TreeMapGroupBy** | | +| **colorBy** | **TreeMapColorBy** | | [optional] | +| **groupBy** | **TreeMapGroupBy** | | [optional] | | **requests** | [**List<TreeMapWidgetRequest>**](TreeMapWidgetRequest.md) | List of top list widget requests. | -| **sizeBy** | **TreeMapSizeBy** | | +| **sizeBy** | **TreeMapSizeBy** | | [optional] | | **title** | **String** | Title of your widget. | [optional] | | **type** | **TreeMapWidgetDefinitionType** | | diff --git a/api_docs/v1/TreeMapWidgetRequest.md b/api_docs/v1/TreeMapWidgetRequest.md index cf8649dc36e..147a86f2366 100644 --- a/api_docs/v1/TreeMapWidgetRequest.md +++ b/api_docs/v1/TreeMapWidgetRequest.md @@ -4,6 +4,9 @@ An updated treemap widget. ## Properties -| Name | Type | Description | Notes | -| ----- | ---------- | ------------------------- | ---------- | -| **q** | **String** | The widget metrics query. | [optional] | +| Name | Type | Description | Notes | +| ------------------ | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------- | +| **formulas** | [**List<WidgetFormula>**](WidgetFormula.md) | List of formulas that operate on queries. **This feature is currently in beta.** | [optional] | +| **q** | **String** | The widget metrics query. | [optional] | +| **queries** | [**List<FormulaAndFunctionQueryDefinition>**](FormulaAndFunctionQueryDefinition.md) | List of queries that can be returned directly or used in formulas. **This feature is currently in beta.** | [optional] | +| **responseFormat** | **FormulaAndFunctionResponseFormat** | | [optional] | diff --git a/examples/v1/dashboards/CreateDashboard_1024858348.java b/examples/v1/dashboards/CreateDashboard_1024858348.java new file mode 100644 index 00000000000..b55aa4633d2 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1024858348.java @@ -0,0 +1,118 @@ +// Create a new dashboard with a formulas and functions treemap widget + +import com.datadog.api.v1.client.ApiClient; +import com.datadog.api.v1.client.ApiException; +import com.datadog.api.v1.client.Configuration; +import com.datadog.api.v1.client.api.DashboardsApi; +import com.datadog.api.v1.client.model.Dashboard; +import com.datadog.api.v1.client.model.DashboardLayoutType; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventAggregation; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinition; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinitionCompute; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryDefinitionSearch; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventQueryGroupBy; +import com.datadog.api.v1.client.model.FormulaAndFunctionEventsDataSource; +import com.datadog.api.v1.client.model.FormulaAndFunctionQueryDefinition; +import com.datadog.api.v1.client.model.FormulaAndFunctionResponseFormat; +import com.datadog.api.v1.client.model.TreeMapWidgetDefinition; +import com.datadog.api.v1.client.model.TreeMapWidgetDefinitionType; +import com.datadog.api.v1.client.model.TreeMapWidgetRequest; +import com.datadog.api.v1.client.model.Widget; +import com.datadog.api.v1.client.model.WidgetDefinition; +import com.datadog.api.v1.client.model.WidgetFormula; +import com.datadog.api.v1.client.model.WidgetLayout; +import java.time.*; +import java.util.*; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + Dashboard body = + new Dashboard() + .title("Example-Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget") + .widgets( + new ArrayList() { + { + add( + new Widget() + .definition( + new WidgetDefinition( + new TreeMapWidgetDefinition() + .title("") + .type(TreeMapWidgetDefinitionType.TREEMAP) + .requests( + new ArrayList() { + { + add( + new TreeMapWidgetRequest() + .formulas( + new ArrayList() { + { + add( + new WidgetFormula() + .formula( + "hour_before(query1)")); + add( + new WidgetFormula() + .formula("query1")); + } + }) + .queries( + new ArrayList< + FormulaAndFunctionQueryDefinition>() { + { + add( + new FormulaAndFunctionQueryDefinition( + new FormulaAndFunctionEventQueryDefinition() + .dataSource( + FormulaAndFunctionEventsDataSource + .LOGS) + .name("query1") + .search( + new FormulaAndFunctionEventQueryDefinitionSearch() + .query("")) + .indexes( + new ArrayList< + String>() { + { + add("*"); + } + }) + .compute( + new FormulaAndFunctionEventQueryDefinitionCompute() + .aggregation( + FormulaAndFunctionEventAggregation + .COUNT)) + .groupBy( + new ArrayList< + FormulaAndFunctionEventQueryGroupBy>() { + { + ; + } + }))); + } + }) + .responseFormat( + FormulaAndFunctionResponseFormat + .SCALAR)); + } + }))) + .layout(new WidgetLayout().x(0L).y(0L).width(4L).height(4L))); + } + }) + .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/v1/client/model/TreeMapWidgetDefinition.java b/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetDefinition.java index a2116271af1..9813740b0a9 100644 --- a/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetDefinition.java +++ b/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetDefinition.java @@ -66,19 +66,10 @@ public TreeMapWidgetDefinition() {} @JsonCreator public TreeMapWidgetDefinition( - @JsonProperty(required = true, value = JSON_PROPERTY_COLOR_BY) TreeMapColorBy colorBy, - @JsonProperty(required = true, value = JSON_PROPERTY_GROUP_BY) TreeMapGroupBy groupBy, @JsonProperty(required = true, value = JSON_PROPERTY_REQUESTS) List requests, - @JsonProperty(required = true, value = JSON_PROPERTY_SIZE_BY) TreeMapSizeBy sizeBy, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TreeMapWidgetDefinitionType type) { - this.colorBy = colorBy; - this.unparsed |= !colorBy.isValid(); - this.groupBy = groupBy; - this.unparsed |= !groupBy.isValid(); this.requests = requests; - this.sizeBy = sizeBy; - this.unparsed |= !sizeBy.isValid(); this.type = type; this.unparsed |= !type.isValid(); } @@ -94,9 +85,10 @@ public TreeMapWidgetDefinition colorBy(TreeMapColorBy colorBy) { * * @return colorBy */ - @ApiModelProperty(required = true, value = "") + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_COLOR_BY) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TreeMapColorBy getColorBy() { return colorBy; } @@ -119,9 +111,10 @@ public TreeMapWidgetDefinition groupBy(TreeMapGroupBy groupBy) { * * @return groupBy */ - @ApiModelProperty(required = true, value = "") + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_GROUP_BY) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TreeMapGroupBy getGroupBy() { return groupBy; } @@ -177,9 +170,10 @@ public TreeMapWidgetDefinition sizeBy(TreeMapSizeBy sizeBy) { * * @return sizeBy */ - @ApiModelProperty(required = true, value = "") + @javax.annotation.Nullable + @ApiModelProperty(value = "") @JsonProperty(JSON_PROPERTY_SIZE_BY) - @JsonInclude(value = JsonInclude.Include.ALWAYS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) public TreeMapSizeBy getSizeBy() { return sizeBy; } diff --git a/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetRequest.java b/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetRequest.java index 279ee87bacc..de1e51aa809 100644 --- a/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetRequest.java +++ b/src/main/java/com/datadog/api/v1/client/model/TreeMapWidgetRequest.java @@ -16,17 +16,68 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; /** An updated treemap widget. */ @ApiModel(description = "An updated treemap widget.") -@JsonPropertyOrder({TreeMapWidgetRequest.JSON_PROPERTY_Q}) +@JsonPropertyOrder({ + TreeMapWidgetRequest.JSON_PROPERTY_FORMULAS, + TreeMapWidgetRequest.JSON_PROPERTY_Q, + TreeMapWidgetRequest.JSON_PROPERTY_QUERIES, + TreeMapWidgetRequest.JSON_PROPERTY_RESPONSE_FORMAT +}) @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class TreeMapWidgetRequest { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_FORMULAS = "formulas"; + private List formulas = null; + public static final String JSON_PROPERTY_Q = "q"; private String q; + public static final String JSON_PROPERTY_QUERIES = "queries"; + private List queries = null; + + public static final String JSON_PROPERTY_RESPONSE_FORMAT = "response_format"; + private FormulaAndFunctionResponseFormat responseFormat; + + public TreeMapWidgetRequest formulas(List formulas) { + this.formulas = formulas; + for (WidgetFormula item : formulas) { + this.unparsed |= item.unparsed; + } + return this; + } + + public TreeMapWidgetRequest addFormulasItem(WidgetFormula formulasItem) { + if (this.formulas == null) { + this.formulas = new ArrayList<>(); + } + this.formulas.add(formulasItem); + this.unparsed |= formulasItem.unparsed; + return this; + } + + /** + * List of formulas that operate on queries. **This feature is currently in beta.** + * + * @return formulas + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of formulas that operate on queries. **This feature is currently in beta.**") + @JsonProperty(JSON_PROPERTY_FORMULAS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getFormulas() { + return formulas; + } + + public void setFormulas(List formulas) { + this.formulas = formulas; + } + public TreeMapWidgetRequest q(String q) { this.q = q; return this; @@ -49,6 +100,70 @@ public void setQ(String q) { this.q = q; } + public TreeMapWidgetRequest queries(List queries) { + this.queries = queries; + for (FormulaAndFunctionQueryDefinition item : queries) { + this.unparsed |= item.unparsed; + } + return this; + } + + public TreeMapWidgetRequest addQueriesItem(FormulaAndFunctionQueryDefinition queriesItem) { + if (this.queries == null) { + this.queries = new ArrayList<>(); + } + this.queries.add(queriesItem); + this.unparsed |= queriesItem.unparsed; + return this; + } + + /** + * List of queries that can be returned directly or used in formulas. **This feature is currently + * in beta.** + * + * @return queries + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = + "List of queries that can be returned directly or used in formulas. **This feature is" + + " currently in beta.**") + @JsonProperty(JSON_PROPERTY_QUERIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getQueries() { + return queries; + } + + public void setQueries(List queries) { + this.queries = queries; + } + + public TreeMapWidgetRequest responseFormat(FormulaAndFunctionResponseFormat responseFormat) { + this.responseFormat = responseFormat; + this.unparsed |= !responseFormat.isValid(); + return this; + } + + /** + * Get responseFormat + * + * @return responseFormat + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + @JsonProperty(JSON_PROPERTY_RESPONSE_FORMAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FormulaAndFunctionResponseFormat getResponseFormat() { + return responseFormat; + } + + public void setResponseFormat(FormulaAndFunctionResponseFormat responseFormat) { + if (!responseFormat.isValid()) { + this.unparsed = true; + } + this.responseFormat = responseFormat; + } + /** Return true if this TreeMapWidgetRequest object is equal to o. */ @Override public boolean equals(Object o) { @@ -59,19 +174,25 @@ public boolean equals(Object o) { return false; } TreeMapWidgetRequest treeMapWidgetRequest = (TreeMapWidgetRequest) o; - return Objects.equals(this.q, treeMapWidgetRequest.q); + return Objects.equals(this.formulas, treeMapWidgetRequest.formulas) + && Objects.equals(this.q, treeMapWidgetRequest.q) + && Objects.equals(this.queries, treeMapWidgetRequest.queries) + && Objects.equals(this.responseFormat, treeMapWidgetRequest.responseFormat); } @Override public int hashCode() { - return Objects.hash(q); + return Objects.hash(formulas, q, queries, responseFormat); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class TreeMapWidgetRequest {\n"); + sb.append(" formulas: ").append(toIndentedString(formulas)).append("\n"); sb.append(" q: ").append(toIndentedString(q)).append("\n"); + sb.append(" queries: ").append(toIndentedString(queries)).append("\n"); + sb.append(" responseFormat: ").append(toIndentedString(responseFormat)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.freeze new file mode 100644 index 00000000000..0aaf970adf5 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.freeze @@ -0,0 +1 @@ +2022-01-12T10:11:31.394Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.json new file mode 100644 index 00000000000..a66e1715a2e --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget.json @@ -0,0 +1,66 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget-1641982291\",\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"hour_before(query1)\"},{\"formula\":\"query1\"}],\"queries\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"logs\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"\"}}],\"response_format\":\"scalar\"}],\"title\":\"\",\"type\":\"treemap\"},\"layout\":{\"height\":4,\"width\":4,\"x\":0,\"y\":0}}]}" + }, + "headers": { + "JAVA-TEST-NAME": [ + "Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget" + ] + }, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"notify_list\":null,\"description\":null,\"restricted_roles\":[],\"author_name\":null,\"template_variables\":null,\"is_read_only\":false,\"id\":\"2ar-acj-hxc\",\"title\":\"Test-Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget-1641982291\",\"url\":\"/dashboard/2ar-acj-hxc/test-createanewdashboardwithaformulasandfunctionstreemapwidget-1641982291\",\"created_at\":\"2022-01-12T10:11:31.601485+00:00\",\"modified_at\":\"2022-01-12T10:11:31.601485+00:00\",\"author_handle\":\"frog@datadoghq.com\",\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"hour_before(query1)\"},{\"formula\":\"query1\"}],\"response_format\":\"scalar\",\"queries\":[{\"search\":{\"query\":\"\"},\"data_source\":\"logs\",\"compute\":{\"aggregation\":\"count\"},\"name\":\"query1\",\"indexes\":[\"*\"],\"group_by\":[]}]}],\"type\":\"treemap\",\"title\":\"\"},\"layout\":{\"y\":0,\"width\":4,\"x\":0,\"height\":4},\"id\":2836171994664464}],\"layout_type\":\"ordered\"}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "14594ccf-095d-aa90-9689-69cdd40b4adb" + }, + { + "httpRequest": { + "headers": { + "JAVA-TEST-NAME": [ + "Create_a_new_dashboard_with_a_formulas_and_functions_treemap_widget" + ] + }, + "method": "DELETE", + "path": "/api/v1/dashboard/2ar-acj-hxc", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"2ar-acj-hxc\"}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "657dda1a-8731-f849-1b14-3842fe7d0347" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/v1/client/api/dashboards.feature b/src/test/resources/com/datadog/api/v1/client/api/dashboards.feature index d4257e7238a..e1c14adc9fe 100644 --- a/src/test/resources/com/datadog/api/v1/client/api/dashboards.feature +++ b/src/test/resources/com/datadog/api/v1/client/api/dashboards.feature @@ -41,6 +41,19 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)" And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1" + @team:DataDog/dashboards + Scenario: Create a new dashboard with a formulas and functions treemap widget + Given new "CreateDashboard" request + And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "", "type": "treemap", "requests": [ { "formulas": [ { "formula": "hour_before(query1)" }, { "formula": "query1" } ], "queries": [ { "data_source": "logs", "name": "query1", "search": { "query": "" }, "indexes": [ "*" ], "compute": { "aggregation": "count" }, "group_by": [] } ], "response_format": "scalar" } ] }, "layout": { "x": 0, "y": 0, "width": 4, "height": 4 } } ], "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 "scalar" + And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "logs" + 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].compute.aggregation" is equal to "count" + And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "hour_before(query1)" + And the response "widgets[0].definition.requests[0].formulas[1].formula" is equal to "query1" + @team:DataDog/dashboards Scenario: Create a new dashboard with a query value widget using the percentile aggregator Given new "CreateDashboard" request