|
| 1 | +""" |
| 2 | +Create a new dashboard with timeseries widget using has_value_labels |
| 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.timeseries_request_style import TimeseriesRequestStyle |
| 10 | +from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition |
| 11 | +from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType |
| 12 | +from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest |
| 13 | +from datadog_api_client.v1.model.widget import Widget |
| 14 | +from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType |
| 15 | +from datadog_api_client.v1.model.widget_line_type import WidgetLineType |
| 16 | +from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth |
| 17 | + |
| 18 | +body = Dashboard( |
| 19 | + layout_type=DashboardLayoutType.ORDERED, |
| 20 | + title="Example-Dashboard with has_value_labels", |
| 21 | + widgets=[ |
| 22 | + Widget( |
| 23 | + definition=TimeseriesWidgetDefinition( |
| 24 | + type=TimeseriesWidgetDefinitionType.TIMESERIES, |
| 25 | + requests=[ |
| 26 | + TimeseriesWidgetRequest( |
| 27 | + q="avg:system.cpu.user{*} by {host}", |
| 28 | + style=TimeseriesRequestStyle( |
| 29 | + palette="dog_classic", |
| 30 | + line_type=WidgetLineType.SOLID, |
| 31 | + line_width=WidgetLineWidth.NORMAL, |
| 32 | + has_value_labels=True, |
| 33 | + ), |
| 34 | + display_type=WidgetDisplayType.LINE, |
| 35 | + ), |
| 36 | + ], |
| 37 | + ), |
| 38 | + ), |
| 39 | + ], |
| 40 | +) |
| 41 | + |
| 42 | +configuration = Configuration() |
| 43 | +with ApiClient(configuration) as api_client: |
| 44 | + api_instance = DashboardsApi(api_client) |
| 45 | + response = api_instance.create_dashboard(body=body) |
| 46 | + |
| 47 | + print(response) |
0 commit comments