diff --git a/.apigentools-info b/.apigentools-info index 2681fd6c45f..08a02b9544a 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -3,14 +3,14 @@ "info_version": "2", "spec_versions": { "v1": { - "apigentools_version": "1.5.1.dev2", - "regenerated": "2022-01-17 16:31:46.250333", - "spec_repo_commit": "9f83d50" + "apigentools_version": "1.6.1", + "regenerated": "2022-01-18 10:09:27.902001", + "spec_repo_commit": "a78f06e" }, "v2": { - "apigentools_version": "1.5.1.dev2", - "regenerated": "2022-01-17 16:31:46.277137", - "spec_repo_commit": "9f83d50" + "apigentools_version": "1.6.1", + "regenerated": "2022-01-18 10:09:27.916870", + "spec_repo_commit": "a78f06e" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index f93b5e6d6bd..a8f5ce9ade6 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -16576,6 +16576,14 @@ paths: required: false schema: type: boolean + - description: 'When `true`, this query returns only deleted custom-created + + or cloned dashboards. This parameter is incompatible with `filter[shared]`.' + in: query + name: filter[deleted] + required: false + schema: + type: boolean responses: '200': content: @@ -16981,6 +16989,12 @@ paths: summary: Delete a dashboard tags: - Dashboards + x-given: + deleted_dashboard: + parameters: + - name: dashboard_id + source: dashboard.id + step: the "dashboard" was deleted x-menu-order: 3 x-undo: type: idempotent diff --git a/api/v1/datadog/api_dashboards.go b/api/v1/datadog/api_dashboards.go index 47e1f1960f1..d5718395ec5 100644 --- a/api/v1/datadog/api_dashboards.go +++ b/api/v1/datadog/api_dashboards.go @@ -678,13 +678,15 @@ func (a *DashboardsApiService) getDashboardExecute(r apiGetDashboardRequest) (Da } type apiListDashboardsRequest struct { - ctx _context.Context - ApiService *DashboardsApiService - filterShared *bool + ctx _context.Context + ApiService *DashboardsApiService + filterShared *bool + filterDeleted *bool } type ListDashboardsOptionalParameters struct { - FilterShared *bool + FilterShared *bool + FilterDeleted *bool } func NewListDashboardsOptionalParameters() *ListDashboardsOptionalParameters { @@ -695,6 +697,10 @@ func (r *ListDashboardsOptionalParameters) WithFilterShared(filterShared bool) * r.FilterShared = &filterShared return r } +func (r *ListDashboardsOptionalParameters) WithFilterDeleted(filterDeleted bool) *ListDashboardsOptionalParameters { + r.FilterDeleted = &filterDeleted + return r +} /* * ListDashboards Get all dashboards @@ -716,6 +722,7 @@ func (a *DashboardsApiService) ListDashboards(ctx _context.Context, o ...ListDas if o != nil { req.filterShared = o[0].FilterShared + req.filterDeleted = o[0].FilterDeleted } return req.ApiService.listDashboardsExecute(req) @@ -749,6 +756,9 @@ func (a *DashboardsApiService) listDashboardsExecute(r apiListDashboardsRequest) if r.filterShared != nil { localVarQueryParams.Add("filter[shared]", parameterToString(*r.filterShared, "")) } + if r.filterDeleted != nil { + localVarQueryParams.Add("filter[deleted]", parameterToString(*r.filterDeleted, "")) + } // to determine the Content-Type header localVarHTTPContentTypes := []string{} diff --git a/api/v1/datadog/docs/DashboardsApi.md b/api/v1/datadog/docs/DashboardsApi.md index 53af59694a6..3de856493ec 100644 --- a/api/v1/datadog/docs/DashboardsApi.md +++ b/api/v1/datadog/docs/DashboardsApi.md @@ -299,8 +299,10 @@ func main() { ctx := datadog.NewDefaultContext(context.Background()) filterShared := true // bool | When `true`, this query only returns shared custom created or cloned dashboards. (optional) + filterDeleted := true // bool | When `true`, this query returns only deleted custom-created or cloned dashboards. This parameter is incompatible with `filter[shared]`. (optional) optionalParams := datadog.ListDashboardsOptionalParameters{ FilterShared: &filterShared, + FilterDeleted: &filterDeleted, } configuration := datadog.NewConfiguration() @@ -323,9 +325,10 @@ func main() { Other parameters are passed through a pointer to a ListDashboardsOptionalParameters struct. -| Name | Type | Description | Notes | -| ---------------- | -------- | ------------------------------------------------------------------------------------------ | ----- | -| **filterShared** | **bool** | When `true`, this query only returns shared custom created or cloned dashboards. | +| Name | Type | Description | Notes | +| ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | +| **filterShared** | **bool** | When `true`, this query only returns shared custom created or cloned dashboards. | +| **filterDeleted** | **bool** | When `true`, this query returns only deleted custom-created or cloned dashboards. This parameter is incompatible with `filter[shared]`. | ### Return type diff --git a/examples/v1/dashboards/ListDashboards_1773932563.go b/examples/v1/dashboards/ListDashboards_1773932563.go new file mode 100644 index 00000000000..41c3813d9a6 --- /dev/null +++ b/examples/v1/dashboards/ListDashboards_1773932563.go @@ -0,0 +1,27 @@ +// Get deleted dashboards returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + resp, r, err := apiClient.DashboardsApi.ListDashboards(ctx, *datadog.NewListDashboardsOptionalParameters().WithFilterDeleted(true)) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.ListDashboards`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.ListDashboards`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.freeze new file mode 100644 index 00000000000..997f40ab47d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-01-17T17:43:33.193Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.yaml new file mode 100644 index 00000000000..9f7f956365b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Get_deleted_dashboards_returns_OK_response.yaml @@ -0,0 +1,71 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","title":"Test-Get_deleted_dashboards_returns_OK_response-1642441413 with Profile Metrics Query","widgets":[{"definition":{"requests":[{"profile_metrics_query":{"compute":{"aggregation":"sum","facet":"@prof_core_cpu_cores"},"group_by":[{"facet":"service","limit":10,"sort":{"aggregation":"sum","facet":"@prof_core_cpu_cores","order":"desc"}}],"search":{"query":"runtime:jvm"}}}],"type":"timeseries"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"notify_list":null,"description":null,"restricted_roles":[],"author_name":null,"template_variables":null,"is_read_only":false,"id":"ssn-gb2-k7k","title":"Test-Get_deleted_dashboards_returns_OK_response-1642441413 + with Profile Metrics Query","url":"/dashboard/ssn-gb2-k7k/test-getdeleteddashboardsreturnsokresponse-1642441413-with-profile-metrics-query","created_at":"2022-01-17T17:43:33.361797+00:00","modified_at":"2022-01-17T17:43:33.361797+00:00","author_handle":"frog@datadoghq.com","widgets":[{"definition":{"requests":[{"profile_metrics_query":{"search":{"query":"runtime:jvm"},"group_by":[{"facet":"service","sort":{"facet":"@prof_core_cpu_cores","aggregation":"sum","order":"desc"},"limit":10}],"compute":{"facet":"@prof_core_cpu_cores","aggregation":"sum"}}}],"type":"timeseries"},"id":748946470803570}],"layout_type":"ordered"}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/ssn-gb2-k7k + response: + body: '{"deleted_dashboard_id":"ssn-gb2-k7k"}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: GET + url: https://api.datadoghq.com/api/v1/dashboard?filter%5Bdeleted%5D=true + response: + body: '{"dashboards":[{"created_at":"2022-01-17T17:43:33.361797+00:00","author_handle":"frog@datadoghq.com","is_read_only":false,"description":null,"title":"Test-Get_deleted_dashboards_returns_OK_response-1642441413 + with Profile Metrics Query","url":"/dashboard/ssn-gb2-k7k/test-getdeleteddashboardsreturnsokresponse-1642441413-with-profile-metrics-query","layout_type":"ordered","deleted_at":"2022-01-17T17:43:33.502200+00:00","modified_at":"2022-01-17T17:43:33.361797+00:00","id":"ssn-gb2-k7k"}]}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/ssn-gb2-k7k + response: + body: '{"errors": ["Dashboard with ID ssn-gb2-k7k not found"]}' + code: 404 + duration: '' + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 1 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index e1c14adc9fe..bc73e839433 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -432,6 +432,15 @@ Feature: Dashboards When the request is sent Then the response status is 200 OK + @team:DataDog/dashboards + Scenario: Get deleted dashboards returns "OK" response + Given new "ListDashboards" request + And there is a valid "dashboard" in the system + And the "dashboard" was deleted + And request contains "filter[deleted]" parameter with value true + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/dashboards Scenario: Restore deleted dashboards returns "Bad Request" response Given new "RestoreDashboards" request diff --git a/tests/scenarios/features/v1/given.json b/tests/scenarios/features/v1/given.json index b4708bfe442..7e90266561e 100644 --- a/tests/scenarios/features/v1/given.json +++ b/tests/scenarios/features/v1/given.json @@ -23,6 +23,18 @@ "tag": "Dashboard Lists", "operationId": "CreateDashboardList" }, + { + "parameters": [ + { + "name": "dashboard_id", + "source": "dashboard.id" + } + ], + "step": "the \"dashboard\" was deleted", + "key": "deleted_dashboard", + "tag": "Dashboards", + "operationId": "DeleteDashboard" + }, { "parameters": [ {