Skip to content

Commit 5db0eb9

Browse files
Add pageStart extension to case management pagination (DataDog#3874)
1 parent 5dc6905 commit 5db0eb9

7 files changed

Lines changed: 51 additions & 4 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75976,6 +75976,7 @@ paths:
7597675976
x-pagination:
7597775977
limitParam: page[size]
7597875978
pageParam: page[number]
75979+
pageStart: 1
7597975980
resultsPath: data
7598075981
post:
7598175982
description: Create a Case

.generator/src/generator/templates/api.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func (a *{{ classname }}) {{ operation.operationId }}WithPagination(ctx _context
370370
{{ get_container(operation, pagination.limitParam) }} = &pageSize_
371371
{%- if pagination.pageParam %}
372372
{%- set pageType = get_container_type(operation, pagination.pageParam) %}
373-
page_ := {{ pageType }}(0)
373+
page_ := {{ pageType }}({{ pagination.pageStart | default(0) }})
374374
{{ get_container(operation, pagination.pageParam) }} = &page_
375375
{%- endif %}
376376
{%- endif %}

api/datadogV2/api_case_management.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ func (a *CaseManagementApi) SearchCasesWithPagination(ctx _context.Context, o ..
18071807
pageSize_ = *o[0].PageSize
18081808
}
18091809
o[0].PageSize = &pageSize_
1810-
page_ := int64(0)
1810+
page_ := int64(1)
18111811
o[0].PageNumber = &page_
18121812

18131813
items := make(chan datadog.PaginationResult[Case], pageSize_)

examples/v2/case-management/SearchCases_3433960044.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
configuration := datadog.NewConfiguration()
1818
apiClient := datadog.NewAPIClient(configuration)
1919
api := datadogV2.NewCaseManagementApi(apiClient)
20-
resp, _ := api.SearchCasesWithPagination(ctx, *datadogV2.NewSearchCasesOptionalParameters())
20+
resp, _ := api.SearchCasesWithPagination(ctx, *datadogV2.NewSearchCasesOptionalParameters().WithPageSize(2).WithFilter("status:closed"))
2121

2222
for paginationResult := range resp {
2323
if paginationResult.Error != nil {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T10:29:24.893Z
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
interactions:
2+
- request:
3+
body: ''
4+
form: {}
5+
headers:
6+
Accept:
7+
- application/json
8+
id: 0
9+
method: GET
10+
url: https://api.datadoghq.com/api/v2/cases?page%5Bsize%5D=2&page%5Bnumber%5D=1&filter=status%3Aclosed
11+
response:
12+
body: '{"data":[{"id":"cd4abeaa-0a5b-4b83-b99c-5b6d1f912938","type":"case","attributes":{"attributes":{"service":["synthetics-browser"]},"closed_at":"2026-01-24T00:47:45.477244496Z","comment_count":0,"created_at":"2025-11-12T00:42:59.178125Z","created_by_author":{"type":"USER","content":{"ID":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
13+
Account","email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","active":true}},"creation_source":"ERROR_TRACKING","custom_attributes":{},"description":"","insights":[{"type":"ERROR_TRACKING","ref":"/error-tracking?issueId=a5bb2896-a4d0-11f0-bd76-da7ad0900002","resource_id":"a5bb2896-a4d0-11f0-bd76-da7ad0900002"}],"internal_id":"cd4abeaa-0a5b-4b83-b99c-5b6d1f912938","key":"ET-3","merge_status":"NOT_MERGED","modified_at":"2026-02-05T03:58:14.876711989Z","priority":"NOT_DEFINED","public_id":"89979","status":"CLOSED","status_group":"SG_CLOSED","status_name":"Closed","title":"require-trusted-types-for:
14+
csp_violation: ''trusted-types-sink'' blocked by ''require-trusted-types-for''
15+
directive","type":"ERROR_TRACKING_ISSUE","type_id":"00000000-0000-0000-0000-000000000005"},"relationships":{"assignee":{"data":{"id":"87cb11a0-278c-440a-99fe-701223c80296","type":"user"}},"created_by":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user"}},"project":{"data":{"id":"384521ba-dc5f-481f-942d-15bd48428029","type":"project"}}}},{"id":"7afc10c8-4096-4af1-9ccf-ec0df3a2f63b","type":"case","attributes":{"attributes":{"service":["synthetics-browser"]},"comment_count":0,"created_at":"2025-09-02T13:56:48.031226Z","created_by_author":{"type":"USER","content":{"ID":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"frog","email":"frog@datadoghq.com","handle":"frog@datadoghq.com","active":true}},"creation_source":"ERROR_TRACKING","custom_attributes":{},"description":"","insights":[{"type":"ERROR_TRACKING","ref":"/error-tracking?issueId=d3ab59c6-84ee-11f0-87bb-da7ad0900002","resource_id":"d3ab59c6-84ee-11f0-87bb-da7ad0900002"}],"internal_id":"7afc10c8-4096-4af1-9ccf-ec0df3a2f63b","key":"ET-2","merge_status":"NOT_MERGED","modified_at":"2026-03-25T09:56:47.052997427Z","priority":"NOT_DEFINED","public_id":"79361","status":"CLOSED","status_group":"SG_CLOSED","status_name":"Closed","title":"Error:
16+
Expected unhandled error","type":"ERROR_TRACKING_ISSUE","type_id":"00000000-0000-0000-0000-000000000005"},"relationships":{"assignee":{"data":{"id":"87cb11a0-278c-440a-99fe-701223c80296","type":"user"}},"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"384521ba-dc5f-481f-942d-15bd48428029","type":"project"}}}}],"meta":{"total_cases":3,"page":{"current":1,"size":2,"total":2}},"included":[{"id":"87cb11a0-278c-440a-99fe-701223c80296","type":"user","attributes":{"active":false,"email":"","handle":"","name":""}},{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"user","attributes":{"active":true,"email":"team-intg-tools-libs-spam@datadoghq.com","handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","name":"CI
17+
Account"}},{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}}]}'
18+
code: 200
19+
duration: 0ms
20+
headers:
21+
Content-Type:
22+
- application/vnd.api+json
23+
status: 200 OK
24+
- request:
25+
body: ''
26+
form: {}
27+
headers:
28+
Accept:
29+
- application/json
30+
id: 1
31+
method: GET
32+
url: https://api.datadoghq.com/api/v2/cases?page%5Bsize%5D=2&page%5Bnumber%5D=2&filter=status%3Aclosed
33+
response:
34+
body: '{"data":[{"id":"f1b32a47-621d-4c57-9642-045aeb83891e","type":"case","attributes":{"attributes":{"service":["synthetics-browser"]},"closed_at":"2025-08-21T17:21:13.882830862Z","comment_count":0,"created_at":"2025-08-21T17:20:22.807979Z","created_by_author":{"type":"USER","content":{"ID":"3ad549bf-eba0-11e9-a77a-0705486660d0","name":"frog","email":"frog@datadoghq.com","handle":"frog@datadoghq.com","active":true}},"creation_source":"ERROR_TRACKING","custom_attributes":{},"description":"","insights":[{"type":"ERROR_TRACKING","ref":"/error-tracking?issueId=5f8ebd5c-6dd9-11f0-8a28-da7ad0900002","resource_id":"5f8ebd5c-6dd9-11f0-8a28-da7ad0900002"}],"internal_id":"f1b32a47-621d-4c57-9642-045aeb83891e","key":"ET-1","merge_status":"NOT_MERGED","modified_at":"2025-08-21T17:21:13.882830862Z","priority":"NOT_DEFINED","public_id":"77795","status":"CLOSED","status_group":"SG_CLOSED","status_name":"Closed","title":"Error:
35+
HTTP error","type":"ERROR_TRACKING_ISSUE","type_id":"00000000-0000-0000-0000-000000000005"},"relationships":{"assignee":{"data":{"id":"87cb11a0-278c-440a-99fe-701223c80296","type":"user"}},"created_by":{"data":{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user"}},"project":{"data":{"id":"384521ba-dc5f-481f-942d-15bd48428029","type":"project"}}}}],"meta":{"total_cases":3,"page":{"current":2,"size":1,"total":2}},"included":[{"id":"3ad549bf-eba0-11e9-a77a-0705486660d0","type":"user","attributes":{"active":true,"email":"frog@datadoghq.com","handle":"frog@datadoghq.com","name":"frog"}},{"id":"87cb11a0-278c-440a-99fe-701223c80296","type":"user","attributes":{"active":false,"email":"","handle":"","name":""}}]}'
36+
code: 200
37+
duration: 0ms
38+
headers:
39+
Content-Type:
40+
- application/vnd.api+json
41+
status: 200 OK
42+
version: 2

tests/scenarios/features/v2/case_management.feature

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,14 @@ Feature: Case Management
508508
When the request is sent
509509
Then the response status is 200 OK
510510

511-
@generated @skip @team:DataDog/case-management @with-pagination
511+
@replay-only @skip-validation @team:DataDog/case-management @with-pagination
512512
Scenario: Search cases returns "OK" response with pagination
513513
Given new "SearchCases" request
514+
And request contains "page[size]" parameter with value 2
515+
And request contains "filter" parameter with value "status:closed"
514516
When the request with pagination is sent
515517
Then the response status is 200 OK
518+
And the response has 3 items
516519

517520
@team:DataDog/case-management
518521
Scenario: Unarchive case returns "Bad Request" response

0 commit comments

Comments
 (0)