Skip to content

Commit 81ed4e8

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit 7e023f1d of spec repo
1 parent 17d1de4 commit 81ed4e8

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 04:31:13.587503",
8-
"spec_repo_commit": "272cce39"
7+
"regenerated": "2025-05-02 20:46:06.351468",
8+
"spec_repo_commit": "7e023f1d"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2025-05-02 04:31:13.603582",
13-
"spec_repo_commit": "272cce39"
12+
"regenerated": "2025-05-02 20:46:06.367616",
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: 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)