diff --git a/.apigentools-info b/.apigentools-info index de2b4da3e55..7c04583f81c 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-24 16:41:55.959055", - "spec_repo_commit": "9bdb5ee6" + "regenerated": "2023-03-27 19:48:20.211619", + "spec_repo_commit": "b6741167" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-03-24 16:41:55.974878", - "spec_repo_commit": "9bdb5ee6" + "regenerated": "2023-03-27 19:48:20.224682", + "spec_repo_commit": "b6741167" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e028210fe1f..8207e424a0a 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1006,6 +1006,14 @@ components: description: A role UUID. type: string type: array + tags: + description: List of team names representing ownership of a dashboard. + items: + description: The name of a Datadog team of the form `team:` + type: string + maxItems: 5 + nullable: true + type: array template_variable_presets: description: Array of template variables saved views. items: diff --git a/examples/v1/dashboards/CreateDashboard_2064651578.java b/examples/v1/dashboards/CreateDashboard_2064651578.java new file mode 100644 index 00000000000..a48eb8f7826 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_2064651578.java @@ -0,0 +1,98 @@ +// Create a new dashboard with team tags returns "OK" response + +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.ChangeWidgetDefinition; +import com.datadog.api.client.v1.model.ChangeWidgetDefinitionType; +import com.datadog.api.client.v1.model.ChangeWidgetRequest; +import com.datadog.api.client.v1.model.Dashboard; +import com.datadog.api.client.v1.model.DashboardLayoutType; +import com.datadog.api.client.v1.model.FormulaAndFunctionEventAggregation; +import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinitionCompute; +import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinitionSearch; +import com.datadog.api.client.v1.model.FormulaAndFunctionEventsDataSource; +import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition; +import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetChangeType; +import com.datadog.api.client.v1.model.WidgetCompareTo; +import com.datadog.api.client.v1.model.WidgetDefinition; +import com.datadog.api.client.v1.model.WidgetFormula; +import com.datadog.api.client.v1.model.WidgetLayout; +import com.datadog.api.client.v1.model.WidgetOrderBy; +import com.datadog.api.client.v1.model.WidgetSort; +import com.datadog.api.client.v1.model.WidgetTextAlign; +import com.datadog.api.client.v1.model.WidgetTime; +import java.util.Arrays; +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-Create_a_new_dashboard_with_team_tags_returns_OK_response") + .widgets( + Collections.singletonList( + new Widget() + .definition( + new WidgetDefinition( + new ChangeWidgetDefinition() + .title("") + .titleSize("16") + .titleAlign(WidgetTextAlign.LEFT) + .time(new WidgetTime()) + .type(ChangeWidgetDefinitionType.CHANGE) + .requests( + Collections.singletonList( + new ChangeWidgetRequest() + .formulas( + Arrays.asList( + new WidgetFormula() + .formula("hour_before(query1)"), + new WidgetFormula().formula("query1"))) + .queries( + Collections.singletonList( + new FormulaAndFunctionQueryDefinition( + new FormulaAndFunctionEventQueryDefinition() + .dataSource( + FormulaAndFunctionEventsDataSource + .LOGS) + .name("query1") + .search( + new FormulaAndFunctionEventQueryDefinitionSearch() + .query("")) + .indexes( + Collections.singletonList("*")) + .compute( + new FormulaAndFunctionEventQueryDefinitionCompute() + .aggregation( + FormulaAndFunctionEventAggregation + .COUNT))))) + .responseFormat( + FormulaAndFunctionResponseFormat.SCALAR) + .compareTo(WidgetCompareTo.HOUR_BEFORE) + .increaseGood(true) + .orderBy(WidgetOrderBy.CHANGE) + .changeType(WidgetChangeType.ABSOLUTE) + .orderDir(WidgetSort.DESCENDING))))) + .layout(new WidgetLayout().x(0L).y(0L).width(4L).height(4L)))) + .tags(Collections.singletonList("team:foobar")) + .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/examples/v1/dashboards/UpdateDashboard_3454865944.java b/examples/v1/dashboards/UpdateDashboard_3454865944.java new file mode 100644 index 00000000000..ef139a06819 --- /dev/null +++ b/examples/v1/dashboards/UpdateDashboard_3454865944.java @@ -0,0 +1,70 @@ +// Update a dashboard with tags returns "OK" response + +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.ListStreamColumn; +import com.datadog.api.client.v1.model.ListStreamColumnWidth; +import com.datadog.api.client.v1.model.ListStreamQuery; +import com.datadog.api.client.v1.model.ListStreamResponseFormat; +import com.datadog.api.client.v1.model.ListStreamSource; +import com.datadog.api.client.v1.model.ListStreamWidgetDefinition; +import com.datadog.api.client.v1.model.ListStreamWidgetDefinitionType; +import com.datadog.api.client.v1.model.ListStreamWidgetRequest; +import com.datadog.api.client.v1.model.Widget; +import com.datadog.api.client.v1.model.WidgetDefinition; +import java.util.Arrays; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + DashboardsApi apiInstance = new DashboardsApi(defaultClient); + + // there is a valid "dashboard" in the system + String DASHBOARD_ID = System.getenv("DASHBOARD_ID"); + + Dashboard body = + new Dashboard() + .layoutType(DashboardLayoutType.ORDERED) + .title( + "Example-Update_a_dashboard_with_tags_returns_OK_response with list_stream widget") + .description("Updated description") + .tags(Arrays.asList("team:foo", "team:bar")) + .widgets( + Collections.singletonList( + new Widget() + .definition( + new WidgetDefinition( + new ListStreamWidgetDefinition() + .type(ListStreamWidgetDefinitionType.LIST_STREAM) + .requests( + Collections.singletonList( + new ListStreamWidgetRequest() + .columns( + Collections.singletonList( + new ListStreamColumn() + .width(ListStreamColumnWidth.AUTO) + .field("timestamp"))) + .query( + new ListStreamQuery() + .dataSource( + ListStreamSource.APM_ISSUE_STREAM) + .queryString("")) + .responseFormat( + ListStreamResponseFormat.EVENT_LIST))))))); + + try { + Dashboard result = apiInstance.updateDashboard(DASHBOARD_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DashboardsApi#updateDashboard"); + 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/Dashboard.java b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java index f5b454029dd..173735a4c0b 100644 --- a/src/main/java/com/datadog/api/client/v1/model/Dashboard.java +++ b/src/main/java/com/datadog/api/client/v1/model/Dashboard.java @@ -35,6 +35,7 @@ Dashboard.JSON_PROPERTY_NOTIFY_LIST, Dashboard.JSON_PROPERTY_REFLOW_TYPE, Dashboard.JSON_PROPERTY_RESTRICTED_ROLES, + Dashboard.JSON_PROPERTY_TAGS, Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS, Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLES, Dashboard.JSON_PROPERTY_TITLE, @@ -82,6 +83,9 @@ public class Dashboard { public static final String JSON_PROPERTY_RESTRICTED_ROLES = "restricted_roles"; private List restrictedRoles = null; + public static final String JSON_PROPERTY_TAGS = "tags"; + private JsonNullable> tags = JsonNullable.>undefined(); + public static final String JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS = "template_variable_presets"; private JsonNullable> templateVariablePresets = JsonNullable.>undefined(); @@ -367,6 +371,49 @@ public void setRestrictedRoles(List restrictedRoles) { this.restrictedRoles = restrictedRoles; } + public Dashboard tags(List tags) { + this.tags = JsonNullable.>of(tags); + return this; + } + + public Dashboard addTagsItem(String tagsItem) { + if (this.tags == null || !this.tags.isPresent()) { + this.tags = JsonNullable.>of(new ArrayList<>()); + } + try { + this.tags.get().add(tagsItem); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + } + + /** + * List of team names representing ownership of a dashboard. + * + * @return tags + */ + @jakarta.annotation.Nullable + @JsonIgnore + public List getTags() { + return tags.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TAGS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable> getTags_JsonNullable() { + return tags; + } + + @JsonProperty(JSON_PROPERTY_TAGS) + public void setTags_JsonNullable(JsonNullable> tags) { + this.tags = tags; + } + + public void setTags(List tags) { + this.tags = JsonNullable.>of(tags); + } + public Dashboard templateVariablePresets( List templateVariablePresets) { this.templateVariablePresets = @@ -544,6 +591,7 @@ public boolean equals(Object o) { && Objects.equals(this.notifyList, dashboard.notifyList) && Objects.equals(this.reflowType, dashboard.reflowType) && Objects.equals(this.restrictedRoles, dashboard.restrictedRoles) + && Objects.equals(this.tags, dashboard.tags) && Objects.equals(this.templateVariablePresets, dashboard.templateVariablePresets) && Objects.equals(this.templateVariables, dashboard.templateVariables) && Objects.equals(this.title, dashboard.title) @@ -565,6 +613,7 @@ public int hashCode() { notifyList, reflowType, restrictedRoles, + tags, templateVariablePresets, templateVariables, title, @@ -587,6 +636,7 @@ public String toString() { sb.append(" notifyList: ").append(toIndentedString(notifyList)).append("\n"); sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n"); sb.append(" restrictedRoles: ").append(toIndentedString(restrictedRoles)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); sb.append(" templateVariablePresets: ") .append(toIndentedString(templateVariablePresets)) .append("\n"); diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..f42aca7bd61 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2023-03-08T22:44:59.472Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.json new file mode 100644 index 00000000000..e7c66b35984 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response.json @@ -0,0 +1,32 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"layout_type\":\"ordered\",\"tags\":[\"tm:foobar\"],\"title\":\"Test-Create_a_new_dashboard_with_invalid_team_tags_returns_Bad_Request_response-1678315499\",\"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}}]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"errors\":[\"Invalid tag format. Tag key must be `team`.\"]}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 400, + "reasonPhrase": "Bad Request" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "56fcc8f4-a1be-ee23-e0c7-69e483b38177" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.freeze new file mode 100644 index 00000000000..1d5de377733 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-03-08T20:53:52.326Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.json new file mode 100644 index 00000000000..6338b084389 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Create_a_new_dashboard_with_team_tags_returns_OK_response.json @@ -0,0 +1,58 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"layout_type\":\"ordered\",\"tags\":[\"team:foobar\"],\"title\":\"Test-Create_a_new_dashboard_with_team_tags_returns_OK_response-1678308832\",\"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}}]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"cvx-m2c-ntf\",\"title\":\"Test-Create_a_new_dashboard_with_team_tags_returns_OK_response-1678308832\",\"description\":null,\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/cvx-m2c-ntf/test-createanewdashboardwithteamtagsreturnsokresponse-1678308832\",\"is_read_only\":false,\"template_variables\":null,\"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},\"id\":3494387223047491}],\"notify_list\":null,\"created_at\":\"2023-03-08T20:53:52.690739+00:00\",\"modified_at\":\"2023-03-08T20:53:52.690739+00:00\",\"tags\":[\"team:foobar\"],\"restricted_roles\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "0aa37866-6c06-aa7a-3960-6c8d0dd7cad7" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/dashboard/cvx-m2c-ntf", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"cvx-m2c-ntf\"}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "366a001e-8e89-b50d-d636-4c67ea56664f" + } +] \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.freeze b/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.freeze new file mode 100644 index 00000000000..09bab8b8312 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.freeze @@ -0,0 +1 @@ +2023-03-10T23:23:35.716Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.json b/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.json new file mode 100644 index 00000000000..814afc13b20 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Update_a_dashboard_with_tags_returns_OK_response.json @@ -0,0 +1,88 @@ +[ + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"layout_type\":\"ordered\",\"title\":\"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with Profile Metrics Query\",\"widgets\":[{\"definition\":{\"requests\":[{\"profile_metrics_query\":{\"compute\":{\"aggregation\":\"sum\",\"facet\":\"@prof_core_cpu_cores\"},\"group_by\":[{\"facet\":\"service\",\"limit\":10,\"sort\":{\"aggregation\":\"sum\",\"facet\":\"@prof_core_cpu_cores\",\"order\":\"desc\"}}],\"search\":{\"query\":\"runtime:jvm\"}}}],\"type\":\"timeseries\"}}]}" + }, + "headers": {}, + "method": "POST", + "path": "/api/v1/dashboard", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"ad2-8ch-y8s\",\"title\":\"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with Profile Metrics Query\",\"description\":null,\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/ad2-8ch-y8s/test-updateadashboardwithtagsreturnsokresponse-1678490615-with-profile-metrics-q\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"profile_metrics_query\":{\"compute\":{\"aggregation\":\"sum\",\"facet\":\"@prof_core_cpu_cores\"},\"group_by\":[{\"facet\":\"service\",\"limit\":10,\"sort\":{\"aggregation\":\"sum\",\"facet\":\"@prof_core_cpu_cores\",\"order\":\"desc\"}}],\"search\":{\"query\":\"runtime:jvm\"}}}],\"type\":\"timeseries\"},\"id\":6897153580739865}],\"notify_list\":null,\"created_at\":\"2023-03-10T23:23:35.908079+00:00\",\"modified_at\":\"2023-03-10T23:23:35.908079+00:00\",\"tags\":[],\"restricted_roles\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "76989a86-a63f-f987-ee25-10f0d5202ac6" + }, + { + "httpRequest": { + "body": { + "type": "JSON", + "json": "{\"description\":\"Updated description\",\"layout_type\":\"ordered\",\"tags\":[\"team:foo\",\"team:bar\"],\"title\":\"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with list_stream widget\",\"widgets\":[{\"definition\":{\"requests\":[{\"columns\":[{\"field\":\"timestamp\",\"width\":\"auto\"}],\"query\":{\"data_source\":\"apm_issue_stream\",\"query_string\":\"\"},\"response_format\":\"event_list\"}],\"type\":\"list_stream\"}}]}" + }, + "headers": {}, + "method": "PUT", + "path": "/api/v1/dashboard/ad2-8ch-y8s", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"id\":\"ad2-8ch-y8s\",\"title\":\"Test-Update_a_dashboard_with_tags_returns_OK_response-1678490615 with list_stream widget\",\"description\":\"Updated description\",\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/ad2-8ch-y8s/test-updateadashboardwithtagsreturnsokresponse-1678490615-with-liststream-widget\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"columns\":[{\"field\":\"timestamp\",\"width\":\"auto\"}],\"query\":{\"data_source\":\"apm_issue_stream\",\"query_string\":\"\"},\"response_format\":\"event_list\"}],\"type\":\"list_stream\"},\"id\":4545330920817753}],\"notify_list\":null,\"created_at\":\"2023-03-10T23:23:35.908079+00:00\",\"modified_at\":\"2023-03-10T23:23:36.124521+00:00\",\"tags\":[\"team:foo\",\"team:bar\"],\"restricted_roles\":[]}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "221a1431-6e9a-2807-0d56-43ab26eac02b" + }, + { + "httpRequest": { + "headers": {}, + "method": "DELETE", + "path": "/api/v1/dashboard/ad2-8ch-y8s", + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"deleted_dashboard_id\":\"ad2-8ch-y8s\"}\n", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "868e470a-568c-c70b-2ed2-17f6b3492540" + } +] \ 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 f27db4533f8..1c0e23ee79e 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 @@ -57,7 +57,7 @@ Feature: Dashboards @generated @skip @team:DataDog/dashboards 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": [], "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"}], "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": [], "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"}], "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 @@ -353,6 +353,13 @@ Feature: Dashboards And the response "widgets[0].definition.type" is equal to "image" And the response "widgets[0].definition.url" is equal to "https://example.com/image.png" + @team:DataDog/dashboards + Scenario: Create a new dashboard with invalid team tags returns "Bad Request" response + 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 } } ], "tags": ["tm:foobar"], "layout_type": "ordered" } + When the request is sent + Then the response status is 400 Bad Request + @team:DataDog/dashboards Scenario: Create a new dashboard with list_stream widget Given new "CreateDashboard" request @@ -539,6 +546,15 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].queries[0].aggregator" is equal to "sum" And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1" + @team:DataDog/dashboards + Scenario: Create a new dashboard with team tags returns "OK" response + 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 } } ], "tags": ["team:foobar"], "layout_type": "ordered" } + When the request is sent + Then the response status is 200 OK + And the response "title" is equal to "{{ unique }}" + And the response "tags[0]" is equal to "team:foobar" + @team:DataDog/dashboards Scenario: Create a new dashboard with template variable defaults and default returns "Bad Request" response Given new "CreateDashboard" request @@ -759,7 +775,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": [], "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"}], "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": [], "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"}], "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 @@ -767,7 +783,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": [], "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"}], "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": [], "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"}], "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 @@ -780,3 +796,13 @@ Feature: Dashboards When the request is sent Then the response status is 200 OK And the response "description" is equal to "Updated description" + + @team:DataDog/dashboards + Scenario: Update a dashboard with tags returns "OK" response + Given there is a valid "dashboard" in the system + And new "UpdateDashboard" request + And request contains "dashboard_id" parameter from "dashboard.id" + And body with value {"layout_type": "ordered", "title": "{{ unique }} with list_stream widget","description":"Updated description", "tags": ["team:foo", "team:bar"], "widgets": [{"definition": {"type": "list_stream","requests": [{"columns":[{"width":"auto","field":"timestamp"}],"query":{"data_source":"apm_issue_stream","query_string":""},"response_format":"event_list"}]}}]} + When the request is sent + Then the response status is 200 OK + And the response "tags" is equal to ["team:foo", "team:bar"]