Skip to content

Update NDM GetInterfaces documentation to add get_ip_addresses param #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-04-14 08:41:51.365494",
"spec_repo_commit": "e73254d7"
"regenerated": "2025-04-14 16:33:06.797040",
"spec_repo_commit": "c0287407"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-04-14 08:41:51.382445",
"spec_repo_commit": "e73254d7"
"regenerated": "2025-04-14 16:33:06.813573",
"spec_repo_commit": "c0287407"
}
}
}
7 changes: 7 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46074,6 +46074,13 @@ paths:
required: true
schema:
type: string
- description: Whether to get the IP addresses of the interfaces.
example: true
in: query
name: get_ip_addresses
required: false
schema:
type: boolean
responses:
'200':
content:
Expand Down
8 changes: 7 additions & 1 deletion examples/v2_network-device-monitoring_GetInterfaces.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// Get the list of interfaces of the device returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_network_device_monitoring::GetInterfacesOptionalParams;
use datadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;

#[tokio::main]
async fn main() {
let configuration = datadog::Configuration::new();
let api = NetworkDeviceMonitoringAPI::with_config(configuration);
let resp = api.get_interfaces("default:1.2.3.4".to_string()).await;
let resp = api
.get_interfaces(
"default:1.2.3.4".to_string(),
GetInterfacesOptionalParams::default().get_ip_addresses(true),
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
Expand Down
27 changes: 26 additions & 1 deletion src/datadogV2/api/api_network_device_monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ use reqwest::header::{HeaderMap, HeaderValue};
use serde::{Deserialize, Serialize};
use std::io::Write;

/// GetInterfacesOptionalParams is a struct for passing parameters to the method [`NetworkDeviceMonitoringAPI::get_interfaces`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct GetInterfacesOptionalParams {
/// Whether to get the IP addresses of the interfaces.
pub get_ip_addresses: Option<bool>,
}

impl GetInterfacesOptionalParams {
/// Whether to get the IP addresses of the interfaces.
pub fn get_ip_addresses(mut self, value: bool) -> Self {
self.get_ip_addresses = Some(value);
self
}
}

/// ListDevicesOptionalParams is a struct for passing parameters to the method [`NetworkDeviceMonitoringAPI::list_devices`]
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
Expand Down Expand Up @@ -260,9 +276,10 @@ impl NetworkDeviceMonitoringAPI {
pub async fn get_interfaces(
&self,
device_id: String,
params: GetInterfacesOptionalParams,
) -> Result<crate::datadogV2::model::GetInterfacesResponse, datadog::Error<GetInterfacesError>>
{
match self.get_interfaces_with_http_info(device_id).await {
match self.get_interfaces_with_http_info(device_id, params).await {
Ok(response_content) => {
if let Some(e) = response_content.entity {
Ok(e)
Expand All @@ -280,13 +297,17 @@ impl NetworkDeviceMonitoringAPI {
pub async fn get_interfaces_with_http_info(
&self,
device_id: String,
params: GetInterfacesOptionalParams,
) -> Result<
datadog::ResponseContent<crate::datadogV2::model::GetInterfacesResponse>,
datadog::Error<GetInterfacesError>,
> {
let local_configuration = &self.config;
let operation_id = "v2.get_interfaces";

// unbox and build optional parameters
let get_ip_addresses = params.get_ip_addresses;

let local_client = &self.client;

let local_uri_str = format!(
Expand All @@ -297,6 +318,10 @@ impl NetworkDeviceMonitoringAPI {
local_client.request(reqwest::Method::GET, local_uri_str.as_str());

local_req_builder = local_req_builder.query(&[("device_id", &device_id.to_string())]);
if let Some(ref local_query_param) = get_ip_addresses {
local_req_builder =
local_req_builder.query(&[("get_ip_addresses", &local_query_param.to_string())]);
};

// build headers
let mut headers = HeaderMap::new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-07-05T14:25:54.313Z
2025-04-09T22:39:12.378Z
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"method": "get",
"uri": "https://api.datadoghq.com/api/v2/ndm/interfaces?device_id=default:1.2.3.4"
"uri": "https://api.datadoghq.com/api/v2/ndm/interfaces?device_id=default%3A1.2.3.4&get_ip_addresses=true"
},
"response": {
"body": {
Expand All @@ -26,7 +26,7 @@
"message": "OK"
}
},
"recorded_at": "Fri, 05 Jul 2024 14:25:54 GMT"
"recorded_at": "Wed, 09 Apr 2025 22:39:12 GMT"
}
],
"recorded_with": "VCR 6.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Feature: Network Device Monitoring
Scenario: Get the list of interfaces of the device returns "OK" response
Given new "GetInterfaces" request
And request contains "device_id" parameter with value "default:1.2.3.4"
And request contains "get_ip_addresses" parameter with value true
When the request is sent
Then the response status is 200 OK
And the response "data[0].type" is equal to "interface"
Expand Down
8 changes: 7 additions & 1 deletion tests/scenarios/function_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19630,7 +19630,13 @@ fn test_v2_get_interfaces(world: &mut DatadogWorld, _parameters: &HashMap<String
.as_ref()
.expect("api instance not found");
let device_id = serde_json::from_value(_parameters.get("device_id").unwrap().clone()).unwrap();
let response = match block_on(api.get_interfaces_with_http_info(device_id)) {
let get_ip_addresses = _parameters
.get("get_ip_addresses")
.and_then(|param| Some(serde_json::from_value(param.clone()).unwrap()));
let mut params =
datadogV2::api_network_device_monitoring::GetInterfacesOptionalParams::default();
params.get_ip_addresses = get_ip_addresses;
let response = match block_on(api.get_interfaces_with_http_info(device_id, params)) {
Ok(response) => response,
Err(error) => {
return match error {
Expand Down
Loading