Skip to content

Commit 79645df

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add tags field to dashboard API spec (#1706)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent c556eaa commit 79645df

12 files changed

+440
-7
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-03-24 16:41:55.959055",
8-
"spec_repo_commit": "9bdb5ee6"
7+
"regenerated": "2023-03-27 19:48:20.211619",
8+
"spec_repo_commit": "b6741167"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-03-24 16:41:55.974878",
13-
"spec_repo_commit": "9bdb5ee6"
12+
"regenerated": "2023-03-27 19:48:20.224682",
13+
"spec_repo_commit": "b6741167"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,14 @@ components:
10061006
description: A role UUID.
10071007
type: string
10081008
type: array
1009+
tags:
1010+
description: List of team names representing ownership of a dashboard.
1011+
items:
1012+
description: The name of a Datadog team of the form `team:<name>`
1013+
type: string
1014+
maxItems: 5
1015+
nullable: true
1016+
type: array
10091017
template_variable_presets:
10101018
description: Array of template variables saved views.
10111019
items:
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Create a new dashboard with team tags returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.DashboardsApi;
6+
import com.datadog.api.client.v1.model.ChangeWidgetDefinition;
7+
import com.datadog.api.client.v1.model.ChangeWidgetDefinitionType;
8+
import com.datadog.api.client.v1.model.ChangeWidgetRequest;
9+
import com.datadog.api.client.v1.model.Dashboard;
10+
import com.datadog.api.client.v1.model.DashboardLayoutType;
11+
import com.datadog.api.client.v1.model.FormulaAndFunctionEventAggregation;
12+
import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinition;
13+
import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinitionCompute;
14+
import com.datadog.api.client.v1.model.FormulaAndFunctionEventQueryDefinitionSearch;
15+
import com.datadog.api.client.v1.model.FormulaAndFunctionEventsDataSource;
16+
import com.datadog.api.client.v1.model.FormulaAndFunctionQueryDefinition;
17+
import com.datadog.api.client.v1.model.FormulaAndFunctionResponseFormat;
18+
import com.datadog.api.client.v1.model.Widget;
19+
import com.datadog.api.client.v1.model.WidgetChangeType;
20+
import com.datadog.api.client.v1.model.WidgetCompareTo;
21+
import com.datadog.api.client.v1.model.WidgetDefinition;
22+
import com.datadog.api.client.v1.model.WidgetFormula;
23+
import com.datadog.api.client.v1.model.WidgetLayout;
24+
import com.datadog.api.client.v1.model.WidgetOrderBy;
25+
import com.datadog.api.client.v1.model.WidgetSort;
26+
import com.datadog.api.client.v1.model.WidgetTextAlign;
27+
import com.datadog.api.client.v1.model.WidgetTime;
28+
import java.util.Arrays;
29+
import java.util.Collections;
30+
31+
public class Example {
32+
public static void main(String[] args) {
33+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
34+
DashboardsApi apiInstance = new DashboardsApi(defaultClient);
35+
36+
Dashboard body =
37+
new Dashboard()
38+
.title("Example-Create_a_new_dashboard_with_team_tags_returns_OK_response")
39+
.widgets(
40+
Collections.singletonList(
41+
new Widget()
42+
.definition(
43+
new WidgetDefinition(
44+
new ChangeWidgetDefinition()
45+
.title("")
46+
.titleSize("16")
47+
.titleAlign(WidgetTextAlign.LEFT)
48+
.time(new WidgetTime())
49+
.type(ChangeWidgetDefinitionType.CHANGE)
50+
.requests(
51+
Collections.singletonList(
52+
new ChangeWidgetRequest()
53+
.formulas(
54+
Arrays.asList(
55+
new WidgetFormula()
56+
.formula("hour_before(query1)"),
57+
new WidgetFormula().formula("query1")))
58+
.queries(
59+
Collections.singletonList(
60+
new FormulaAndFunctionQueryDefinition(
61+
new FormulaAndFunctionEventQueryDefinition()
62+
.dataSource(
63+
FormulaAndFunctionEventsDataSource
64+
.LOGS)
65+
.name("query1")
66+
.search(
67+
new FormulaAndFunctionEventQueryDefinitionSearch()
68+
.query(""))
69+
.indexes(
70+
Collections.singletonList("*"))
71+
.compute(
72+
new FormulaAndFunctionEventQueryDefinitionCompute()
73+
.aggregation(
74+
FormulaAndFunctionEventAggregation
75+
.COUNT)))))
76+
.responseFormat(
77+
FormulaAndFunctionResponseFormat.SCALAR)
78+
.compareTo(WidgetCompareTo.HOUR_BEFORE)
79+
.increaseGood(true)
80+
.orderBy(WidgetOrderBy.CHANGE)
81+
.changeType(WidgetChangeType.ABSOLUTE)
82+
.orderDir(WidgetSort.DESCENDING)))))
83+
.layout(new WidgetLayout().x(0L).y(0L).width(4L).height(4L))))
84+
.tags(Collections.singletonList("team:foobar"))
85+
.layoutType(DashboardLayoutType.ORDERED);
86+
87+
try {
88+
Dashboard result = apiInstance.createDashboard(body);
89+
System.out.println(result);
90+
} catch (ApiException e) {
91+
System.err.println("Exception when calling DashboardsApi#createDashboard");
92+
System.err.println("Status code: " + e.getCode());
93+
System.err.println("Reason: " + e.getResponseBody());
94+
System.err.println("Response headers: " + e.getResponseHeaders());
95+
e.printStackTrace();
96+
}
97+
}
98+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Update a dashboard with tags returns "OK" response
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.ApiException;
5+
import com.datadog.api.client.v1.api.DashboardsApi;
6+
import com.datadog.api.client.v1.model.Dashboard;
7+
import com.datadog.api.client.v1.model.DashboardLayoutType;
8+
import com.datadog.api.client.v1.model.ListStreamColumn;
9+
import com.datadog.api.client.v1.model.ListStreamColumnWidth;
10+
import com.datadog.api.client.v1.model.ListStreamQuery;
11+
import com.datadog.api.client.v1.model.ListStreamResponseFormat;
12+
import com.datadog.api.client.v1.model.ListStreamSource;
13+
import com.datadog.api.client.v1.model.ListStreamWidgetDefinition;
14+
import com.datadog.api.client.v1.model.ListStreamWidgetDefinitionType;
15+
import com.datadog.api.client.v1.model.ListStreamWidgetRequest;
16+
import com.datadog.api.client.v1.model.Widget;
17+
import com.datadog.api.client.v1.model.WidgetDefinition;
18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
21+
public class Example {
22+
public static void main(String[] args) {
23+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
24+
DashboardsApi apiInstance = new DashboardsApi(defaultClient);
25+
26+
// there is a valid "dashboard" in the system
27+
String DASHBOARD_ID = System.getenv("DASHBOARD_ID");
28+
29+
Dashboard body =
30+
new Dashboard()
31+
.layoutType(DashboardLayoutType.ORDERED)
32+
.title(
33+
"Example-Update_a_dashboard_with_tags_returns_OK_response with list_stream widget")
34+
.description("Updated description")
35+
.tags(Arrays.asList("team:foo", "team:bar"))
36+
.widgets(
37+
Collections.singletonList(
38+
new Widget()
39+
.definition(
40+
new WidgetDefinition(
41+
new ListStreamWidgetDefinition()
42+
.type(ListStreamWidgetDefinitionType.LIST_STREAM)
43+
.requests(
44+
Collections.singletonList(
45+
new ListStreamWidgetRequest()
46+
.columns(
47+
Collections.singletonList(
48+
new ListStreamColumn()
49+
.width(ListStreamColumnWidth.AUTO)
50+
.field("timestamp")))
51+
.query(
52+
new ListStreamQuery()
53+
.dataSource(
54+
ListStreamSource.APM_ISSUE_STREAM)
55+
.queryString(""))
56+
.responseFormat(
57+
ListStreamResponseFormat.EVENT_LIST)))))));
58+
59+
try {
60+
Dashboard result = apiInstance.updateDashboard(DASHBOARD_ID, body);
61+
System.out.println(result);
62+
} catch (ApiException e) {
63+
System.err.println("Exception when calling DashboardsApi#updateDashboard");
64+
System.err.println("Status code: " + e.getCode());
65+
System.err.println("Reason: " + e.getResponseBody());
66+
System.err.println("Response headers: " + e.getResponseHeaders());
67+
e.printStackTrace();
68+
}
69+
}
70+
}

src/main/java/com/datadog/api/client/v1/model/Dashboard.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Dashboard.JSON_PROPERTY_NOTIFY_LIST,
3636
Dashboard.JSON_PROPERTY_REFLOW_TYPE,
3737
Dashboard.JSON_PROPERTY_RESTRICTED_ROLES,
38+
Dashboard.JSON_PROPERTY_TAGS,
3839
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS,
3940
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLES,
4041
Dashboard.JSON_PROPERTY_TITLE,
@@ -82,6 +83,9 @@ public class Dashboard {
8283
public static final String JSON_PROPERTY_RESTRICTED_ROLES = "restricted_roles";
8384
private List<String> restrictedRoles = null;
8485

86+
public static final String JSON_PROPERTY_TAGS = "tags";
87+
private JsonNullable<List<String>> tags = JsonNullable.<List<String>>undefined();
88+
8589
public static final String JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS = "template_variable_presets";
8690
private JsonNullable<List<DashboardTemplateVariablePreset>> templateVariablePresets =
8791
JsonNullable.<List<DashboardTemplateVariablePreset>>undefined();
@@ -367,6 +371,49 @@ public void setRestrictedRoles(List<String> restrictedRoles) {
367371
this.restrictedRoles = restrictedRoles;
368372
}
369373

374+
public Dashboard tags(List<String> tags) {
375+
this.tags = JsonNullable.<List<String>>of(tags);
376+
return this;
377+
}
378+
379+
public Dashboard addTagsItem(String tagsItem) {
380+
if (this.tags == null || !this.tags.isPresent()) {
381+
this.tags = JsonNullable.<List<String>>of(new ArrayList<>());
382+
}
383+
try {
384+
this.tags.get().add(tagsItem);
385+
} catch (java.util.NoSuchElementException e) {
386+
// this can never happen, as we make sure above that the value is present
387+
}
388+
return this;
389+
}
390+
391+
/**
392+
* List of team names representing ownership of a dashboard.
393+
*
394+
* @return tags
395+
*/
396+
@jakarta.annotation.Nullable
397+
@JsonIgnore
398+
public List<String> getTags() {
399+
return tags.orElse(null);
400+
}
401+
402+
@JsonProperty(JSON_PROPERTY_TAGS)
403+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
404+
public JsonNullable<List<String>> getTags_JsonNullable() {
405+
return tags;
406+
}
407+
408+
@JsonProperty(JSON_PROPERTY_TAGS)
409+
public void setTags_JsonNullable(JsonNullable<List<String>> tags) {
410+
this.tags = tags;
411+
}
412+
413+
public void setTags(List<String> tags) {
414+
this.tags = JsonNullable.<List<String>>of(tags);
415+
}
416+
370417
public Dashboard templateVariablePresets(
371418
List<DashboardTemplateVariablePreset> templateVariablePresets) {
372419
this.templateVariablePresets =
@@ -544,6 +591,7 @@ public boolean equals(Object o) {
544591
&& Objects.equals(this.notifyList, dashboard.notifyList)
545592
&& Objects.equals(this.reflowType, dashboard.reflowType)
546593
&& Objects.equals(this.restrictedRoles, dashboard.restrictedRoles)
594+
&& Objects.equals(this.tags, dashboard.tags)
547595
&& Objects.equals(this.templateVariablePresets, dashboard.templateVariablePresets)
548596
&& Objects.equals(this.templateVariables, dashboard.templateVariables)
549597
&& Objects.equals(this.title, dashboard.title)
@@ -565,6 +613,7 @@ public int hashCode() {
565613
notifyList,
566614
reflowType,
567615
restrictedRoles,
616+
tags,
568617
templateVariablePresets,
569618
templateVariables,
570619
title,
@@ -587,6 +636,7 @@ public String toString() {
587636
sb.append(" notifyList: ").append(toIndentedString(notifyList)).append("\n");
588637
sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n");
589638
sb.append(" restrictedRoles: ").append(toIndentedString(restrictedRoles)).append("\n");
639+
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
590640
sb.append(" templateVariablePresets: ")
591641
.append(toIndentedString(templateVariablePresets))
592642
.append("\n");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-03-08T22:44:59.472Z
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"httpRequest": {
4+
"body": {
5+
"type": "JSON",
6+
"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}}]}"
7+
},
8+
"headers": {},
9+
"method": "POST",
10+
"path": "/api/v1/dashboard",
11+
"keepAlive": false,
12+
"secure": true
13+
},
14+
"httpResponse": {
15+
"body": "{\"errors\":[\"Invalid tag format. Tag key must be `team`.\"]}",
16+
"headers": {
17+
"Content-Type": [
18+
"application/json"
19+
]
20+
},
21+
"statusCode": 400,
22+
"reasonPhrase": "Bad Request"
23+
},
24+
"times": {
25+
"remainingTimes": 1
26+
},
27+
"timeToLive": {
28+
"unlimited": true
29+
},
30+
"id": "56fcc8f4-a1be-ee23-e0c7-69e483b38177"
31+
}
32+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-03-08T20:53:52.326Z
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"httpRequest": {
4+
"body": {
5+
"type": "JSON",
6+
"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}}]}"
7+
},
8+
"headers": {},
9+
"method": "POST",
10+
"path": "/api/v1/dashboard",
11+
"keepAlive": false,
12+
"secure": true
13+
},
14+
"httpResponse": {
15+
"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",
16+
"headers": {
17+
"Content-Type": [
18+
"application/json"
19+
]
20+
},
21+
"statusCode": 200,
22+
"reasonPhrase": "OK"
23+
},
24+
"times": {
25+
"remainingTimes": 1
26+
},
27+
"timeToLive": {
28+
"unlimited": true
29+
},
30+
"id": "0aa37866-6c06-aa7a-3960-6c8d0dd7cad7"
31+
},
32+
{
33+
"httpRequest": {
34+
"headers": {},
35+
"method": "DELETE",
36+
"path": "/api/v1/dashboard/cvx-m2c-ntf",
37+
"keepAlive": false,
38+
"secure": true
39+
},
40+
"httpResponse": {
41+
"body": "{\"deleted_dashboard_id\":\"cvx-m2c-ntf\"}\n",
42+
"headers": {
43+
"Content-Type": [
44+
"application/json"
45+
]
46+
},
47+
"statusCode": 200,
48+
"reasonPhrase": "OK"
49+
},
50+
"times": {
51+
"remainingTimes": 1
52+
},
53+
"timeToLive": {
54+
"unlimited": true
55+
},
56+
"id": "366a001e-8e89-b50d-d636-4c67ea56664f"
57+
}
58+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-03-10T23:23:35.716Z

0 commit comments

Comments
 (0)