|
| 1 | +""" |
| 2 | +Clients deserialize a dashboard with a empty time object |
| 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.formula_and_function_cloud_cost_data_source import ( |
| 10 | + FormulaAndFunctionCloudCostDataSource, |
| 11 | +) |
| 12 | +from datadog_api_client.v1.model.formula_and_function_cloud_cost_query_definition import ( |
| 13 | + FormulaAndFunctionCloudCostQueryDefinition, |
| 14 | +) |
| 15 | +from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat |
| 16 | +from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition |
| 17 | +from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType |
| 18 | +from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest |
| 19 | +from datadog_api_client.v1.model.widget import Widget |
| 20 | +from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType |
| 21 | +from datadog_api_client.v1.model.widget_formula import WidgetFormula |
| 22 | +from datadog_api_client.v1.model.widget_legacy_live_span import WidgetLegacyLiveSpan |
| 23 | +from datadog_api_client.v1.model.widget_line_type import WidgetLineType |
| 24 | +from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth |
| 25 | +from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle |
| 26 | +from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign |
| 27 | + |
| 28 | +body = Dashboard( |
| 29 | + title="Example-Dashboard", |
| 30 | + widgets=[ |
| 31 | + Widget( |
| 32 | + definition=TimeseriesWidgetDefinition( |
| 33 | + title="Example Cloud Cost Query", |
| 34 | + title_size="16", |
| 35 | + title_align=WidgetTextAlign.LEFT, |
| 36 | + type=TimeseriesWidgetDefinitionType.TIMESERIES, |
| 37 | + requests=[ |
| 38 | + TimeseriesWidgetRequest( |
| 39 | + formulas=[ |
| 40 | + WidgetFormula( |
| 41 | + formula="query1", |
| 42 | + ), |
| 43 | + ], |
| 44 | + queries=[ |
| 45 | + FormulaAndFunctionCloudCostQueryDefinition( |
| 46 | + data_source=FormulaAndFunctionCloudCostDataSource.CLOUD_COST, |
| 47 | + name="query1", |
| 48 | + query="sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)", |
| 49 | + ), |
| 50 | + ], |
| 51 | + response_format=FormulaAndFunctionResponseFormat.TIMESERIES, |
| 52 | + style=WidgetRequestStyle( |
| 53 | + palette="dog_classic", |
| 54 | + line_type=WidgetLineType.SOLID, |
| 55 | + line_width=WidgetLineWidth.NORMAL, |
| 56 | + ), |
| 57 | + display_type=WidgetDisplayType.BARS, |
| 58 | + ), |
| 59 | + ], |
| 60 | + time=WidgetLegacyLiveSpan(), |
| 61 | + ), |
| 62 | + ), |
| 63 | + ], |
| 64 | + layout_type=DashboardLayoutType.ORDERED, |
| 65 | +) |
| 66 | + |
| 67 | +configuration = Configuration() |
| 68 | +with ApiClient(configuration) as api_client: |
| 69 | + api_instance = DashboardsApi(api_client) |
| 70 | + response = api_instance.create_dashboard(body=body) |
| 71 | + |
| 72 | + print(response) |
0 commit comments