Skip to content

Commit 2439a1b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add sort field to List Stream Widget's request query (#1492)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 067e5c3 commit 2439a1b

10 files changed

+246
-4
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-05-30 14:28:55.332880",
8-
"spec_repo_commit": "adf5379f"
7+
"regenerated": "2023-05-31 17:18:49.448507",
8+
"spec_repo_commit": "3b710977"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-05-30 14:28:55.345353",
13-
"spec_repo_commit": "adf5379f"
12+
"regenerated": "2023-05-31 17:18:49.461560",
13+
"spec_repo_commit": "3b710977"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4289,6 +4289,8 @@ components:
42894289
description: Widget query.
42904290
example: '@service:app'
42914291
type: string
4292+
sort:
4293+
$ref: '#/components/schemas/WidgetFieldSort'
42924294
storage:
42934295
description: Option for storage location. Feature in Private Beta.
42944296
example: indexes
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
Create a new dashboard with list_stream widget with a valid sort parameter ASC
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
7+
from datadog_api_client.v1.model.dashboard import Dashboard
8+
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
9+
from datadog_api_client.v1.model.list_stream_column import ListStreamColumn
10+
from datadog_api_client.v1.model.list_stream_column_width import ListStreamColumnWidth
11+
from datadog_api_client.v1.model.list_stream_query import ListStreamQuery
12+
from datadog_api_client.v1.model.list_stream_response_format import ListStreamResponseFormat
13+
from datadog_api_client.v1.model.list_stream_source import ListStreamSource
14+
from datadog_api_client.v1.model.list_stream_widget_definition import ListStreamWidgetDefinition
15+
from datadog_api_client.v1.model.list_stream_widget_definition_type import ListStreamWidgetDefinitionType
16+
from datadog_api_client.v1.model.list_stream_widget_request import ListStreamWidgetRequest
17+
from datadog_api_client.v1.model.widget import Widget
18+
from datadog_api_client.v1.model.widget_event_size import WidgetEventSize
19+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
20+
from datadog_api_client.v1.model.widget_sort import WidgetSort
21+
22+
body = Dashboard(
23+
layout_type=DashboardLayoutType.ORDERED,
24+
title="Example-Dashboard with list_stream widget",
25+
widgets=[
26+
Widget(
27+
definition=ListStreamWidgetDefinition(
28+
type=ListStreamWidgetDefinitionType.LIST_STREAM,
29+
requests=[
30+
ListStreamWidgetRequest(
31+
columns=[
32+
ListStreamColumn(
33+
width=ListStreamColumnWidth.AUTO,
34+
field="timestamp",
35+
),
36+
],
37+
query=ListStreamQuery(
38+
data_source=ListStreamSource.EVENT_STREAM,
39+
query_string="",
40+
event_size=WidgetEventSize.LARGE,
41+
sort=WidgetFieldSort(
42+
column="timestamp",
43+
order=WidgetSort.ASCENDING,
44+
),
45+
),
46+
response_format=ListStreamResponseFormat.EVENT_LIST,
47+
),
48+
],
49+
),
50+
),
51+
],
52+
)
53+
54+
configuration = Configuration()
55+
with ApiClient(configuration) as api_client:
56+
api_instance = DashboardsApi(api_client)
57+
response = api_instance.create_dashboard(body=body)
58+
59+
print(response)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
Create a new dashboard with list_stream widget with a valid sort parameter DESC
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
7+
from datadog_api_client.v1.model.dashboard import Dashboard
8+
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
9+
from datadog_api_client.v1.model.list_stream_column import ListStreamColumn
10+
from datadog_api_client.v1.model.list_stream_column_width import ListStreamColumnWidth
11+
from datadog_api_client.v1.model.list_stream_query import ListStreamQuery
12+
from datadog_api_client.v1.model.list_stream_response_format import ListStreamResponseFormat
13+
from datadog_api_client.v1.model.list_stream_source import ListStreamSource
14+
from datadog_api_client.v1.model.list_stream_widget_definition import ListStreamWidgetDefinition
15+
from datadog_api_client.v1.model.list_stream_widget_definition_type import ListStreamWidgetDefinitionType
16+
from datadog_api_client.v1.model.list_stream_widget_request import ListStreamWidgetRequest
17+
from datadog_api_client.v1.model.widget import Widget
18+
from datadog_api_client.v1.model.widget_event_size import WidgetEventSize
19+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
20+
from datadog_api_client.v1.model.widget_sort import WidgetSort
21+
22+
body = Dashboard(
23+
layout_type=DashboardLayoutType.ORDERED,
24+
title="Example-Dashboard with list_stream widget",
25+
widgets=[
26+
Widget(
27+
definition=ListStreamWidgetDefinition(
28+
type=ListStreamWidgetDefinitionType.LIST_STREAM,
29+
requests=[
30+
ListStreamWidgetRequest(
31+
columns=[
32+
ListStreamColumn(
33+
width=ListStreamColumnWidth.AUTO,
34+
field="timestamp",
35+
),
36+
],
37+
query=ListStreamQuery(
38+
data_source=ListStreamSource.EVENT_STREAM,
39+
query_string="",
40+
event_size=WidgetEventSize.LARGE,
41+
sort=WidgetFieldSort(
42+
column="timestamp",
43+
order=WidgetSort.DESCENDING,
44+
),
45+
),
46+
response_format=ListStreamResponseFormat.EVENT_LIST,
47+
),
48+
],
49+
),
50+
),
51+
],
52+
)
53+
54+
configuration = Configuration()
55+
with ApiClient(configuration) as api_client:
56+
api_instance = DashboardsApi(api_client)
57+
response = api_instance.create_dashboard(body=body)
58+
59+
print(response)

