diff --git a/.apigentools-info b/.apigentools-info index f34893fe30f..ac4963db991 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-22 20:03:19.855082", - "spec_repo_commit": "cd020fa6" + "regenerated": "2024-07-23 15:33:48.760135", + "spec_repo_commit": "015355f6" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-22 20:03:19.873734", - "spec_repo_commit": "cd020fa6" + "regenerated": "2024-07-23 15:33:48.778613", + "spec_repo_commit": "015355f6" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 7749ad8b460..cef095c02fe 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -2867,6 +2867,7 @@ components: - events - ci_tests - ci_pipelines + - incident_analytics example: logs type: string x-enum-varnames: @@ -2880,6 +2881,7 @@ components: - EVENTS - CI_TESTS - CI_PIPELINES + - INCIDENT_ANALYTICS FormulaAndFunctionMetricAggregation: description: The aggregation methods available for metrics queries. enum: diff --git a/api/datadogV1/model_formula_and_function_events_data_source.go b/api/datadogV1/model_formula_and_function_events_data_source.go index 56a3cacf626..ff844620ab4 100644 --- a/api/datadogV1/model_formula_and_function_events_data_source.go +++ b/api/datadogV1/model_formula_and_function_events_data_source.go @@ -15,16 +15,17 @@ type FormulaAndFunctionEventsDataSource string // List of FormulaAndFunctionEventsDataSource. const ( - FORMULAANDFUNCTIONEVENTSDATASOURCE_LOGS FormulaAndFunctionEventsDataSource = "logs" - FORMULAANDFUNCTIONEVENTSDATASOURCE_SPANS FormulaAndFunctionEventsDataSource = "spans" - FORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK FormulaAndFunctionEventsDataSource = "network" - FORMULAANDFUNCTIONEVENTSDATASOURCE_RUM FormulaAndFunctionEventsDataSource = "rum" - FORMULAANDFUNCTIONEVENTSDATASOURCE_SECURITY_SIGNALS FormulaAndFunctionEventsDataSource = "security_signals" - FORMULAANDFUNCTIONEVENTSDATASOURCE_PROFILES FormulaAndFunctionEventsDataSource = "profiles" - FORMULAANDFUNCTIONEVENTSDATASOURCE_AUDIT FormulaAndFunctionEventsDataSource = "audit" - FORMULAANDFUNCTIONEVENTSDATASOURCE_EVENTS FormulaAndFunctionEventsDataSource = "events" - FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_TESTS FormulaAndFunctionEventsDataSource = "ci_tests" - FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_PIPELINES FormulaAndFunctionEventsDataSource = "ci_pipelines" + FORMULAANDFUNCTIONEVENTSDATASOURCE_LOGS FormulaAndFunctionEventsDataSource = "logs" + FORMULAANDFUNCTIONEVENTSDATASOURCE_SPANS FormulaAndFunctionEventsDataSource = "spans" + FORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK FormulaAndFunctionEventsDataSource = "network" + FORMULAANDFUNCTIONEVENTSDATASOURCE_RUM FormulaAndFunctionEventsDataSource = "rum" + FORMULAANDFUNCTIONEVENTSDATASOURCE_SECURITY_SIGNALS FormulaAndFunctionEventsDataSource = "security_signals" + FORMULAANDFUNCTIONEVENTSDATASOURCE_PROFILES FormulaAndFunctionEventsDataSource = "profiles" + FORMULAANDFUNCTIONEVENTSDATASOURCE_AUDIT FormulaAndFunctionEventsDataSource = "audit" + FORMULAANDFUNCTIONEVENTSDATASOURCE_EVENTS FormulaAndFunctionEventsDataSource = "events" + FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_TESTS FormulaAndFunctionEventsDataSource = "ci_tests" + FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_PIPELINES FormulaAndFunctionEventsDataSource = "ci_pipelines" + FORMULAANDFUNCTIONEVENTSDATASOURCE_INCIDENT_ANALYTICS FormulaAndFunctionEventsDataSource = "incident_analytics" ) var allowedFormulaAndFunctionEventsDataSourceEnumValues = []FormulaAndFunctionEventsDataSource{ @@ -38,6 +39,7 @@ var allowedFormulaAndFunctionEventsDataSourceEnumValues = []FormulaAndFunctionEv FORMULAANDFUNCTIONEVENTSDATASOURCE_EVENTS, FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_TESTS, FORMULAANDFUNCTIONEVENTSDATASOURCE_CI_PIPELINES, + FORMULAANDFUNCTIONEVENTSDATASOURCE_INCIDENT_ANALYTICS, } // GetAllowedValues reeturns the list of possible values. diff --git a/examples/v1/dashboards/CreateDashboard_985012506.go b/examples/v1/dashboards/CreateDashboard_985012506.go new file mode 100644 index 00000000000..9b3fdc84033 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_985012506.go @@ -0,0 +1,86 @@ +// Create a new timeseries widget with incident_analytics data source + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + Title: "Example-Dashboard with incident_analytics datasource", + Widgets: []datadogV1.Widget{ + { + Definition: datadogV1.WidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Title: datadog.PtrString(""), + ShowLegend: datadog.PtrBool(true), + LegendLayout: datadogV1.TIMESERIESWIDGETLEGENDLAYOUT_AUTO.Ptr(), + LegendColumns: []datadogV1.TimeseriesWidgetLegendColumn{ + datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_AVG, + datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_MIN, + datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_MAX, + datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_VALUE, + datadogV1.TIMESERIESWIDGETLEGENDCOLUMN_SUM, + }, + Time: &datadogV1.WidgetTime{}, + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + Formulas: []datadogV1.WidgetFormula{ + { + Formula: "query1", + }, + }, + Queries: []datadogV1.FormulaAndFunctionQueryDefinition{ + datadogV1.FormulaAndFunctionQueryDefinition{ + FormulaAndFunctionEventQueryDefinition: &datadogV1.FormulaAndFunctionEventQueryDefinition{ + DataSource: datadogV1.FORMULAANDFUNCTIONEVENTSDATASOURCE_INCIDENT_ANALYTICS, + Name: "query1", + Search: &datadogV1.FormulaAndFunctionEventQueryDefinitionSearch{ + Query: "test_level:test", + }, + Indexes: []string{ + "*", + }, + Compute: datadogV1.FormulaAndFunctionEventQueryDefinitionCompute{ + Aggregation: datadogV1.FORMULAANDFUNCTIONEVENTAGGREGATION_COUNT, + }, + GroupBy: []datadogV1.FormulaAndFunctionEventQueryGroupBy{}, + }}, + }, + ResponseFormat: datadogV1.FORMULAANDFUNCTIONRESPONSEFORMAT_TIMESERIES.Ptr(), + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("dog_classic"), + LineType: datadogV1.WIDGETLINETYPE_SOLID.Ptr(), + LineWidth: datadogV1.WIDGETLINEWIDTH_NORMAL.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(), + }, + }, + }}, + }, + }, + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + ReflowType: datadogV1.DASHBOARDREFLOWTYPE_AUTO.Ptr(), + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.freeze new file mode 100644 index 00000000000..4db9b8d383e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.freeze @@ -0,0 +1 @@ +2024-07-23T14:59:59.215Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.yaml new file mode 100644 index 00000000000..270f5b089e5 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_timeseries_widget_with_incident_analytics_data_source.yaml @@ -0,0 +1,44 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 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"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"r29-a2b-nhh","title":"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 + with incident_analytics datasource","description":null,"author_handle":"frog@datadoghq.com","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":[]} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/r29-a2b-nhh + response: + body: '{"deleted_dashboard_id":"r29-a2b-nhh"} + + ' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index 1f42aa8f072..b892e9da84d 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -830,6 +830,15 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "ci_tests" And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test" + @team:DataDog/dashboards-backend + Scenario: Create a new timeseries widget with incident_analytics data source + Given new "CreateDashboard" request + 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"} + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "incident_analytics" + And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test" + @generated @skip @team:DataDog/dashboards-backend Scenario: Create a shared dashboard returns "Bad Request" response Given new "CreatePublicDashboard" request