Skip to main content
Flexible Top Header

Hello,

I’m working on converting all our scripts from V1 to V2 of the API on version 9.6.1, but I’m struggling to find the right call to replace “GetLinkedEntities”.  For reference, we’re needing to do a search by MacAddress and return all the IP Addresses associated with that mac address, or even a single IP associated with that address.   The V1 to V2 guide lists several API Areas where this should be possible:

  • GET /api/v2/tags/{collectionId}/taggedResources
  • GET /api/v2/userGroups/{collectionId}/users
  • GET /api/v2/addreses/{collectionId}/resourceRecords
  • GET /api/v2/resourceRecords/{collectionId}/dependentRecords
  • GET /api/v2/macPools/{collectionId}/macAddresses
  • GET /api/v2/serverGroups/{collectionId}/servers
  • GET /api/v2/locations/{collectionId}/annotatedResources

However, I have had zero luck getting any of these to work at all.  I can do a straight mac address search and return the MacID without any issues, but getting all the linked entities to this mac address within the system has been a challenge.    I haven’t been able to determine the “Collection ID” that would be appropriate in this case as the MacID does not appear to be it and it also doesn’t appear to be the ConfigurationID.

Has anyone else had any luck getting this to work in APIv2?  An example or any advice would be very much appreciated as, no matter what syntax I throw at this, it doesn’t appear to return any useful data.

Thanks for any help you can provide.

Fetch the mac address with /api/v2/macAddresses?filter=address:eq('xx-xx-xx-xx-xx-xx'). 

In the response will be a _links.addresses, which will be /api/v2/macAddresses/<mac object id>/addresses - this will give you the linked IPv4Address object(s).


That second part is exactly what I wasn’t understanding.  That worked beautifully to pull out the needed information.  Thank You.


...and you can combine it all into a single call by embedding the addresses collection like so:

/api/v2/macAddresses?filter=address:eq('xx-xx-xx-xx-xx-xx')&fields=embed(addresses)


https://{{bamip}}/api/v2/macAddresses?filter=address:eq('00-0C-29-F9-FE-ED')&fields=address,address,_embedded.addresses.address,_embedded.addresses._embedded.leases.leaseDateTime,_embedded.addresses._embedded.leases.leaseExpirationDateTime

{
"count": 1,
"data": [
{
"address": "00-0C-29-F9-FE-ED",
"_embedded": {
"addresses": [
{
"address": "192.168.1.2",
"_embedded": {
"leases": []
}
}
]
}
}
]
}

Given a specific MAC, show me the addresses and any lease too for good measure


Reply