Skip to content

Commit eb622b8

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 7ed109b2 of spec repo
1 parent 180396b commit eb622b8

File tree

7 files changed

+93
-35
lines changed

7 files changed

+93
-35
lines changed

.apigentools-info

+4-4
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 15:05:57.976406",
8-
"spec_repo_commit": "d0ee626b"
7+
"regenerated": "2025-05-06 16:27:18.556547",
8+
"spec_repo_commit": "7ed109b2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-06 15:05:57.992373",
13-
"spec_repo_commit": "d0ee626b"
12+
"regenerated": "2025-05-06 16:27:18.572671",
13+
"spec_repo_commit": "7ed109b2"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

+6-16
Original file line numberDiff line numberDiff line change
@@ -50924,22 +50924,8 @@ paths:
5092450924
description: Get the list of devices.
5092550925
operationId: ListDevices
5092650926
parameters:
50927-
- description: The page number to fetch.
50928-
example: 0
50929-
in: query
50930-
name: page[number]
50931-
required: false
50932-
schema:
50933-
format: int64
50934-
type: integer
50935-
- description: The number of devices to return per page.
50936-
example: 10
50937-
in: query
50938-
name: page[size]
50939-
required: false
50940-
schema:
50941-
format: int64
50942-
type: integer
50927+
- $ref: '#/components/parameters/PageSize'
50928+
- $ref: '#/components/parameters/PageNumber'
5094350929
- description: The field to sort the devices by.
5094450930
example: status
5094550931
in: query
@@ -50970,6 +50956,10 @@ paths:
5097050956
summary: Get the list of devices
5097150957
tags:
5097250958
- Network Device Monitoring
50959+
x-pagination:
50960+
limitParam: page[size]
50961+
pageParam: page[number]
50962+
resultsPath: data
5097350963
/api/v2/ndm/devices/{device_id}:
5097450964
get:
5097550965
description: Get the device details.

examples/v2/network-device-monitoring/ListDevices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const configuration = client.createConfiguration();
88
const apiInstance = new v2.NetworkDeviceMonitoringApi(configuration);
99

1010
const params: v2.NetworkDeviceMonitoringApiListDevicesRequest = {
11-
pageNumber: 0,
1211
pageSize: 1,
12+
pageNumber: 0,
1313
filterTag: "device_namespace:default",
1414
};
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Get the list of devices returns "OK" response with pagination
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.NetworkDeviceMonitoringApi(configuration);
9+
10+
(async () => {
11+
try {
12+
for await (const item of apiInstance.listDevicesWithPagination()) {
13+
console.log(item);
14+
}
15+
} catch (error) {
16+
console.error(error);
17+
}
18+
})();

features/support/scenarios_model_mapping.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5714,11 +5714,11 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
57145714
"operationResponseType": "MonitorConfigPolicyResponse",
57155715
},
57165716
"v2.ListDevices": {
5717-
"pageNumber": {
5717+
"pageSize": {
57185718
"type": "number",
57195719
"format": "int64",
57205720
},
5721-
"pageSize": {
5721+
"pageNumber": {
57225722
"type": "number",
57235723
"format": "int64",
57245724
},

features/v2/network_device_monitoring.feature

+6
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

packages/datadog-api-client-v2/apis/NetworkDeviceMonitoringApi.ts

+56-12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ObjectSerializer } from "../models/ObjectSerializer";
1717
import { ApiException } from "../../datadog-api-client-common/exception";
1818

1919
import { APIErrorResponse } from "../models/APIErrorResponse";
20+
import { DevicesListData } from "../models/DevicesListData";
2021
import { GetDeviceResponse } from "../models/GetDeviceResponse";
2122
import { GetInterfacesResponse } from "../models/GetInterfacesResponse";
2223
import { ListDevicesResponse } from "../models/ListDevicesResponse";
@@ -104,8 +105,8 @@ export class NetworkDeviceMonitoringApiRequestFactory extends BaseAPIRequestFact
104105
}
105106

106107
public async listDevices(
107-
pageNumber?: number,
108108
pageSize?: number,
109+
pageNumber?: number,
109110
sort?: string,
110111
filterTag?: string,
111112
_options?: Configuration
@@ -123,17 +124,17 @@ export class NetworkDeviceMonitoringApiRequestFactory extends BaseAPIRequestFact
123124
requestContext.setHttpConfig(_config.httpConfig);
124125

125126
// Query Params
126-
if (pageNumber !== undefined) {
127+
if (pageSize !== undefined) {
127128
requestContext.setQueryParam(
128-
"page[number]",
129-
ObjectSerializer.serialize(pageNumber, "number", "int64"),
129+
"page[size]",
130+
ObjectSerializer.serialize(pageSize, "number", "int64"),
130131
""
131132
);
132133
}
133-
if (pageSize !== undefined) {
134+
if (pageNumber !== undefined) {
134135
requestContext.setQueryParam(
135-
"page[size]",
136-
ObjectSerializer.serialize(pageSize, "number", "int64"),
136+
"page[number]",
137+
ObjectSerializer.serialize(pageNumber, "number", "int64"),
137138
""
138139
);
139140
}
@@ -576,15 +577,15 @@ export interface NetworkDeviceMonitoringApiGetInterfacesRequest {
576577

577578
export interface NetworkDeviceMonitoringApiListDevicesRequest {
578579
/**
579-
* The page number to fetch.
580+
* Size for a given page. The maximum allowed value is 100.
580581
* @type number
581582
*/
582-
pageNumber?: number;
583+
pageSize?: number;
583584
/**
584-
* The number of devices to return per page.
585+
* Specific page number to return.
585586
* @type number
586587
*/
587-
pageSize?: number;
588+
pageNumber?: number;
588589
/**
589590
* The field to sort the devices by.
590591
* @type string
@@ -687,8 +688,8 @@ export class NetworkDeviceMonitoringApi {
687688
options?: Configuration
688689
): Promise<ListDevicesResponse> {
689690
const requestContextPromise = this.requestFactory.listDevices(
690-
param.pageNumber,
691691
param.pageSize,
692+
param.pageNumber,
692693
param.sort,
693694
param.filterTag,
694695
options
@@ -702,6 +703,49 @@ export class NetworkDeviceMonitoringApi {
702703
});
703704
}
704705

706+
/**
707+
* Provide a paginated version of listDevices returning a generator with all the items.
708+
*/
709+
public async *listDevicesWithPagination(
710+
param: NetworkDeviceMonitoringApiListDevicesRequest = {},
711+
options?: Configuration
712+
): AsyncGenerator<DevicesListData> {
713+
let pageSize = 10;
714+
if (param.pageSize !== undefined) {
715+
pageSize = param.pageSize;
716+
}
717+
param.pageSize = pageSize;
718+
param.pageNumber = 0;
719+
while (true) {
720+
const requestContext = await this.requestFactory.listDevices(
721+
param.pageSize,
722+
param.pageNumber,
723+
param.sort,
724+
param.filterTag,
725+
options
726+
);
727+
const responseContext = await this.configuration.httpApi.send(
728+
requestContext
729+
);
730+
731+
const response = await this.responseProcessor.listDevices(
732+
responseContext
733+
);
734+
const responseData = response.data;
735+
if (responseData === undefined) {
736+
break;
737+
}
738+
const results = responseData;
739+
for (const item of results) {
740+
yield item;
741+
}
742+
if (results.length < pageSize) {
743+
break;
744+
}
745+
param.pageNumber = param.pageNumber + 1;
746+
}
747+
}
748+
705749
/**
706750
* Get the list of tags for a device.
707751
* @param param The request object

0 commit comments

Comments
 (0)