src/datadog_api_client/v1/model/list_stream_query.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from datadog_api_client.v1.model.list_stream_source import ListStreamSource
1919
from datadog_api_client.v1.model.widget_event_size import WidgetEventSize
2020
from datadog_api_client.v1.model.list_stream_group_by_items import ListStreamGroupByItems
21+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
2122

2223

2324
class ListStreamQuery(ModelNormal):
@@ -37,6 +38,7 @@ def openapi_types(_):
3738
from datadog_api_client.v1.model.list_stream_source import ListStreamSource
3839
from datadog_api_client.v1.model.widget_event_size import WidgetEventSize
3940
from datadog_api_client.v1.model.list_stream_group_by_items import ListStreamGroupByItems
41+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
4042

4143
return {
4244
"compute": ([ListStreamComputeItems],),
@@ -45,6 +47,7 @@ def openapi_types(_):
4547
"group_by": ([ListStreamGroupByItems],),
4648
"indexes": ([str],),
4749
"query_string": (str,),
50+
"sort": (WidgetFieldSort,),
4851
"storage": (str,),
4952
}
5053

@@ -55,6 +58,7 @@ def openapi_types(_):
5558
"group_by": "group_by",
5659
"indexes": "indexes",
5760
"query_string": "query_string",
61+
"sort": "sort",
5862
"storage": "storage",
5963
}
6064

