The Network Device Monitoring API allows you to fetch devices and interfaces and their attributes. See the Network Device Monitoring page for more information.
"""
Get the list of devices returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.network_device_monitoring_apiimportNetworkDeviceMonitoringApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=NetworkDeviceMonitoringApi(api_client)response=api_instance.list_devices(page_size=1,page_number=0,filter_tag="device_namespace:default",)print(response)
# Get the list of devices returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.newopts={page_size:1,page_number:0,filter_tag:"device_namespace:default",}papi_instance.list_devices(opts)
// Get the list of devices returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewNetworkDeviceMonitoringApi(apiClient)resp,r,err:=api.ListDevices(ctx,*datadogV2.NewListDevicesOptionalParameters().WithPageSize(1).WithPageNumber(0).WithFilterTag("device_namespace:default"))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `NetworkDeviceMonitoringApi.ListDevices`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `NetworkDeviceMonitoringApi.ListDevices`:\n%s\n",responseContent)}
// Get the list of devices returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi.ListDevicesOptionalParameters;importcom.datadog.api.client.v2.model.ListDevicesResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();NetworkDeviceMonitoringApiapiInstance=newNetworkDeviceMonitoringApi(defaultClient);try{ListDevicesResponseresult=apiInstance.listDevices(newListDevicesOptionalParameters().pageSize(1L).pageNumber(0L).filterTag("device_namespace:default"));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling NetworkDeviceMonitoringApi#listDevices");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get the list of devices returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_network_device_monitoring::ListDevicesOptionalParams;usedatadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=NetworkDeviceMonitoringAPI::with_config(configuration);letresp=api.list_devices(ListDevicesOptionalParams::default().page_size(1).page_number(0).filter_tag("device_namespace:default".to_string()),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get the list of devices returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.NetworkDeviceMonitoringApi(configuration);constparams: v2.NetworkDeviceMonitoringApiListDevicesRequest={pageSize: 1,pageNumber: 0,filterTag:"device_namespace:default",};apiInstance.listDevices(params).then((data: v2.ListDevicesResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get the device details returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.network_device_monitoring_apiimportNetworkDeviceMonitoringApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=NetworkDeviceMonitoringApi(api_client)response=api_instance.get_device(device_id="default_device",)print(response)
# Get the device details returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.newpapi_instance.get_device("default_device")
// Get the device details returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewNetworkDeviceMonitoringApi(apiClient)resp,r,err:=api.GetDevice(ctx,"default_device")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `NetworkDeviceMonitoringApi.GetDevice`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `NetworkDeviceMonitoringApi.GetDevice`:\n%s\n",responseContent)}
// Get the device details returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=NetworkDeviceMonitoringAPI::with_config(configuration);letresp=api.get_device("default_device".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get the device details returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.NetworkDeviceMonitoringApi(configuration);constparams: v2.NetworkDeviceMonitoringApiGetDeviceRequest={deviceId:"default_device",};apiInstance.getDevice(params).then((data: v2.GetDeviceResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get the list of interfaces of the device returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.network_device_monitoring_apiimportNetworkDeviceMonitoringApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=NetworkDeviceMonitoringApi(api_client)response=api_instance.get_interfaces(device_id="default:1.2.3.4",get_ip_addresses=True,)print(response)
# Get the list of interfaces of the device returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.newopts={get_ip_addresses:true,}papi_instance.get_interfaces("default:1.2.3.4",opts)
// Get the list of interfaces of the device returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewNetworkDeviceMonitoringApi(apiClient)resp,r,err:=api.GetInterfaces(ctx,"default:1.2.3.4",*datadogV2.NewGetInterfacesOptionalParameters().WithGetIpAddresses(true))iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `NetworkDeviceMonitoringApi.GetInterfaces`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `NetworkDeviceMonitoringApi.GetInterfaces`:\n%s\n",responseContent)}
// Get the list of interfaces of the device returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi.GetInterfacesOptionalParameters;importcom.datadog.api.client.v2.model.GetInterfacesResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();NetworkDeviceMonitoringApiapiInstance=newNetworkDeviceMonitoringApi(defaultClient);try{GetInterfacesResponseresult=apiInstance.getInterfaces("default:1.2.3.4",newGetInterfacesOptionalParameters().getIpAddresses(true));System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling NetworkDeviceMonitoringApi#getInterfaces");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get the list of interfaces of the device returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_network_device_monitoring::GetInterfacesOptionalParams;usedatadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=NetworkDeviceMonitoringAPI::with_config(configuration);letresp=api.get_interfaces("default:1.2.3.4".to_string(),GetInterfacesOptionalParams::default().get_ip_addresses(true),).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get the list of interfaces of the device returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.NetworkDeviceMonitoringApi(configuration);constparams: v2.NetworkDeviceMonitoringApiGetInterfacesRequest={deviceId:"default:1.2.3.4",getIpAddresses: true,};apiInstance.getInterfaces(params).then((data: v2.GetInterfacesResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Get the list of tags for a device returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.network_device_monitoring_apiimportNetworkDeviceMonitoringApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=NetworkDeviceMonitoringApi(api_client)response=api_instance.list_device_user_tags(device_id="default_device",)print(response)
# Get the list of tags for a device returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.newpapi_instance.list_device_user_tags("default_device")
// Get the list of tags for a device returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewNetworkDeviceMonitoringApi(apiClient)resp,r,err:=api.ListDeviceUserTags(ctx,"default_device")iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `NetworkDeviceMonitoringApi.ListDeviceUserTags`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `NetworkDeviceMonitoringApi.ListDeviceUserTags`:\n%s\n",responseContent)}
// Get the list of tags for a device returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;importcom.datadog.api.client.v2.model.ListTagsResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();NetworkDeviceMonitoringApiapiInstance=newNetworkDeviceMonitoringApi(defaultClient);try{ListTagsResponseresult=apiInstance.listDeviceUserTags("default_device");System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling NetworkDeviceMonitoringApi#listDeviceUserTags");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
// Get the list of tags for a device returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;#[tokio::main]asyncfnmain(){letconfiguration=datadog::Configuration::new();letapi=NetworkDeviceMonitoringAPI::with_config(configuration);letresp=api.list_device_user_tags("default_device".to_string()).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Get the list of tags for a device returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.NetworkDeviceMonitoringApi(configuration);constparams: v2.NetworkDeviceMonitoringApiListDeviceUserTagsRequest={deviceId:"default_device",};apiInstance.listDeviceUserTags(params).then((data: v2.ListTagsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Update the tags for a device returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){body:=datadogV2.ListTagsResponse{Data:&datadogV2.ListTagsResponseData{Attributes:&datadogV2.ListTagsResponseDataAttributes{Tags:[]string{"tag:test","tag:testbis",},},Id:datadog.PtrString("default_device"),Type:datadog.PtrString("tags"),},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewNetworkDeviceMonitoringApi(apiClient)resp,r,err:=api.UpdateDeviceUserTags(ctx,"default_device",body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `NetworkDeviceMonitoringApi.UpdateDeviceUserTags`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `NetworkDeviceMonitoringApi.UpdateDeviceUserTags`:\n%s\n",responseContent)}
// Update the tags for a device returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.NetworkDeviceMonitoringApi;importcom.datadog.api.client.v2.model.ListTagsResponse;importcom.datadog.api.client.v2.model.ListTagsResponseData;importcom.datadog.api.client.v2.model.ListTagsResponseDataAttributes;importjava.util.Arrays;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();NetworkDeviceMonitoringApiapiInstance=newNetworkDeviceMonitoringApi(defaultClient);ListTagsResponsebody=newListTagsResponse().data(newListTagsResponseData().attributes(newListTagsResponseDataAttributes().tags(Arrays.asList("tag:test","tag:testbis"))).id("default_device").type("tags"));try{ListTagsResponseresult=apiInstance.updateDeviceUserTags("default_device",body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling NetworkDeviceMonitoringApi#updateDeviceUserTags");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update the tags for a device returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.network_device_monitoring_apiimportNetworkDeviceMonitoringApifromdatadog_api_client.v2.model.list_tags_responseimportListTagsResponsefromdatadog_api_client.v2.model.list_tags_response_dataimportListTagsResponseDatafromdatadog_api_client.v2.model.list_tags_response_data_attributesimportListTagsResponseDataAttributesbody=ListTagsResponse(data=ListTagsResponseData(attributes=ListTagsResponseDataAttributes(tags=["tag:test","tag:testbis",],),id="default_device",type="tags",),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=NetworkDeviceMonitoringApi(api_client)response=api_instance.update_device_user_tags(device_id="default_device",body=body)print(response)
# Update the tags for a device returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::NetworkDeviceMonitoringAPI.newbody=DatadogAPIClient::V2::ListTagsResponse.new({data:DatadogAPIClient::V2::ListTagsResponseData.new({attributes:DatadogAPIClient::V2::ListTagsResponseDataAttributes.new({tags:["tag:test","tag:testbis",],}),id:"default_device",type:"tags",}),})papi_instance.update_device_user_tags("default_device",body)
// Update the tags for a device returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_network_device_monitoring::NetworkDeviceMonitoringAPI;usedatadog_api_client::datadogV2::model::ListTagsResponse;usedatadog_api_client::datadogV2::model::ListTagsResponseData;usedatadog_api_client::datadogV2::model::ListTagsResponseDataAttributes;#[tokio::main]asyncfnmain(){letbody=ListTagsResponse::new().data(ListTagsResponseData::new().attributes(ListTagsResponseDataAttributes::new().tags(vec!["tag:test".to_string(),"tag:testbis".to_string()]),).id("default_device".to_string()).type_("tags".to_string()),);letconfiguration=datadog::Configuration::new();letapi=NetworkDeviceMonitoringAPI::with_config(configuration);letresp=api.update_device_user_tags("default_device".to_string(),body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.com"DD_API_KEY="<API-KEY>"DD_APP_KEY="<APP-KEY>"cargo run
/**
* Update the tags for a device returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.NetworkDeviceMonitoringApi(configuration);constparams: v2.NetworkDeviceMonitoringApiUpdateDeviceUserTagsRequest={body:{data:{attributes:{tags:["tag:test","tag:testbis"],},id:"default_device",type:"tags",},},deviceId:"default_device",};apiInstance.updateDeviceUserTags(params).then((data: v2.ListTagsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));