The find operation finds elements that correspond to a particular query.
The find operation obtains objects of any type by searching for a particular name. The query results are provided in the form of a QueryResult object, which contains an array of FinderResult objects with a total counter. The query itself is passed to find as the second parameter, as the following operation declaration shows.
public QueryResult find(String type, String query, String username, String password);
The plug-in that contains the objects that you are looking for parses the query. The plug-in defines the query language that the find operation uses. Consequently, the syntax of the query parameter differs according to the implementation of the plug-in. Most of the officially supported Orchestrator plug-ins do not store any objects in the inventory, so they do not expose anything that can be searched for.
The following table describes the find operationquery parameter syntax and behavior for each of the supported Orchestrator plug-ins.
When you develop plug-ins, you can define a query language to use find to search for named objects through the custom plug-in. This definition is not mandatory. The syntax of the query parameter is entirely dependent on the query language that the plug-in implements. To avoid defining a query language, make find return all objects, as in the case of the VMware Infrastructure plug-ins.
The size of the array of objects that the QueryResult returns depends on the definition of the plug-in through which you make the query. For the queries you make through the standard Orchestrator plug-ins, the array contains an unlimited number of FinderResult objects. Developers of third-party plug-ins, however, can set a limit on the number of results that the query returns. If the value of totalCount exceeds the number of objects in the array of FinderResult objects, the array does not include all of the objects found in the queried inventory. The totalCount property does report the total number of FinderResult objects found. The totalCount property can be negative, which signifies that the plug-in cannot determine how many corresponding objects are in the plug-in.
The query is a string enclosed in quotation marks. Any object of the type specified by the type parameter with a name that matches the query string is returned in the QueryResult object. |
||
Returns the result of the query as a QueryResult object.
If find fails to match an object, QueryResult.getTotalCount returns 0 and QueryResult.getElement returns null.
If the server does not recognize the object type or plug-in searched for, find throws an exception. The find operation also returns an exception if you pass it an invalid parameter.