diff --git a/.apigentools-info b/.apigentools-info index 8c8b1f2b9a7..271e4f3df6e 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-11-12 11:37:10.876032", - "spec_repo_commit": "fabbc01" + "regenerated": "2021-11-12 15:05:10.211771", + "spec_repo_commit": "c588c56" }, "v2": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-11-12 11:37:10.908515", - "spec_repo_commit": "fabbc01" + "regenerated": "2021-11-12 15:05:10.240638", + "spec_repo_commit": "c588c56" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 37a3d7cad3b..e77cd85d4c5 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -736,6 +736,12 @@ components: $ref: '#/components/schemas/WidgetCompareTo' event_query: $ref: '#/components/schemas/LogQueryDefinition' + formulas: + description: List of formulas that operate on queries. **This feature is + currently in beta.** + items: + $ref: '#/components/schemas/WidgetFormula' + type: array increase_good: description: Whether to show increase as good. type: boolean @@ -754,6 +760,14 @@ components: q: description: Query definition. 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' rum_query: $ref: '#/components/schemas/LogQueryDefinition' security_query: diff --git a/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/frozen.json b/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/frozen.json new file mode 100644 index 00000000000..18b3e32cf26 --- /dev/null +++ b/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/frozen.json @@ -0,0 +1 @@ +"2021-11-12T15:01:21.644Z" diff --git a/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/recording.har b/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/recording.har new file mode 100644 index 00000000000..9939c24d5f3 --- /dev/null +++ b/cassettes/v1/Dashboards_1335235736/Create-a-new-dashboard-with-a-formulas-and-functions-change-widget_2972377494/recording.har @@ -0,0 +1,269 @@ +{ + "log": { + "_recordingName": "Dashboards/Create a new dashboard with a formulas and functions change widget", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.1.0" + }, + "entries": [ + { + "_id": "82255a04cc78dc098057203ae783c46b", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 626, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "user-agent", + "value": "datadog-api-client-typescript/1.0.0-beta.6 (node 14.18.1; os Linux; arch x64)" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json, */*;q=0.8" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "x-datadog-parent-id", + "value": "8731715351358858124" + }, + { + "_fromType": "array", + "name": "x-datadog-trace-id", + "value": "5873467306450681742" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "626" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "api.datadoghq.com" + } + ], + "headersSize": 476, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_a_formulas_and_functions_change_widget-1636729281\",\"widgets\":[{\"definition\":{\"requests\":[{\"change_type\":\"absolute\",\"compare_to\":\"hour_before\",\"formulas\":[{\"formula\":\"hour_before(query1)\"},{\"formula\":\"query1\"}],\"increase_good\":true,\"order_by\":\"change\",\"order_dir\":\"desc\",\"queries\":[{\"compute\":{\"aggregation\":\"count\"},\"data_source\":\"logs\",\"group_by\":[],\"indexes\":[\"*\"],\"name\":\"query1\",\"search\":{\"query\":\"\"}}],\"response_format\":\"scalar\"}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"change\"},\"layout\":{\"height\":4,\"width\":4,\"x\":0,\"y\":0}}]}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v1/dashboard" + }, + "response": { + "bodySize": 1031, + "content": { + "mimeType": "application/json", + "size": 1031, + "text": "{\"notify_list\":null,\"description\":null,\"restricted_roles\":[],\"author_name\":null,\"template_variables\":null,\"is_read_only\":false,\"id\":\"dwk-ej2-e2f\",\"title\":\"Test-Create_a_new_dashboard_with_a_formulas_and_functions_change_widget-1636729281\",\"url\":\"/dashboard/dwk-ej2-e2f/test-createanewdashboardwithaformulasandfunctionschangewidget-1636729281\",\"created_at\":\"2021-11-12T15:01:21.989698+00:00\",\"modified_at\":\"2021-11-12T15:01:21.989698+00:00\",\"author_handle\":\"frog@datadoghq.com\",\"widgets\":[{\"definition\":{\"title_size\":\"16\",\"title\":\"\",\"title_align\":\"left\",\"time\":{},\"requests\":[{\"formulas\":[{\"formula\":\"hour_before(query1)\"},{\"formula\":\"query1\"}],\"order_by\":\"change\",\"order_dir\":\"desc\",\"compare_to\":\"hour_before\",\"response_format\":\"scalar\",\"increase_good\":true,\"queries\":[{\"search\":{\"query\":\"\"},\"data_source\":\"logs\",\"compute\":{\"aggregation\":\"count\"},\"name\":\"query1\",\"indexes\":[\"*\"],\"group_by\":[]}],\"change_type\":\"absolute\"}],\"type\":\"change\"},\"layout\":{\"y\":0,\"width\":4,\"x\":0,\"height\":4},\"id\":1892792703041590}],\"layout_type\":\"ordered\"}" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Fri, 12 Nov 2021 15:01:22 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": "1031" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "cache-control", + "value": "no-cache" + }, + { + "name": "x-envoy-upstream-service-time", + "value": "326" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800;" + }, + { + "name": "content-security-policy", + "value": "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + } + ], + "headersSize": 420, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2021-11-12T15:01:21.668Z", + "time": 365, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 365 + } + }, + { + "_id": "c2474a11dcdebd269c3d458c798513b8", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 0, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "user-agent", + "value": "datadog-api-client-typescript/1.0.0-beta.6 (node 14.18.1; os Linux; arch x64)" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json, */*;q=0.8" + }, + { + "_fromType": "array", + "name": "x-datadog-parent-id", + "value": "1167209965635326775" + }, + { + "_fromType": "array", + "name": "x-datadog-trace-id", + "value": "5873467306450681742" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "api.datadoghq.com" + } + ], + "headersSize": 437, + "httpVersion": "HTTP/1.1", + "method": "DELETE", + "queryString": [], + "url": "https://api.datadoghq.com/api/v1/dashboard/dwk-ej2-e2f" + }, + "response": { + "bodySize": 38, + "content": { + "mimeType": "application/json", + "size": 38, + "text": "{\"deleted_dashboard_id\":\"dwk-ej2-e2f\"}" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Fri, 12 Nov 2021 15:01:22 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": "38" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "cache-control", + "value": "no-cache" + }, + { + "name": "x-envoy-upstream-service-time", + "value": "298" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800;" + }, + { + "name": "content-security-policy", + "value": "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + } + ], + "headersSize": 418, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2021-11-12T15:01:22.053Z", + "time": 361, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 361 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/features/v1/dashboards.feature b/features/v1/dashboards.feature index 343d02bd50d..758edb2a030 100644 --- a/features/v1/dashboards.feature +++ b/features/v1/dashboards.feature @@ -23,6 +23,23 @@ Feature: Dashboards When the request is sent Then the response status is 200 OK + Scenario: Create a new dashboard with a formulas and functions change widget + Given new "CreateDashboard" request + And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "", "title_size": "16", "title_align": "left", "time": {}, "type": "change", "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", "compare_to": "hour_before", "increase_good": true, "order_by": "change", "change_type": "absolute", "order_dir": "desc" } ] }, "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].compare_to" is equal to "hour_before" + And the response "widgets[0].definition.requests[0].increase_good" is equal to true + And the response "widgets[0].definition.requests[0].order_by" is equal to "change" + And the response "widgets[0].definition.requests[0].change_type" is equal to "absolute" + And the response "widgets[0].definition.requests[0].order_dir" is equal to "desc" + 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" + Scenario: Create a new dashboard with a profile metric query Given new "CreateDashboard" request And body from file "dashboard_payload.json" diff --git a/packages/datadog-api-client-v1/models/ChangeWidgetRequest.ts b/packages/datadog-api-client-v1/models/ChangeWidgetRequest.ts index 8b8df9910f8..79250b29e85 100644 --- a/packages/datadog-api-client-v1/models/ChangeWidgetRequest.ts +++ b/packages/datadog-api-client-v1/models/ChangeWidgetRequest.ts @@ -8,10 +8,13 @@ * Do not edit the class manually. */ +import { FormulaAndFunctionQueryDefinition } from "./FormulaAndFunctionQueryDefinition"; +import { FormulaAndFunctionResponseFormat } from "./FormulaAndFunctionResponseFormat"; import { LogQueryDefinition } from "./LogQueryDefinition"; import { ProcessQueryDefinition } from "./ProcessQueryDefinition"; import { WidgetChangeType } from "./WidgetChangeType"; import { WidgetCompareTo } from "./WidgetCompareTo"; +import { WidgetFormula } from "./WidgetFormula"; import { WidgetOrderBy } from "./WidgetOrderBy"; import { WidgetSort } from "./WidgetSort"; @@ -20,6 +23,10 @@ export class ChangeWidgetRequest { "changeType"?: WidgetChangeType; "compareTo"?: WidgetCompareTo; "eventQuery"?: LogQueryDefinition; + /** + * List of formulas that operate on queries. **This feature is currently in beta.** + */ + "formulas"?: Array; /** * Whether to show increase as good. */ @@ -34,6 +41,11 @@ export class ChangeWidgetRequest { * Query definition. */ "q"?: string; + /** + * List of queries that can be returned directly or used in formulas. **This feature is currently in beta.** + */ + "queries"?: Array; + "responseFormat"?: FormulaAndFunctionResponseFormat; "rumQuery"?: LogQueryDefinition; "securityQuery"?: LogQueryDefinition; /** @@ -67,6 +79,10 @@ export class ChangeWidgetRequest { baseName: "event_query", type: "LogQueryDefinition", }, + formulas: { + baseName: "formulas", + type: "Array", + }, increaseGood: { baseName: "increase_good", type: "boolean", @@ -99,6 +115,14 @@ export class ChangeWidgetRequest { baseName: "q", type: "string", }, + queries: { + baseName: "queries", + type: "Array", + }, + responseFormat: { + baseName: "response_format", + type: "FormulaAndFunctionResponseFormat", + }, rumQuery: { baseName: "rum_query", type: "LogQueryDefinition",