How to use the Spectrum RESTful API to get a list for interfaces based on a network address.
search cancel

How to use the Spectrum RESTful API to get a list for interfaces based on a network address.

book

Article ID: 266042

calendar_today

Updated On: 04-10-2025

Products

Network Observability Spectrum

Issue/Introduction

With Spectrum RESTful API, a GET request query using an IP address of a device ca return any number of attributes of that device model. This article shows how to retrieve the hostname and other attributes.

Environment

DX NetOps Spectrum all currently supported releases 

Resolution

In the following example, we created an xml file called GetInterfaces.xml.

<?xml version="1.0" encoding="UTF-8"?>

<rs:model-request throttlesize="500"
  xmlns:rs="http://www.ca.com/spectrum/restful/schema/request"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd ">

    <rs:target-models>
      <rs:models-search>
        <rs:search-criteria
             xmlns="http://www.ca.com/spectrum/restful/schema/filter">
             <interfaces-of-devices-search/>
          <filtered-models>
            <equals>
              <attribute id="AttributeID.NETWORK_ADDRESS">
                <value>xxx.xxx.xxx.xxx</value> <!-- RTR_Cisco -->
              </attribute>
            </equals>
          </filtered-models>
        </rs:search-criteria>
      </rs:models-search>
    </rs:target-models>

    <rs:requested-attribute id="0x1006e" />
    <rs:requested-attribute id="0x10000" />

</rs:model-request>

In the above xml, the "<interfaces-of-devices-search/>" tag will search for the associated interface models for the device ip address (xxx.xxx.xxx.xxx) in the "<value>" tag. The results will display the interface model name "0x1006e" and the model type name "0x10000". Other interface attribute may be added as needed.

From the command line, use the following template to read in the xml file replacing the following for your environment:

"spectrum:spectrum" with the username and password of a valid Spectrum user
https with either http or https
<OneClick-HOST> with your OneClick hostname or ip address
8443 with the proper http or https port

curl -kv -d @GetInterfaces.xml -X POST -i -H "Content-Type: application/xml" -u spectrum:spectrum https://<OneClick-HOST>:8443/spectrum/restful/models