Skip to content

Commit 2a77ede

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 7e023f1d of spec repo
1 parent 4bb4b2b commit 2a77ede

File tree

5 files changed

+112
-33
lines changed

5 files changed

+112
-33
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-02 04:31:10.898749",
8-
"spec_repo_commit": "272cce39"
7+
"regenerated": "2025-05-02 20:46:09.170182",
8+
"spec_repo_commit": "7e023f1d"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-02 04:31:10.915000",
13-
"spec_repo_commit": "272cce39"
12+
"regenerated": "2025-05-02 20:46:09.185776",
13+
"spec_repo_commit": "7e023f1d"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50567,22 +50567,8 @@ paths:
5056750567
description: Get the list of devices.
5056850568
operationId: ListDevices
5056950569
parameters:
50570-
- description: The page number to fetch.
50571-
example: 0
50572-
in: query
50573-
name: page[number]
50574-
required: false
50575-
schema:
50576-
format: int64
50577-
type: integer
50578-
- description: The number of devices to return per page.
50579-
example: 10
50580-
in: query
50581-
name: page[size]
50582-
required: false
50583-
schema:
50584-
format: int64
50585-
type: integer
50570+
- $ref: '#/components/parameters/PageSize'
50571+
- $ref: '#/components/parameters/PageNumber'
5058650572
- description: The field to sort the devices by.
5058750573
example: status
5058850574
in: query
@@ -50613,6 +50599,10 @@ paths:
5061350599
summary: Get the list of devices
5061450600
tags:
5061550601
- Network Device Monitoring
50602+
x-pagination:
50603+
limitParam: page[size]
50604+
pageParam: page[number]
50605+
resultsPath: data
5061650606
/api/v2/ndm/devices/{device_id}:
5061750607
get:
5061850608
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/com/datadog/api/client/v2/api/network_device_monitoring.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ Feature: Network Device Monitoring
7575
And the response "data[0].attributes.interface_statuses.down" is equal to 13
7676
And the response "meta.page.total_filtered_count" is equal to 1
7777

78+
@generated @skip @team:DataDog/network-device-monitoring @with-pagination
79+
Scenario: Get the list of devices returns "OK" response with pagination
80+
Given new "ListDevices" request
81+
When the request with pagination is sent
82+
Then the response status is 200 OK
83+
7884
@replay-only @team:DataDog/network-device-monitoring
7985
Scenario: Get the list of interfaces of the device returns "OK" response
8086
Given new "GetInterfaces" request

0 commit comments

Comments
 (0)