@@ -66,6 +70,7 @@ def __init__(
6670
event_size: Union[WidgetEventSize, UnsetType] = unset,
6771
group_by: Union[List[ListStreamGroupByItems], UnsetType] = unset,
6872
indexes: Union[List[str], UnsetType] = unset,
73+
sort: Union[WidgetFieldSort, UnsetType] = unset,
6974
storage: Union[str, UnsetType] = unset,
7075
**kwargs,
7176
):
@@ -90,6 +95,9 @@ def __init__(
9095
:param query_string: Widget query.
9196
:type query_string: str
9297
98+
:param sort: Which column and order to sort by
99+
:type sort: WidgetFieldSort, optional
100+
93101
:param storage: Option for storage location. Feature in Private Beta.
94102
:type storage: str, optional
95103
"""
@@ -101,6 +109,8 @@ def __init__(
101109
kwargs["group_by"] = group_by
102110
if indexes is not unset:
103111
kwargs["indexes"] = indexes
112+
if sort is not unset:
113+
kwargs["sort"] = sort
104114
if storage is not unset:
105115
kwargs["storage"] = storage
106116
super().__init__(kwargs)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-05-31T17:12:24.532Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
interactions:
2+
- request:
3+
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_list_stream_widget_with_a_valid_sort_parameter_ASC-1685553144
4+
with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"event_stream","event_size":"l","query_string":"","sort":{"column":"timestamp","order":"asc"}},"response_format":"event_list"}],"type":"list_stream"}}]}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v1/dashboard
12+
response:
13+
body:
14+
string: '{"id":"td2-he3-3vj","title":"Test-Create_a_new_dashboard_with_list_stream_widget_with_a_valid_sort_parameter_ASC-1685553144
15+
with list_stream widget","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/td2-he3-3vj/test-createanewdashboardwithliststreamwidgetwithavalidsortparameterasc-168555314","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"event_stream","event_size":"l","query_string":"","sort":{"column":"timestamp","order":"asc"}},"response_format":"event_list"}],"type":"list_stream"},"id":4579982797049164}],"notify_list":null,"created_at":"2023-05-31T17:12:24.700217+00:00","modified_at":"2023-05-31T17:12:24.700217+00:00","restricted_roles":[]}
16+
17+
'
18+
headers:
19+
content-type:
20+
- application/json
21+
status:
22+
code: 200
23+
message: OK
24+
- request:
25+
body: null
26+
headers:
27+
accept:
28+
- application/json
29+
method: DELETE
30+
uri: https://api.datadoghq.com/api/v1/dashboard/td2-he3-3vj
31+
response:
32+
body:
33+
string: '{"deleted_dashboard_id":"td2-he3-3vj"}
34+
35+
'
36+
headers:
37+
content-type:
38+
- application/json
39+
status:
40+
code: 200
41+
message: OK
42+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-05-31T17:12:24.923Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
interactions:
2+
- request:
3+
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_list_stream_widget_with_a_valid_sort_parameter_DESC-1685553144
4+
with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"event_stream","event_size":"l","query_string":"","sort":{"column":"timestamp","order":"desc"}},"response_format":"event_list"}],"type":"list_stream"}}]}'
5+
headers:
6+
accept:
7+
- application/json
8+
content-type:
9+
- application/json
10+
method: POST
11+
uri: https://api.datadoghq.com/api/v1/dashboard
12+
response:
13+
body:
14+
string: '{"id":"mwn-7ph-8z8","title":"Test-Create_a_new_dashboard_with_list_stream_widget_with_a_valid_sort_parameter_DESC-1685553144
15+
with list_stream widget","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/mwn-7ph-8z8/test-createanewdashboardwithliststreamwidgetwithavalidsortparameterdesc-16855531","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"event_stream","event_size":"l","query_string":"","sort":{"column":"timestamp","order":"desc"}},"response_format":"event_list"}],"type":"list_stream"},"id":8830087860290510}],"notify_list":null,"created_at":"2023-05-31T17:12:25.020023+00:00","modified_at":"2023-05-31T17:12:25.020023+00:00","restricted_roles":[]}
16+
17+
'
18+
headers:
19+
content-type:
20+
- application/json
21+
status:
22+
code: 200
23+
message: OK
24+
- request:
25+
body: null
26+
headers:
27+
accept:
28+
- application/json
29+
method: DELETE
30+
uri: https://api.datadoghq.com/api/v1/dashboard/mwn-7ph-8z8
31+
response:
32+
body:
33+
string: '{"deleted_dashboard_id":"mwn-7ph-8z8"}
34+
35+
'
36+
headers:
37+
content-type:
38+
- application/json
39+
status:
40+
code: 200
41+
message: OK
42+
version: 1

tests/v1/features/dashboards.feature

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,32 @@ Feature: Dashboards
390390
And the response "widgets[0].definition.type" is equal to "list_stream"
391391
And the response "widgets[0].definition.requests[0].query.data_source" is equal to "apm_issue_stream"
392392

393+
@team:DataDog/dashboards-backend
394+
Scenario: Create a new dashboard with list_stream widget with a valid sort parameter ASC
395+
Given new "CreateDashboard" request
396+
And body with value {"layout_type": "ordered","title": "{{ unique }} with list_stream widget","widgets": [{"definition": {"type": "list_stream","requests": [{"columns": [{"width": "auto","field": "timestamp"}],"query": {"data_source": "event_stream","query_string": "","event_size": "l", "sort": {"column": "timestamp", "order": "asc"}},"response_format": "event_list"}]}}]}
397+
When the request is sent
398+
Then the response status is 200 OK
399+
And the response "widgets[0].definition.type" is equal to "list_stream"
400+
And the response "widgets[0].definition.requests[0].response_format" is equal to "event_list"
401+
And the response "widgets[0].definition.requests[0].query.data_source" is equal to "event_stream"
402+
And the response "widgets[0].definition.requests[0].query.event_size" is equal to "l"
403+
And the response "widgets[0].definition.requests[0].query.sort.column" is equal to "timestamp"
404+
And the response "widgets[0].definition.requests[0].query.sort.order" is equal to "asc"
405+
406+
@team:DataDog/dashboards-backend
407+
Scenario: Create a new dashboard with list_stream widget with a valid sort parameter DESC
408+
Given new "CreateDashboard" request
409+
And body with value {"layout_type": "ordered","title": "{{ unique }} with list_stream widget","widgets": [{"definition": {"type": "list_stream","requests": [{"columns": [{"width": "auto","field": "timestamp"}],"query": {"data_source": "event_stream","query_string": "","event_size": "l", "sort": {"column": "timestamp", "order": "desc"}},"response_format": "event_list"}]}}]}
410+
When the request is sent
411+
Then the response status is 200 OK
412+
And the response "widgets[0].definition.type" is equal to "list_stream"
413+
And the response "widgets[0].definition.requests[0].response_format" is equal to "event_list"
414+
And the response "widgets[0].definition.requests[0].query.data_source" is equal to "event_stream"
415+
And the response "widgets[0].definition.requests[0].query.event_size" is equal to "l"
416+
And the response "widgets[0].definition.requests[0].query.sort.column" is equal to "timestamp"
417+
And the response "widgets[0].definition.requests[0].query.sort.order" is equal to "desc"
418+
393419
@team:DataDog/dashboards-backend
394420
Scenario: Create a new dashboard with log_stream widget
395421
Given new "CreateDashboard" request

0 commit comments

Comments
 (0)