Skip to content

Commit

Permalink
Add week_to_date and month_to_date to widget livespan (#1768)
Browse files Browse the repository at this point in the history
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
api-clients-generation-pipeline[bot] and ci.datadog-api-spec authored Nov 20, 2023
1 parent 7efdeda commit 237cd1b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2023-11-17 20:28:38.988410",
"spec_repo_commit": "7fb616ae"
"regenerated": "2023-11-20 19:20:13.651946",
"spec_repo_commit": "55cf29a4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2023-11-17 20:28:39.002128",
"spec_repo_commit": "7fb616ae"
"regenerated": "2023-11-20 19:20:13.666926",
"spec_repo_commit": "55cf29a4"
}
}
}
4 changes: 4 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20955,6 +20955,8 @@ components:
- 1mo
- 3mo
- 6mo
- week_to_date
- month_to_date
- 1y
- alert
example: 5m
Expand All @@ -20973,6 +20975,8 @@ components:
- PAST_ONE_MONTH
- PAST_THREE_MONTHS
- PAST_SIX_MONTHS
- WEEK_TO_DATE
- MONTH_TO_DATE
- PAST_ONE_YEAR
- ALERT
WidgetMargin:
Expand Down
5 changes: 5 additions & 0 deletions examples/v1/dashboards/CreateDashboard_1284514532.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
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_live_span import WidgetLiveSpan
from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle
from datadog_api_client.v1.model.widget_text_align import WidgetTextAlign
from datadog_api_client.v1.model.widget_time import WidgetTime

body = Dashboard(
title="Example-Dashboard",
Expand Down Expand Up @@ -56,6 +58,9 @@
display_type=WidgetDisplayType.BARS,
),
],
time=WidgetTime(
live_span=WidgetLiveSpan.WEEK_TO_DATE,
),
),
),
],
Expand Down
8 changes: 7 additions & 1 deletion src/datadog_api_client/v1/model/widget_live_span.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class WidgetLiveSpan(ModelSimple):
"""
The available timeframes depend on the widget you are using.
:param value: Must be one of ["1m", "5m", "10m", "15m", "30m", "1h", "4h", "1d", "2d", "1w", "1mo", "3mo", "6mo", "1y", "alert"].
:param value: Must be one of ["1m", "5m", "10m", "15m", "30m", "1h", "4h", "1d", "2d", "1w", "1mo", "3mo", "6mo", "week_to_date", "month_to_date", "1y", "alert"].
:type value: str
"""

Expand All @@ -34,6 +34,8 @@ class WidgetLiveSpan(ModelSimple):
"1mo",
"3mo",
"6mo",
"week_to_date",
"month_to_date",
"1y",
"alert",
}
Expand All @@ -50,6 +52,8 @@ class WidgetLiveSpan(ModelSimple):
PAST_ONE_MONTH: ClassVar["WidgetLiveSpan"]
PAST_THREE_MONTHS: ClassVar["WidgetLiveSpan"]
PAST_SIX_MONTHS: ClassVar["WidgetLiveSpan"]
WEEK_TO_DATE: ClassVar["WidgetLiveSpan"]
MONTH_TO_DATE: ClassVar["WidgetLiveSpan"]
PAST_ONE_YEAR: ClassVar["WidgetLiveSpan"]
ALERT: ClassVar["WidgetLiveSpan"]

Expand All @@ -73,5 +77,7 @@ def openapi_types(_):
WidgetLiveSpan.PAST_ONE_MONTH = WidgetLiveSpan("1mo")
WidgetLiveSpan.PAST_THREE_MONTHS = WidgetLiveSpan("3mo")
WidgetLiveSpan.PAST_SIX_MONTHS = WidgetLiveSpan("6mo")
WidgetLiveSpan.WEEK_TO_DATE = WidgetLiveSpan("week_to_date")
WidgetLiveSpan.MONTH_TO_DATE = WidgetLiveSpan("month_to_date")
WidgetLiveSpan.PAST_ONE_YEAR = WidgetLiveSpan("1y")
WidgetLiveSpan.ALERT = WidgetLiveSpan("alert")
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-07-11T14:32:45.409Z
2023-11-14T21:39:19.397Z
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interactions:
- request:
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1689085965","widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*}
by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"title":"Example
body: '{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1699997959","widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*}
by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"time":{"live_span":"week_to_date"},"title":"Example
Cloud Cost Query","title_align":"left","title_size":"16","type":"timeseries"}}]}'
headers:
accept:
Expand All @@ -12,9 +12,10 @@ interactions:
uri: https://api.datadoghq.com/api/v1/dashboard
response:
body:
string: '{"id":"kka-2iz-3jf","title":"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1689085965","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/kka-2iz-3jf/test-createanewdashboardwithatimeserieswidgetusingformulasandfunctionscloudcostq","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*}
by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"title":"Example
Cloud Cost Query","title_align":"left","title_size":"16","type":"timeseries"},"id":1004255439340}],"notify_list":null,"created_at":"2023-07-11T14:32:45.564617+00:00","modified_at":"2023-07-11T14:32:45.564617+00:00","restricted_roles":[]}
string: '{"id":"nh3-n9c-wuz","title":"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_cloud_cost_query-1699997959","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI
Account","layout_type":"ordered","url":"/dashboard/nh3-n9c-wuz/test-createanewdashboardwithatimeserieswidgetusingformulasandfunctionscloudcostq","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"bars","formulas":[{"formula":"query1"}],"queries":[{"data_source":"cloud_cost","name":"query1","query":"sum:aws.cost.amortized{*}
by {aws_product}.rollup(sum, monthly)"}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"time":{"live_span":"week_to_date"},"title":"Example
Cloud Cost Query","title_align":"left","title_size":"16","type":"timeseries"},"id":380165468656457}],"notify_list":null,"created_at":"2023-11-14T21:39:19.798591+00:00","modified_at":"2023-11-14T21:39:19.798591+00:00","restricted_roles":[]}
'
headers:
Expand All @@ -29,10 +30,10 @@ interactions:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/dashboard/kka-2iz-3jf
uri: https://api.datadoghq.com/api/v1/dashboard/nh3-n9c-wuz
response:
body:
string: '{"deleted_dashboard_id":"kka-2iz-3jf"}
string: '{"deleted_dashboard_id":"nh3-n9c-wuz"}
'
headers:
Expand Down
3 changes: 2 additions & 1 deletion tests/v1/features/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,15 @@ Feature: Dashboards
@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with a timeseries widget using formulas and functions cloud cost query
Given new "CreateDashboard" request
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ] } } ], "layout_type": "ordered" }
And body with value { "title": "{{ unique }}", "widgets": [ { "definition": { "title": "Example Cloud Cost Query", "title_size": "16", "title_align": "left", "type": "timeseries", "requests": [ { "formulas": [ { "formula": "query1" } ], "queries": [ { "data_source": "cloud_cost", "name": "query1", "query": "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)" } ], "response_format": "timeseries", "style": { "palette": "dog_classic", "line_type": "solid", "line_width": "normal" }, "display_type": "bars" } ], "time": { "live_span": "week_to_date" } } } ], "layout_type": "ordered" }
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.requests[0].response_format" is equal to "timeseries"
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "cloud_cost"
And the response "widgets[0].definition.requests[0].queries[0].name" is equal to "query1"
And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "sum:aws.cost.amortized{*} by {aws_product}.rollup(sum, monthly)"
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1"
And the response "widgets[0].definition.time.live_span" is equal to "week_to_date"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with alert_graph widget
Expand Down

0 comments on commit 237cd1b

Please sign in to comment.