-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
- Loading branch information
1 parent
9dc3887
commit 4210af3
Showing
7 changed files
with
159 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
""" | ||
Create a new timeseries widget with ci_pipelines data source | ||
""" | ||
|
||
from datadog_api_client import ApiClient, Configuration | ||
from datadog_api_client.v1.api.dashboards_api import DashboardsApi | ||
from datadog_api_client.v1.model.dashboard import Dashboard | ||
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType | ||
from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType | ||
from datadog_api_client.v1.model.formula_and_function_event_aggregation import FormulaAndFunctionEventAggregation | ||
from datadog_api_client.v1.model.formula_and_function_event_query_definition import ( | ||
FormulaAndFunctionEventQueryDefinition, | ||
) | ||
from datadog_api_client.v1.model.formula_and_function_event_query_definition_compute import ( | ||
FormulaAndFunctionEventQueryDefinitionCompute, | ||
) | ||
from datadog_api_client.v1.model.formula_and_function_event_query_definition_search import ( | ||
FormulaAndFunctionEventQueryDefinitionSearch, | ||
) | ||
from datadog_api_client.v1.model.formula_and_function_events_data_source import FormulaAndFunctionEventsDataSource | ||
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat | ||
from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition | ||
from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType | ||
from datadog_api_client.v1.model.timeseries_widget_legend_column import TimeseriesWidgetLegendColumn | ||
from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout | ||
from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest | ||
from datadog_api_client.v1.model.widget import Widget | ||
from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType | ||
from datadog_api_client.v1.model.widget_formula import WidgetFormula | ||
from datadog_api_client.v1.model.widget_line_type import WidgetLineType | ||
from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth | ||
from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle | ||
from datadog_api_client.v1.model.widget_time import WidgetTime | ||
|
||
body = Dashboard( | ||
title="Example-Create_a_new_timeseries_widget_with_ci_pipelines_data_source with ci_pipelines datasource", | ||
widgets=[ | ||
Widget( | ||
definition=TimeseriesWidgetDefinition( | ||
title="", | ||
show_legend=True, | ||
legend_layout=TimeseriesWidgetLegendLayout.AUTO, | ||
legend_columns=[ | ||
TimeseriesWidgetLegendColumn.AVG, | ||
TimeseriesWidgetLegendColumn.MIN, | ||
TimeseriesWidgetLegendColumn.MAX, | ||
TimeseriesWidgetLegendColumn.VALUE, | ||
TimeseriesWidgetLegendColumn.SUM, | ||
], | ||
time=WidgetTime(), | ||
type=TimeseriesWidgetDefinitionType.TIMESERIES, | ||
requests=[ | ||
TimeseriesWidgetRequest( | ||
formulas=[ | ||
WidgetFormula( | ||
formula="query1", | ||
), | ||
], | ||
queries=[ | ||
FormulaAndFunctionEventQueryDefinition( | ||
data_source=FormulaAndFunctionEventsDataSource.CI_PIPELINES, | ||
name="query1", | ||
search=FormulaAndFunctionEventQueryDefinitionSearch( | ||
query="ci_level:job", | ||
), | ||
indexes=[ | ||
"*", | ||
], | ||
compute=FormulaAndFunctionEventQueryDefinitionCompute( | ||
aggregation=FormulaAndFunctionEventAggregation.COUNT, | ||
metric="@ci.queue_time", | ||
), | ||
group_by=[], | ||
), | ||
], | ||
response_format=FormulaAndFunctionResponseFormat.TIMESERIES, | ||
style=WidgetRequestStyle( | ||
palette="dog_classic", | ||
line_type=WidgetLineType.SOLID, | ||
line_width=WidgetLineWidth.NORMAL, | ||
), | ||
display_type=WidgetDisplayType.LINE, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
layout_type=DashboardLayoutType.ORDERED, | ||
reflow_type=DashboardReflowType.AUTO, | ||
) | ||
|
||
configuration = Configuration() | ||
with ApiClient(configuration) as api_client: | ||
api_instance = DashboardsApi(api_client) | ||
response = api_instance.create_dashboard(body=body) | ||
|
||
print(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...s/test_scenarios/test_create_a_new_timeseries_widget_with_ci_pipelines_data_source.frozen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2023-03-02T15:41:16.500Z |
42 changes: 42 additions & 0 deletions
42
...tes/test_scenarios/test_create_a_new_timeseries_widget_with_ci_pipelines_data_source.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
interactions: | ||
- request: | ||
body: '{"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_ci_pipelines_data_source-1677771676 | ||
with ci_pipelines datasource","widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count","metric":"@ci.queue_time"},"data_source":"ci_pipelines","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"ci_level:job"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"}}]}' | ||
headers: | ||
accept: | ||
- application/json | ||
content-type: | ||
- application/json | ||
method: POST | ||
uri: https://api.datadoghq.com/api/v1/dashboard | ||
response: | ||
body: | ||
string: '{"id":"iu9-viw-buz","title":"Test-Create_a_new_timeseries_widget_with_ci_pipelines_data_source-1677771676 | ||
with ci_pipelines datasource","description":null,"author_handle":"frog@datadoghq.com","author_name":null,"layout_type":"ordered","url":"/dashboard/iu9-viw-buz/test-createanewtimeserieswidgetwithcipipelinesdatasource-1677771676-with-cipipel","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","metric":"@ci.queue_time"},"data_source":"ci_pipelines","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"ci_level:job"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"},"id":2105687409669278}],"notify_list":null,"created_at":"2023-03-02T15:41:16.697612+00:00","modified_at":"2023-03-02T15:41:16.697612+00:00","reflow_type":"auto","restricted_roles":[]} | ||
' | ||
headers: | ||
content-type: | ||
- application/json | ||
status: | ||
code: 200 | ||
message: OK | ||
- request: | ||
body: null | ||
headers: | ||
accept: | ||
- application/json | ||
method: DELETE | ||
uri: https://api.datadoghq.com/api/v1/dashboard/iu9-viw-buz | ||
response: | ||
body: | ||
string: '{"deleted_dashboard_id":"iu9-viw-buz"} | ||
' | ||
headers: | ||
content-type: | ||
- application/json | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters