Skip to content

Commit 8db05dc

Browse files
Add pageStart extension to case management pagination (#1412)
1 parent 5655b58 commit 8db05dc

7 files changed

Lines changed: 74 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
@@ -203,7 +203,7 @@ impl {{ structName }} {
203203
{%- if pagination.pageParam %}
204204
{%- set getter, setter, required, schema = get_accessors(operation, pagination.pageParam) %}
205205
if {{ getter }}.is_none() {
206-
{{ setter }} = {% if not required %}Some({% endif %}0{% if not required %}){% endif %};
206+
{{ setter }} = {% if not required %}Some({% endif %}{{ pagination.pageStart | default(0) }}{% if not required %}){% endif %};
207207
}
208208
{%- endif %}
209209
loop {

examples/v2_case-management_SearchCases_3433960044.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ use futures_util::stream::StreamExt;
99
async fn main() {
1010
let configuration = datadog::Configuration::new();
1111
let api = CaseManagementAPI::with_config(configuration);
12-
let response = api.search_cases_with_pagination(SearchCasesOptionalParams::default());
12+
let response = api.search_cases_with_pagination(
13+
SearchCasesOptionalParams::default()
14+
.page_size(2)
15+
.filter("status:closed".to_string()),
16+
);
1317
pin_mut!(response);
1418
while let Some(resp) = response.next().await {
1519
if let Ok(value) = resp {

src/datadogV2/api/api_case_management.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3045,7 +3045,7 @@ impl CaseManagementAPI {
30453045
page_size = params.page_size.unwrap().clone();
30463046
}
30473047
if params.page_number.is_none() {
3048-
params.page_number = Some(0);
3048+
params.page_number = Some(1);
30493049
}
30503050
loop {
30513051
let resp = self.search_cases(params.clone()).await?;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2026-03-25T10:29:24.893Z
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"http_interactions": [
3+
{
4+
"request": {
5+
"body": "",
6+
"headers": {
7+
"Accept": [
8+
"application/json"
9+
]
10+
},
11+
"method": "get",
12+
"uri": "https://api.datadoghq.com/api/v2/cases?page%5Bsize%5D=2&page%5Bnumber%5D=1&filter=status%3Aclosed"
13+
},
14+
"response": {
15+
"body": {
16+
"string": "{\"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 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: csp_violation: 'trusted-types-sink' blocked by 'require-trusted-types-for' 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: 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 Account\"}},{\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"type\":\"user\",\"attributes\":{\"active\":true,\"email\":\"frog@datadoghq.com\",\"handle\":\"frog@datadoghq.com\",\"name\":\"frog\"}}]}",
17+
"encoding": null
18+
},
19+
"headers": {
20+
"Content-Type": [
21+
"application/vnd.api+json"
22+
]
23+
},
24+
"status": {
25+
"code": 200,
26+
"message": "OK"
27+
}
28+
},
29+
"recorded_at": "Wed, 25 Mar 2026 10:29:24 GMT"
30+
},
31+
{
32+
"request": {
33+
"body": "",
34+
"headers": {
35+
"Accept": [
36+
"application/json"
37+
]
38+
},
39+
"method": "get",
40+
"uri": "https://api.datadoghq.com/api/v2/cases?page%5Bsize%5D=2&page%5Bnumber%5D=2&filter=status%3Aclosed"
41+
},
42+
"response": {
43+
"body": {
44+
"string": "{\"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: 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\":\"\"}}]}",
45+
"encoding": null
46+
},
47+
"headers": {
48+
"Content-Type": [
49+
"application/vnd.api+json"
50+
]
51+
},
52+
"status": {
53+
"code": 200,
54+
"message": "OK"
55+
}
56+
},
57+
"recorded_at": "Wed, 25 Mar 2026 10:29:24 GMT"
58+
}
59+
],
60+
"recorded_with": "VCR 6.0.0"
61+
}

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)