How to use Spectrum REST API to get interface models and attributes
search cancel

How to use Spectrum REST API to get interface models and attributes

book

Article ID: 235422

calendar_today

Updated On:

Products

CA Spectrum

Issue/Introduction

We need port information like IP address and device name from spectrum through API call. 

 

Environment

Release : 10.4.x, 21.x

Component :OneClick REST API

Cause

Informational

Resolution

1. To get the interface model handles, you would first need to query the device model:

http://<OneClick>:<port>/spectrum/restful/associations/relation/0x10004/model/0xdevHandle?side=left

Example from my lab server with device model handle 0x2001dbf
http://hostname.domain.com/spectrum/restful/associations/relation/0x10004/model/0x2001dbf?side=left

Response back
<association-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response">
<association-responses>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd0"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd3"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd4"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd5"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd6"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd7"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd8"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dd9"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dda"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ddb"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ddc"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ddd"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dde"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ddf"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001de0"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001de1"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001de8"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001de9"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dea"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001deb"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dec"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ded"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dee"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001def"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df3"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df4"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df5"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df6"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df7"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df8"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001df9"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001dfa"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fdc"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fdd"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fde"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe2"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe3"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe4"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe5"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe6"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe7"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe8"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fe9"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fea"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001feb"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fec"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fed"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001fef"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ff0"/>
<association rh="0x10004" leftmh="0x2001dbf" rightmh="0x2001ff1"/>
</association-responses>
</association-response-list>


2. This will list all the model handles of the 'has_members' relation to the device (interfaces)

     You will then need to iterate through the list of model handles and use that to query the interface info.

 


Example from my lab server where model handle 0x2001dd0 is the first response from the rightmh above.

http://hostname.domain.com/spectrum/restful/model/0x2001dd0?attr=0x12d7f&attr=0x1006e


Response returned

<model-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response" total-models="1" throttle="1" error="EndOfResults">
<model-responses>
<model mh="0x2001dd0">
<attribute id="0x12d7f">xx.x.x.x</attribute>
<attribute id="0x1006e">Name</attribute>
</model>
</model-responses>
</model-response-list>

 

You will need to complete this for each response of the rightmh from the response of the first query.  Then you will have the entire list of interfaces and ip addresses.

 

Additional Information

If you wanted to add additional attributes to the query, you could do this by appending &attr=<attribute value> to the 2nd query.