Skip to content

Commit 50c0d2c

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 9f1d06e4 of spec repo
1 parent 825234b commit 50c0d2c

File tree

6 files changed

+47
-24
lines changed

6 files changed

+47
-24
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 09:33:55.410949",
8-
"spec_repo_commit": "77cf469a"
7+
"regenerated": "2025-05-05 22:04:05.606466",
8+
"spec_repo_commit": "9f1d06e4"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-02 09:33:55.426962",
13-
"spec_repo_commit": "77cf469a"
12+
"regenerated": "2025-05-05 22:04:05.623507",
13+
"spec_repo_commit": "9f1d06e4"
1414
}
1515
}
1616
}

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 16 deletions
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.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Get the list of devices returns "OK" response with pagination
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.new
5+
api_instance.list_devices_with_pagination() { |item| puts item }

features/scenarios_model_mapping.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,8 @@
20132013
"body" => "MonitorConfigPolicyEditRequest",
20142014
},
20152015
"v2.ListDevices" => {
2016-
"page_number" => "Integer",
20172016
"page_size" => "Integer",
2017+
"page_number" => "Integer",
20182018
"sort" => "String",
20192019
"filter_tag" => "String",
20202020
},

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

lib/datadog_api_client/v2/api/network_device_monitoring_api.rb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ def list_devices(opts = {})
169169
# Get the list of devices.
170170
#
171171
# @param opts [Hash] the optional parameters
172-
# @option opts [Integer] :page_number The page number to fetch.
173-
# @option opts [Integer] :page_size The number of devices to return per page.
172+
# @option opts [Integer] :page_size Size for a given page. The maximum allowed value is 100.
173+
# @option opts [Integer] :page_number Specific page number to return.
174174
# @option opts [String] :sort The field to sort the devices by.
175175
# @option opts [String] :filter_tag Filter devices by tag.
176176
# @return [Array<(ListDevicesResponse, Integer, Hash)>] ListDevicesResponse data, response status code and response headers
@@ -184,8 +184,8 @@ def list_devices_with_http_info(opts = {})
184184

185185
# query parameters
186186
query_params = opts[:query_params] || {}
187-
query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
188187
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
188+
query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
189189
query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
190190
query_params[:'filter[tag]'] = opts[:'filter_tag'] if !opts[:'filter_tag'].nil?
191191

@@ -224,6 +224,28 @@ def list_devices_with_http_info(opts = {})
224224
return data, status_code, headers
225225
end
226226

227+
# Get the list of devices.
228+
#
229+
# Provide a paginated version of {#list_devices}, returning all items.
230+
#
231+
# To use it you need to use a block: list_devices_with_pagination { |item| p item }
232+
#
233+
# @yield [DevicesListData] Paginated items
234+
def list_devices_with_pagination(opts = {})
235+
api_version = "V2"
236+
page_size = @api_client.get_attribute_from_path(opts, "page_size", 10)
237+
@api_client.set_attribute_from_path(api_version, opts, "page_size", Integer, page_size)
238+
@api_client.set_attribute_from_path(api_version, opts, "page_number", Integer, 0)
239+
while true do
240+
response = list_devices(opts)
241+
@api_client.get_attribute_from_path(response, "data").each { |item| yield(item) }
242+
if @api_client.get_attribute_from_path(response, "data").length < page_size
243+
break
244+
end
245+
@api_client.set_attribute_from_path(api_version, opts, "page_number", Integer, @api_client.get_attribute_from_path(opts, "page_number", 0) + 1)
246+
end
247+
end
248+
227249
# Get the list of tags for a device.
228250
#
229251
# @see #list_device_user_tags_with_http_info

0 commit comments

Comments
 (0)