Skip to content

Commit c154716

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 7ed109b2 of spec repo
1 parent 5f4b128 commit c154716

File tree

6 files changed

+92
-30
lines changed

6 files changed

+92
-30
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:06:00.944093",
8-
"spec_repo_commit": "d0ee626b"
7+
"regenerated": "2025-05-06 16:27:14.423277",
8+
"spec_repo_commit": "7ed109b2"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-06 15:06:00.959289",
13-
"spec_repo_commit": "d0ee626b"
12+
"regenerated": "2025-05-06 16:27:14.440050",
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.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
with ApiClient(configuration) as api_client:
1010
api_instance = NetworkDeviceMonitoringApi(api_client)
1111
response = api_instance.list_devices(
12-
page_number=0,
1312
page_size=1,
13+
page_number=0,
1414
filter_tag="device_namespace:default",
1515
)
1616

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
Get the list of devices returns "OK" response with pagination
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.network_device_monitoring_api import NetworkDeviceMonitoringApi
7+
8+
configuration = Configuration()
9+
with ApiClient(configuration) as api_client:
10+
api_instance = NetworkDeviceMonitoringApi(api_client)
11+
items = api_instance.list_devices_with_pagination()
12+
for item in items:
13+
print(item)

src/datadog_api_client/v2/api/network_device_monitoring_api.py

+62-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
# Copyright 2019-Present Datadog, Inc.
44
from __future__ import annotations
55

6+
import collections
67
from typing import Any, Dict, Union
78

89
from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint
910
from datadog_api_client.configuration import Configuration
1011
from datadog_api_client.model_utils import (
12+
set_attribute_from_path,
13+
get_attribute_from_path,
1114
UnsetType,
1215
unset,
1316
)
1417
from datadog_api_client.v2.model.list_devices_response import ListDevicesResponse
18+
from datadog_api_client.v2.model.devices_list_data import DevicesListData
1519
from datadog_api_client.v2.model.get_device_response import GetDeviceResponse
1620
from datadog_api_client.v2.model.get_interfaces_response import GetInterfacesResponse
1721
from datadog_api_client.v2.model.list_tags_response import ListTagsResponse
@@ -88,14 +92,14 @@ def __init__(self, api_client=None):
8892
"version": "v2",
8993
},
9094
params_map={
91-
"page_number": {
95+
"page_size": {
9296
"openapi_types": (int,),
93-
"attribute": "page[number]",
97+
"attribute": "page[size]",
9498
"location": "query",
9599
},
96-
"page_size": {
100+
"page_number": {
97101
"openapi_types": (int,),
98-
"attribute": "page[size]",
102+
"attribute": "page[number]",
99103
"location": "query",
100104
},
101105
"sort": {
@@ -208,39 +212,88 @@ def get_interfaces(
208212
def list_devices(
209213
self,
210214
*,
211-
page_number: Union[int, UnsetType] = unset,
212215
page_size: Union[int, UnsetType] = unset,
216+
page_number: Union[int, UnsetType] = unset,
213217
sort: Union[str, UnsetType] = unset,
214218
filter_tag: Union[str, UnsetType] = unset,
215219
) -> ListDevicesResponse:
216220
"""Get the list of devices.
217221
218222
Get the list of devices.
219223
220-
:param page_number: The page number to fetch.
221-
:type page_number: int, optional
222-
:param page_size: The number of devices to return per page.
224+
:param page_size: Size for a given page. The maximum allowed value is 100.
223225
:type page_size: int, optional
226+
:param page_number: Specific page number to return.
227+
:type page_number: int, optional
224228
:param sort: The field to sort the devices by.
225229
:type sort: str, optional
226230
:param filter_tag: Filter devices by tag.
227231
:type filter_tag: str, optional
228232
:rtype: ListDevicesResponse
229233
"""
230234
kwargs: Dict[str, Any] = {}
235+
if page_size is not unset:
236+
kwargs["page_size"] = page_size
237+
231238
if page_number is not unset:
232239
kwargs["page_number"] = page_number
233240

241+
if sort is not unset:
242+
kwargs["sort"] = sort
243+
244+
if filter_tag is not unset:
245+
kwargs["filter_tag"] = filter_tag
246+
247+
return self._list_devices_endpoint.call_with_http_info(**kwargs)
248+
249+
def list_devices_with_pagination(
250+
self,
251+
*,
252+
page_size: Union[int, UnsetType] = unset,
253+
page_number: Union[int, UnsetType] = unset,
254+
sort: Union[str, UnsetType] = unset,
255+
filter_tag: Union[str, UnsetType] = unset,
256+
) -> collections.abc.Iterable[DevicesListData]:
257+
"""Get the list of devices.
258+
259+
Provide a paginated version of :meth:`list_devices`, returning all items.
260+
261+
:param page_size: Size for a given page. The maximum allowed value is 100.
262+
:type page_size: int, optional
263+
:param page_number: Specific page number to return.
264+
:type page_number: int, optional
265+
:param sort: The field to sort the devices by.
266+
:type sort: str, optional
267+
:param filter_tag: Filter devices by tag.
268+
:type filter_tag: str, optional
269+
270+
:return: A generator of paginated results.
271+
:rtype: collections.abc.Iterable[DevicesListData]
272+
"""
273+
kwargs: Dict[str, Any] = {}
234274
if page_size is not unset:
235275
kwargs["page_size"] = page_size
236276

277+
if page_number is not unset:
278+
kwargs["page_number"] = page_number
279+
237280
if sort is not unset:
238281
kwargs["sort"] = sort
239282

240283
if filter_tag is not unset:
241284
kwargs["filter_tag"] = filter_tag
242285

243-
return self._list_devices_endpoint.call_with_http_info(**kwargs)
286+
local_page_size = get_attribute_from_path(kwargs, "page_size", 10)
287+
endpoint = self._list_devices_endpoint
288+
set_attribute_from_path(kwargs, "page_size", local_page_size, endpoint.params_map)
289+
pagination = {
290+
"limit_value": local_page_size,
291+
"results_path": "data",
292+
"page_param": "page_number",
293+
"endpoint": endpoint,
294+
"kwargs": kwargs,
295+
}
296+
return endpoint.call_with_http_info_paginated(pagination)
244297

245298
def list_device_user_tags(
246299
self,

tests/v2/features/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

0 commit comments

Comments
 (0)