Skip to content

Commit 4737a8f

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add pagination method for NDM ListDevices. (#2837)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 81f7cae commit 4737a8f

File tree

112 files changed

+297
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+297
-218
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2025-05-06 19:21:55.406687",
8-
"spec_repo_commit": "1faa96a2"
7+
"regenerated": "2025-05-07 17:07:25.236674",
8+
"spec_repo_commit": "a1235a0d"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-06 19:21:55.422474",
13-
"spec_repo_commit": "1faa96a2"
12+
"regenerated": "2025-05-07 17:07:25.253013",
13+
"spec_repo_commit": "a1235a0d"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50925,22 +50925,8 @@ paths:
5092550925
description: Get the list of devices.
5092650926
operationId: ListDevices
5092750927
parameters:
50928-
- description: The page number to fetch.
50929-
example: 0
50930-
in: query
50931-
name: page[number]
50932-
required: false
50933-
schema:
50934-
format: int64
50935-
type: integer
50936-
- description: The number of devices to return per page.
50937-
example: 10
50938-
in: query
50939-
name: page[size]
50940-
required: false
50941-
schema:
50942-
format: int64
50943-
type: integer
50928+
- $ref: '#/components/parameters/PageSize'
50929+
- $ref: '#/components/parameters/PageNumber'
5094450930
- description: The field to sort the devices by.
5094550931
example: status
5094650932
in: query
@@ -50971,6 +50957,10 @@ paths:
5097150957
summary: Get the list of devices
5097250958
tags:
5097350959
- Network Device Monitoring
50960+
x-pagination:
50961+
limitParam: page[size]
50962+
pageParam: page[number]
50963+
resultsPath: data
5097450964
/api/v2/ndm/devices/{device_id}:
5097550965
get:
5097650966
description: Get the device details.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Get the list of devices returns "OK" response with pagination
2+
3+
import com.datadog.api.client.ApiClient;
4+
import com.datadog.api.client.PaginationIterable;
5+
import com.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;
6+
import com.datadog.api.client.v2.model.DevicesListData;
7+
8+
public class Example {
9+
public static void main(String[] args) {
10+
ApiClient defaultClient = ApiClient.getDefaultApiClient();
11+
NetworkDeviceMonitoringApi apiInstance = new NetworkDeviceMonitoringApi(defaultClient);
12+
13+
try {
14+
PaginationIterable<DevicesListData> iterable = apiInstance.listDevicesWithPagination();
15+
16+
for (DevicesListData item : iterable) {
17+
System.out.println(item);
18+
}
19+
} catch (RuntimeException e) {
20+
System.err.println(
21+
"Exception when calling NetworkDeviceMonitoringApi#listDevicesWithPagination");
22+
System.err.println("Reason: " + e.getMessage());
23+
e.printStackTrace();
24+
}
25+
}
26+
}

src/main/java/com/datadog/api/client/v2/api/NetworkDeviceMonitoringApi.java

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import com.datadog.api.client.ApiClient;
44
import com.datadog.api.client.ApiException;
55
import com.datadog.api.client.ApiResponse;
6+
import com.datadog.api.client.PaginationIterable;
67
import com.datadog.api.client.Pair;
8+
import com.datadog.api.client.v2.model.DevicesListData;
79
import com.datadog.api.client.v2.model.GetDeviceResponse;
810
import com.datadog.api.client.v2.model.GetInterfacesResponse;
911
import com.datadog.api.client.v2.model.ListDevicesResponse;
@@ -12,6 +14,7 @@
1214
import jakarta.ws.rs.core.GenericType;
1315
import java.util.ArrayList;
1416
import java.util.HashMap;
17+
import java.util.LinkedHashMap;
1518
import java.util.List;
1619
import java.util.Map;
1720
import java.util.concurrent.CompletableFuture;
@@ -374,30 +377,31 @@ public CompletableFuture<ApiResponse<GetInterfacesResponse>> getInterfacesWithHt
374377

375378
/** Manage optional parameters to listDevices. */
376379
public static class ListDevicesOptionalParameters {
377-
private Long pageNumber;
378380
private Long pageSize;
381+
private Long pageNumber;
379382
private String sort;
380383
private String filterTag;
381384

382385
/**
383-
* Set pageNumber.
386+
* Set pageSize.
384387
*
385-
* @param pageNumber The page number to fetch. (optional)
388+
* @param pageSize Size for a given page. The maximum allowed value is 100. (optional, default
389+
* to 10)
386390
* @return ListDevicesOptionalParameters
387391
*/
388-
public ListDevicesOptionalParameters pageNumber(Long pageNumber) {
389-
this.pageNumber = pageNumber;
392+
public ListDevicesOptionalParameters pageSize(Long pageSize) {
393+
this.pageSize = pageSize;
390394
return this;
391395
}
392396

393397
/**
394-
* Set pageSize.
398+
* Set pageNumber.
395399
*
396-
* @param pageSize The number of devices to return per page. (optional)
400+
* @param pageNumber Specific page number to return. (optional, default to 0)
397401
* @return ListDevicesOptionalParameters
398402
*/
399-
public ListDevicesOptionalParameters pageSize(Long pageSize) {
400-
this.pageSize = pageSize;
403+
public ListDevicesOptionalParameters pageNumber(Long pageNumber) {
404+
this.pageNumber = pageNumber;
401405
return this;
402406
}
403407

@@ -482,6 +486,59 @@ public CompletableFuture<ListDevicesResponse> listDevicesAsync(
482486
});
483487
}
484488

489+
/**
490+
* Get the list of devices.
491+
*
492+
* <p>See {@link #listDevicesWithHttpInfo}.
493+
*
494+
* @return PaginationIterable&lt;DevicesListData&gt;
495+
*/
496+
public PaginationIterable<DevicesListData> listDevicesWithPagination() {
497+
ListDevicesOptionalParameters parameters = new ListDevicesOptionalParameters();
498+
return listDevicesWithPagination(parameters);
499+
}
500+
501+
/**
502+
* Get the list of devices.
503+
*
504+
* <p>See {@link #listDevicesWithHttpInfo}.
505+
*
506+
* @return ListDevicesResponse
507+
*/
508+
public PaginationIterable<DevicesListData> listDevicesWithPagination(
509+
ListDevicesOptionalParameters parameters) {
510+
String resultsPath = "getData";
511+
String valueGetterPath = "";
512+
String valueSetterPath = "pageNumber";
513+
Boolean valueSetterParamOptional = true;
514+
parameters.pageNumber(0l);
515+
Long limit;
516+
517+
if (parameters.pageSize == null) {
518+
limit = 10l;
519+
parameters.pageSize(limit);
520+
} else {
521+
limit = parameters.pageSize;
522+
}
523+
524+
LinkedHashMap<String, Object> args = new LinkedHashMap<String, Object>();
525+
args.put("optionalParams", parameters);
526+
527+
PaginationIterable iterator =
528+
new PaginationIterable(
529+
this,
530+
"listDevices",
531+
resultsPath,
532+
valueGetterPath,
533+
valueSetterPath,
534+
valueSetterParamOptional,
535+
false,
536+
limit,
537+
args);
538+
539+
return iterator;
540+
}
541+
485542
/**
486543
* Get the list of devices.
487544
*
@@ -501,8 +558,8 @@ public CompletableFuture<ListDevicesResponse> listDevicesAsync(
501558
public ApiResponse<ListDevicesResponse> listDevicesWithHttpInfo(
502559
ListDevicesOptionalParameters parameters) throws ApiException {
503560
Object localVarPostBody = null;
504-
Long pageNumber = parameters.pageNumber;
505561
Long pageSize = parameters.pageSize;
562+
Long pageNumber = parameters.pageNumber;
506563
String sort = parameters.sort;
507564
String filterTag = parameters.filterTag;
508565
// create path and map variables
@@ -511,8 +568,8 @@ public ApiResponse<ListDevicesResponse> listDevicesWithHttpInfo(
511568
List<Pair> localVarQueryParams = new ArrayList<Pair>();
512569
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
513570

514-
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));
515571
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize));
572+
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));
516573
localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort));
517574
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[tag]", filterTag));
518575

@@ -547,8 +604,8 @@ public ApiResponse<ListDevicesResponse> listDevicesWithHttpInfo(
547604
public CompletableFuture<ApiResponse<ListDevicesResponse>> listDevicesWithHttpInfoAsync(
548605
ListDevicesOptionalParameters parameters) {
549606
Object localVarPostBody = null;
550-
Long pageNumber = parameters.pageNumber;
551607
Long pageSize = parameters.pageSize;
608+
Long pageNumber = parameters.pageNumber;
552609
String sort = parameters.sort;
553610
String filterTag = parameters.filterTag;
554611
// create path and map variables
@@ -557,8 +614,8 @@ public CompletableFuture<ApiResponse<ListDevicesResponse>> listDevicesWithHttpIn
557614
List<Pair> localVarQueryParams = new ArrayList<Pair>();
558615
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
559616

560-
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));
561617
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize));
618+
localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber));
562619
localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort));
563620
localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[tag]", filterTag));
564621

src/test/resources/cassettes/features/v1/Get_all_hosts_with_metadata_deserializes_successfully.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"timeToLive": {
2929
"unlimited": true
3030
},
31-
"id": "d5bade64-6ebb-4f4d-903d-8069b52bb31e"
31+
"id": "d5bade64-6ebb-4f4d-903d-8069b52bb31d"
3232
}
3333
]

src/test/resources/cassettes/features/v1/Get_all_hosts_with_metadata_for_your_organization_returns_OK_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"timeToLive": {
2929
"unlimited": true
3030
},
31-
"id": "d5bade64-6ebb-4f4d-903d-8069b52bb31d"
31+
"id": "d5bade64-6ebb-4f4d-903d-8069b52bb31e"
3232
}
3333
]

src/test/resources/cassettes/features/v1/Validate_API_key_returns_Forbidden_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"timeToLive": {
2424
"unlimited": true
2525
},
26-
"id": "3f83caea-c405-97df-c554-ee2d9f9e4f02"
26+
"id": "3f83caea-c405-97df-c554-ee2d9f9e4f01"
2727
}
2828
]

src/test/resources/cassettes/features/v1/Validate_API_key_returns_OK_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"timeToLive": {
2424
"unlimited": true
2525
},
26-
"id": "3f83caea-c405-97df-c554-ee2d9f9e4f01"
26+
"id": "3f83caea-c405-97df-c554-ee2d9f9e4f02"
2727
}
2828
]

src/test/resources/cassettes/features/v2/AWS_Integration_Create_account_config_returns_AWS_Account_object_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "c206b9cd-771e-14f0-5d18-42a3a48556ce"
30+
"id": "c206b9cd-771e-14f0-5d18-42a3a48556d1"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_Create_account_config_returns_Conflict_response.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eee"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9ee9"
3131
},
3232
{
3333
"httpRequest": {
@@ -57,7 +57,7 @@
5757
"timeToLive": {
5858
"unlimited": true
5959
},
60-
"id": "c206b9cd-771e-14f0-5d18-42a3a48556d1"
60+
"id": "c206b9cd-771e-14f0-5d18-42a3a48556ce"
6161
},
6262
{
6363
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_Delete_account_config_returns_Bad_Request_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"timeToLive": {
2424
"unlimited": true
2525
},
26-
"id": "73fd406e-d686-10bd-50ee-83f2c499e8a8"
26+
"id": "73fd406e-d686-10bd-50ee-83f2c499e8a9"
2727
}
2828
]

src/test/resources/cassettes/features/v2/AWS_Integration_Delete_account_config_returns_No_Content_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eeb"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eea"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_Delete_account_config_returns_Not_Found_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eec"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eed"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_Generate_new_external_ID_returns_AWS_External_ID_object_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"timeToLive": {
2424
"unlimited": true
2525
},
26-
"id": "a3ebb722-60eb-fa89-589a-ff3630e3a2cc"
26+
"id": "a3ebb722-60eb-fa89-589a-ff3630e3a2cd"
2727
}
2828
]

src/test/resources/cassettes/features/v2/AWS_Integration_Get_account_config_returns_AWS_Account_object_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eed"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eee"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_List_available_namespaces_returns_AWS_Namespaces_List_object_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@
2323
"timeToLive": {
2424
"unlimited": true
2525
},
26-
"id": "d0ec7736-ef6c-d071-3390-4a5c3a301d11"
26+
"id": "d0ec7736-ef6c-d071-3390-4a5c3a301d0e"
2727
}
2828
]

src/test/resources/cassettes/features/v2/AWS_Integration_Patch_account_config_returns_AWS_Account_object_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eea"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eec"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/AWS_Integration_Patch_account_config_returns_Bad_Request_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9ee9"
30+
"id": "194b15fb-fcae-9b9a-e1a7-0daa19dc9eeb"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/Archive_case_returns_Bad_Request_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "0a6534d0-42f2-5075-64f8-7ab28f449a8f"
30+
"id": "0a6534d0-42f2-5075-64f8-7ab28f449a95"
3131
},
3232
{
3333
"httpRequest": {

src/test/resources/cassettes/features/v2/Archive_case_returns_OK_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"timeToLive": {
2828
"unlimited": true
2929
},
30-
"id": "0a6534d0-42f2-5075-64f8-7ab28f449a8e"
30+
"id": "0a6534d0-42f2-5075-64f8-7ab28f449a90"
3131
},
3232
{
3333
"httpRequest": {

0 commit comments

Comments
 (0)