Skip to content

Commit 7f5f29f

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit bc0f83d2 of spec repo
1 parent ee7ecfa commit 7f5f29f

File tree

8 files changed

+226
-6
lines changed

8 files changed

+226
-6
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-02-14 19:39:22.891297",
8-
"spec_repo_commit": "c0625360"
7+
"regenerated": "2023-02-15 14:25:38.180916",
8+
"spec_repo_commit": "bc0f83d2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-02-14 19:39:22.905029",
13-
"spec_repo_commit": "c0625360"
12+
"regenerated": "2023-02-15 14:25:38.196359",
13+
"spec_repo_commit": "bc0f83d2"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9668,6 +9668,11 @@ components:
96689668
description: Widget query.
96699669
example: env:prod AND service:my-app
96709670
type: string
9671+
sort:
9672+
description: Options for sorting results.
9673+
items:
9674+
$ref: '#/components/schemas/WidgetFieldSort'
9675+
type: array
96719676
required:
96729677
- query_string
96739678
type: object
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
"""
2+
Create a new dashboard with slo list widget with sort
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.slo_list_widget_definition import SLOListWidgetDefinition
10+
from datadog_api_client.v1.model.slo_list_widget_definition_type import SLOListWidgetDefinitionType
11+
from datadog_api_client.v1.model.slo_list_widget_query import SLOListWidgetQuery
12+
from datadog_api_client.v1.model.slo_list_widget_request import SLOListWidgetRequest
13+
from datadog_api_client.v1.model.slo_list_widget_request_type import SLOListWidgetRequestType
14+
from datadog_api_client.v1.model.widget import Widget
15+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
16+
from datadog_api_client.v1.model.widget_layout import WidgetLayout
17+
from datadog_api_client.v1.model.widget_sort import WidgetSort
18+
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign
19+
20+
body = Dashboard(
21+
title="Example-Create_a_new_dashboard_with_slo_list_widget_with_sort",
22+
description="",
23+
widgets=[
24+
Widget(
25+
layout=WidgetLayout(
26+
x=0,
27+
y=0,
28+
width=60,
29+
height=21,
30+
),
31+
definition=SLOListWidgetDefinition(
32+
title_size="16",
33+
title_align=WidgetTextAlign.LEFT,
34+
type=SLOListWidgetDefinitionType.SLO_LIST,
35+
requests=[
36+
SLOListWidgetRequest(
37+
query=SLOListWidgetQuery(
38+
query_string="env:prod AND service:my-app",
39+
limit=75,
40+
sort=[
41+
WidgetFieldSort(
42+
column="status.sli",
43+
order=WidgetSort.ASCENDING,
44+
),
45+
],
46+
),
47+
request_type=SLOListWidgetRequestType.SLO_LIST,
48+
),
49+
],
50+
),
51+
),
52+
],
53+
template_variables=[],
54+
layout_type=DashboardLayoutType.FREE,
55+
is_read_only=False,
56+
notify_list=[],
57+
)
58+
59+
configuration = Configuration()
60+
with ApiClient(configuration) as api_client:
61+
api_instance = DashboardsApi(api_client)
62+
response = api_instance.create_dashboard(body=body)
63+
64+
print(response)

src/datadog_api_client/v1/model/slo_list_widget_query.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6-
from typing import Union
6+
from typing import List, Union, TYPE_CHECKING
77

88
from datadog_api_client.model_utils import (
99
ModelNormal,
@@ -13,6 +13,10 @@
1313
)
1414

1515

16+
if TYPE_CHECKING:
17+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
18+
19+
1620
class SLOListWidgetQuery(ModelNormal):
1721
validations = {
1822
"limit": {
@@ -23,17 +27,27 @@ class SLOListWidgetQuery(ModelNormal):
2327

2428
@cached_property
2529
def openapi_types(_):
30+
from datadog_api_client.v1.model.widget_field_sort import WidgetFieldSort
31+
2632
return {
2733
"limit": (int,),
2834
"query_string": (str,),
35+
"sort": ([WidgetFieldSort],),
2936
}
3037

3138
attribute_map = {
3239
"limit": "limit",
3340
"query_string": "query_string",
41+
"sort": "sort",
3442
}
3543

36-
def __init__(self_, query_string: str, limit: Union[int, UnsetType] = unset, **kwargs):
44+
def __init__(
45+
self_,
46+
query_string: str,
47+
limit: Union[int, UnsetType] = unset,
48+
sort: Union[List[WidgetFieldSort], UnsetType] = unset,
49+
**kwargs,
50+
):
3751
"""
3852
Updated SLO List widget.
3953
@@ -42,9 +56,14 @@ def __init__(self_, query_string: str, limit: Union[int, UnsetType] = unset, **k
4256
4357
:param query_string: Widget query.
4458
:type query_string: str
59+
60+
:param sort: Options for sorting results.
61+
:type sort: [WidgetFieldSort], optional
4562
"""
4663
if limit is not unset:
4764
kwargs["limit"] = limit
65+
if sort is not unset:
66+
kwargs["sort"] = sort
4867
super().__init__(kwargs)
4968

5069
self_.query_string = query_string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2023-02-14T18:54:56.599Z
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
interactions:
2+
- request:
3+
body: '{"name":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"thresholds":[{"target":95,"timeframe":"7d","warning":98}],"type":"metric"}'
4+
headers:
5+
accept:
6+
- application/json
7+
content-type:
8+
- application/json
9+
method: POST
10+
uri: https://api.datadoghq.com/api/v1/slo
11+
response:
12+
body:
13+
string: '{"data":[{"id":"80091437d0165587a0831040981e44f9","name":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","tags":[],"monitor_tags":[],"thresholds":[{"timeframe":"7d","target":95.0,"target_display":"95.","warning":98.0,"warning_display":"98."}],"type":"metric","type_id":1,"description":"","timeframe":"7d","warning_threshold":98,"target_threshold":95,"query":{"denominator":"sum:httpservice.hits{!code:3xx}.as_count()","numerator":"sum:httpservice.hits{code:2xx}.as_count()"},"creator":{"name":null,"handle":"[email protected]","email":"[email protected]"},"created_at":1676400896,"modified_at":1676400896}],"error":null}
14+
15+
'
16+
headers:
17+
content-type:
18+
- application/json
19+
status:
20+
code: 200
21+
message: OK
22+
- request:
23+
body: '{"description":"","is_read_only":false,"layout_type":"free","notify_list":[],"template_variables":[],"title":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","widgets":[{"definition":{"requests":[{"query":{"limit":75,"query_string":"env:prod
24+
AND service:my-app","sort":[{"column":"status.sli","order":"asc"}]},"request_type":"slo_list"}],"title_align":"left","title_size":"16","type":"slo_list"},"layout":{"height":21,"width":60,"x":0,"y":0}}]}'
25+
headers:
26+
accept:
27+
- application/json
28+
content-type:
29+
- application/json
30+
method: POST
31+
uri: https://api.datadoghq.com/api/v1/dashboard
32+
response:
33+
body:
34+
string: '{"id":"6hq-ih3-tzg","title":"Test-Create_a_new_dashboard_with_slo_list_widget_with_sort-1676400896","description":"","author_handle":"[email protected]","author_name":null,"layout_type":"free","url":"/dashboard/6hq-ih3-tzg/test-createanewdashboardwithslolistwidgetwithsort-1676400896","is_read_only":false,"template_variables":[],"widgets":[{"definition":{"requests":[{"query":{"limit":75,"query_string":"env:prod
35+
AND service:my-app","sort":[{"column":"status.sli","order":"asc"}]},"request_type":"slo_list"}],"title_align":"left","title_size":"16","type":"slo_list"},"layout":{"height":21,"width":60,"x":0,"y":0},"id":1642439378480719}],"notify_list":[],"created_at":"2023-02-14T18:54:57.012649+00:00","modified_at":"2023-02-14T18:54:57.012649+00:00","restricted_roles":[]}
36+
37+
'
38+
headers:
39+
content-type:
40+
- application/json
41+
status:
42+
code: 200
43+
message: OK
44+
- request:
45+
body: null
46+
headers:
47+
accept:
48+
- application/json
49+
method: DELETE
50+
uri: https://api.datadoghq.com/api/v1/dashboard/6hq-ih3-tzg
51+
response:
52+
body:
53+
string: '{"deleted_dashboard_id":"6hq-ih3-tzg"}
54+
55+
'
56+
headers:
57+
content-type:
58+
- application/json
59+
status:
60+
code: 200
61+
message: OK
62+
- request:
63+
body: null
64+
headers:
65+
accept:
66+
- application/json
67+
method: DELETE
68+
uri: https://api.datadoghq.com/api/v1/slo/80091437d0165587a0831040981e44f9
69+
response:
70+
body:
71+
string: '{"data":["80091437d0165587a0831040981e44f9"],"error":null}
72+
73+
'
74+
headers:
75+
content-type:
76+
- application/json
77+
status:
78+
code: 200
79+
message: OK
80+
version: 1

tests/v1/features/dashboards.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,19 @@ Feature: Dashboards
462462
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
463463
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75
464464

465+
@team:DataDog/dashboards
466+
Scenario: Create a new dashboard with slo list widget with sort
467+
Given there is a valid "slo" in the system
468+
And new "CreateDashboard" request
469+
And body from file "dashboards_json_payload/slo_list_widget_with_sort.json"
470+
When the request is sent
471+
Then the response status is 200 OK
472+
And the response "widgets[0].definition.type" is equal to "slo_list"
473+
And the response "widgets[0].definition.requests[0].query.query_string" is equal to "env:prod AND service:my-app"
474+
And the response "widgets[0].definition.requests[0].query.limit" is equal to 75
475+
And the response "widgets[0].definition.requests[0].query.sort[0].column" is equal to "status.sli"
476+
And the response "widgets[0].definition.requests[0].query.sort[0].order" is equal to "asc"
477+
465478
@team:DataDog/dashboards
466479
Scenario: Create a new dashboard with slo widget
467480
Given there is a valid "slo" in the system
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"title": "{{ unique }}",
3+
"description": "",
4+
"widgets": [
5+
{
6+
"layout": {
7+
"x": 0,
8+
"y": 0,
9+
"width": 60,
10+
"height": 21
11+
},
12+
"definition": {
13+
"title_size": "16",
14+
"title_align": "left",
15+
"type": "slo_list",
16+
"requests": [
17+
{
18+
"query": {
19+
"query_string": "env:prod AND service:my-app",
20+
"limit": 75,
21+
"sort": [
22+
{
23+
"column": "status.sli",
24+
"order": "asc"
25+
}
26+
]
27+
},
28+
"request_type": "slo_list"
29+
}
30+
]
31+
}
32+
}
33+
],
34+
"template_variables": [],
35+
"layout_type": "free",
36+
"is_read_only": false,
37+
"notify_list": []
38+
}

0 commit comments

Comments
 (0)