VMware Networking Community
dreznicek
Contributor
Contributor

REST API: Query for object based on name instead of objectId

Please correct me if I'm wrong...

Right now I have to query anything and everything by the objectId. The issue is that I don't know what that is. I know the name. So, for example, If I know the objectId of an edge device named "myrouter" is "edge-1", then I can do:

     https://nsxmgr/api/4.0/edges/edge-1

Awesome! Now I get the entire config. But let's say I don't know the edgeId. Because why would I? I would, however, know its name because that's why I name things. In many other API's all I would have to do is something like this:

     https://nsxmgr/api/4.0/edges?name=myrouter

The only way I know of to do this today is to fetch ALL of the edges with the following:

     https://nsxmgr/api/4.0/edges

This returns every single edge in the scope! Then I have to do something like (in powershell):

     $router_exist = (Select-Xml -Xml $script:edges -XPath "//edgeSummary[name=`"$esr_name`"]").Node

     if ($router_exist) {

          $router_id = $router_exist.objectId

     }


This isn't just for edges...its for every object available. Is it not possible to query based on an attribute?


Thanks,

Daniel

Tags (1)
0 Kudos
1 Reply
ShaneRay87
Contributor
Contributor

I have the same/similar requirement.

It would really be nice if this API supported OData or something similar.

Having to pul an entire list of objects (could be thousands) to search for one by name or filter by a property value is extreemly inefficient.

0 Kudos