Skip to content

Commit 4337a59

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Support incident_analytics enum in dashboard widget FormulaAndFunctionEventsDataSource data sources (#2068)
* Regenerate client from commit 015355f6 of spec repo * pre-commit fixes --------- Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
1 parent 4762f53 commit 4337a59

File tree

7 files changed

+158
-5
lines changed

7 files changed

+158
-5
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.6",
7-
"regenerated": "2024-07-22 20:03:16.966843",
8-
"spec_repo_commit": "cd020fa6"
7+
"regenerated": "2024-07-23 15:33:51.142309",
8+
"spec_repo_commit": "015355f6"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-07-22 20:03:16.983748",
13-
"spec_repo_commit": "cd020fa6"
12+
"regenerated": "2024-07-23 15:33:51.159414",
13+
"spec_repo_commit": "015355f6"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,7 @@ components:
28672867
- events
28682868
- ci_tests
28692869
- ci_pipelines
2870+
- incident_analytics
28702871
example: logs
28712872
type: string
28722873
x-enum-varnames:
@@ -2880,6 +2881,7 @@ components:
28802881
- EVENTS
28812882
- CI_TESTS
28822883
- CI_PIPELINES
2884+
- INCIDENT_ANALYTICS
28832885
FormulaAndFunctionMetricAggregation:
28842886
description: The aggregation methods available for metrics queries.
28852887
enum:
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
"""
2+
Create a new timeseries widget with incident_analytics data source
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.dashboard_reflow_type import DashboardReflowType
10+
from datadog_api_client.v1.model.formula_and_function_event_aggregation import FormulaAndFunctionEventAggregation
11+
from datadog_api_client.v1.model.formula_and_function_event_query_definition import (
12+
FormulaAndFunctionEventQueryDefinition,
13+
)
14+
from datadog_api_client.v1.model.formula_and_function_event_query_definition_compute import (
15+
FormulaAndFunctionEventQueryDefinitionCompute,
16+
)
17+
from datadog_api_client.v1.model.formula_and_function_event_query_definition_search import (
18+
FormulaAndFunctionEventQueryDefinitionSearch,
19+
)
20+
from datadog_api_client.v1.model.formula_and_function_events_data_source import FormulaAndFunctionEventsDataSource
21+
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
22+
from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition
23+
from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType
24+
from datadog_api_client.v1.model.timeseries_widget_legend_column import TimeseriesWidgetLegendColumn
25+
from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout
26+
from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest
27+
from datadog_api_client.v1.model.widget import Widget
28+
from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType
29+
from datadog_api_client.v1.model.widget_formula import WidgetFormula
30+
from datadog_api_client.v1.model.widget_line_type import WidgetLineType
31+
from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth
32+
from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle
33+
from datadog_api_client.v1.model.widget_time import WidgetTime
34+
35+
body = Dashboard(
36+
title="Example-Dashboard with incident_analytics datasource",
37+
widgets=[
38+
Widget(
39+
definition=TimeseriesWidgetDefinition(
40+
title="",
41+
show_legend=True,
42+
legend_layout=TimeseriesWidgetLegendLayout.AUTO,
43+
legend_columns=[
44+
TimeseriesWidgetLegendColumn.AVG,
45+
TimeseriesWidgetLegendColumn.MIN,
46+
TimeseriesWidgetLegendColumn.MAX,
47+
TimeseriesWidgetLegendColumn.VALUE,
48+
TimeseriesWidgetLegendColumn.SUM,
49+
],
50+
time=WidgetTime(),
51+
type=TimeseriesWidgetDefinitionType.TIMESERIES,
52+
requests=[
53+
TimeseriesWidgetRequest(
54+
formulas=[
55+
WidgetFormula(
56+
formula="query1",
57+
),
58+
],
59+
queries=[
60+
FormulaAndFunctionEventQueryDefinition(
61+
data_source=FormulaAndFunctionEventsDataSource.INCIDENT_ANALYTICS,
62+
name="query1",
63+
search=FormulaAndFunctionEventQueryDefinitionSearch(
64+
query="test_level:test",
65+
),
66+
indexes=[
67+
"*",
68+
],
69+
compute=FormulaAndFunctionEventQueryDefinitionCompute(
70+
aggregation=FormulaAndFunctionEventAggregation.COUNT,
71+
),
72+
group_by=[],
73+
),
74+
],
75+
response_format=FormulaAndFunctionResponseFormat.TIMESERIES,
76+
style=WidgetRequestStyle(
77+
palette="dog_classic",
78+
line_type=WidgetLineType.SOLID,
79+
line_width=WidgetLineWidth.NORMAL,
80+
),
81+
display_type=WidgetDisplayType.LINE,
82+
),
83+
],
84+
),
85+
),
86+
],
87+
layout_type=DashboardLayoutType.ORDERED,
88+
reflow_type=DashboardReflowType.AUTO,
89+
)
90+
91+
configuration = Configuration()
92+
with ApiClient(configuration) as api_client:
93+
api_instance = DashboardsApi(api_client)
94+
response = api_instance.create_dashboard(body=body)
95+
96+
print(response)

src/datadog_api_client/v1/model/formula_and_function_events_data_source.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
1616
"""
1717
Data source for event platform-based queries.
1818
19-
:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests", "ci_pipelines"].
19+
:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests", "ci_pipelines", "incident_analytics"].
2020
:type value: str
2121
"""
2222

@@ -31,6 +31,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
3131
"events",
3232
"ci_tests",
3333
"ci_pipelines",
34+
"incident_analytics",
3435
}
3536
LOGS: ClassVar["FormulaAndFunctionEventsDataSource"]
3637
SPANS: ClassVar["FormulaAndFunctionEventsDataSource"]
@@ -42,6 +43,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
4243
EVENTS: ClassVar["FormulaAndFunctionEventsDataSource"]
4344
CI_TESTS: ClassVar["FormulaAndFunctionEventsDataSource"]
4445
CI_PIPELINES: ClassVar["FormulaAndFunctionEventsDataSource"]
46+
INCIDENT_ANALYTICS: ClassVar["FormulaAndFunctionEventsDataSource"]
4547

4648
@cached_property
4749
def openapi_types(_):
@@ -60,3 +62,4 @@ def openapi_types(_):
6062
FormulaAndFunctionEventsDataSource.EVENTS = FormulaAndFunctionEventsDataSource("events")
6163
FormulaAndFunctionEventsDataSource.CI_TESTS = FormulaAndFunctionEventsDataSource("ci_tests")
6264
FormulaAndFunctionEventsDataSource.CI_PIPELINES = FormulaAndFunctionEventsDataSource("ci_pipelines")
65+
FormulaAndFunctionEventsDataSource.INCIDENT_ANALYTICS = FormulaAndFunctionEventsDataSource("incident_analytics")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024-07-23T14:59:59.215Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
interactions:
2+
- request:
3+
body: '{"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799
4+
with incident_analytics datasource","widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"incident_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"}}]}'
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":"r29-a2b-nhh","title":"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799
15+
with incident_analytics datasource","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/r29-a2b-nhh/test-createanewtimeserieswidgetwithincidentanalyticsdatasource-1721746799-with-i","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"incident_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"},"id":4216078110414841}],"notify_list":null,"created_at":"2024-07-23T14:59:59.491800+00:00","modified_at":"2024-07-23T14:59:59.491800+00:00","reflow_type":"auto","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/r29-a2b-nhh
31+
response:
32+
body:
33+
string: '{"deleted_dashboard_id":"r29-a2b-nhh"}
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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ Feature: Dashboards
830830
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "ci_tests"
831831
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"
832832

833+
@team:DataDog/dashboards-backend
834+
Scenario: Create a new timeseries widget with incident_analytics data source
835+
Given new "CreateDashboard" request
836+
And body with value {"title":"{{ unique }} with incident_analytics datasource","widgets":[{"definition":{"title":"","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"formulas":[{"formula":"query1"}],"queries":[{"data_source":"incident_analytics","name":"query1","search":{"query":"test_level:test"},"indexes":["*"],"compute":{"aggregation":"count"},"group_by":[]}],"response_format":"timeseries","style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]}}],"layout_type":"ordered","reflow_type":"auto"}
837+
When the request is sent
838+
Then the response status is 200 OK
839+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "incident_analytics"
840+
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"
841+
833842
@generated @skip @team:DataDog/dashboards-backend
834843
Scenario: Create a shared dashboard returns "Bad Request" response
835844
Given new "CreatePublicDashboard" request

0 commit comments

Comments
 (0)