You can extend the scope of a collection query to retrieve data from a related resource type. The REST model describes two kinds of relations:
A referenced resource type describes an instance of a linked object type. This resource type is declared in the REST model as a reference to an object (for a many-to-one relation) or an array of objects (for a one-to-many or many-to-many relation). To return information about instances and their related instances, use the following syntax in the select parameter to specify the wanted attributes from the related resource type:
...<attribute1>,<attribute2>,<related_resource> (id,related_attribute2, related_attribute3...)
If you omit the list of parameters, only the select attribute and its value are returned for the referenced object:
...<attribute1>,<attribute2>,<related_resource>
The following queries use the select request parameter to return information about nodes and their related appliances.
Component | Details |
---|---|
Headers |
Accept: application/json Authorization: <auth_cookie> |
Request |
https://1.2.3.4/api/rest/node?select=id,name,appliance(id,name) |
Response body |
[ { "id":"N1", "name":"H0112-appliance-1-node-A", "appliance": { "id":"A1", "name":"H0112-appliance-1" } }, { "id":"N2", "name":"H0112-appliance-1-node-B", "appliance": { "id":"A1", "name":"H0112-appliance-1" } } ] |
Component | Details |
---|---|
Headers |
Accept: application/json Authorization: <auth_cookie> |
Request |
https://1.2.3.4/api/rest/node?select=id,name,appliance |
Response body |
[ { "id":"N1", "name":"H0112-appliance-1-node-A", "appliance": { "id":"A1" } }, { "id":"N2", "name":"H0112-appliance-1-node-B", "appliance": { "id":"A1" } } ] |
Component | Details |
---|---|
Headers |
Accept: application/json Authorization: <auth_cookie> |
Request |
https://1.2.3.4/api/rest/appliance?select=id,name,nodes(id,name) |
Response body |
[ { "id":"A1", "name":"H0112-appliance-1", "nodes": [ { "id":"N1", "name":"H0112-appliance-1-node-A" }, { "id":"N2", "name":"H0112-appliance-1-node-B" } ] } ] |
Component | Details |
---|---|
Headers |
Accept: application/json Authorization: <auth_cookie> |
Request |
https://1.2.3.4/api/rest/appliance?select=id,name,nodes |
Response body |
[ { "id":"A1", "name":"H0112-appliance-1", "nodes": [ { "id":"N1" }, { "id":"N2" } ] } ] |
An embedded resource type describes an instance of nested objects. This resource type is declared in the REST model as a reference to an object or an array of objects with a special note in its description field.
Use the following syntax in the select parameter to query an embedded resource type:
...<attribute1>,<attribute2>,<embedded_resource>
In addition, you can display selected attributes of an embedded resource:
...<attribute1>,<attribute2>,<embedded_resource>->>embedded_attribute1,<embedded_resource>->>embedded_attribute2...
Component | Details |
---|---|
Headers |
Accept: application/json Authorization: <auth_cookie> |
Request |
https://1.2.3.4/api/rest/volume?select=id,protection_data |
Response body |
[ { "id":"3f6208d1-b325-4901-9fc1-9e82d943b857", "protection_data": { "family_id": "3f6208d1-b325-4901-9fc1-9e82d943b857", "parent_id": null, "source_id": null, "creator_type": "User", "copy_signature": null, "source_timestamp": null, "creator_type_l10n": "User", "is_app_consistent": null, "created_by_rule_id": null, "created_by_rule_name": null, "expiration_timestamp": null } }, { "id":"9d102db7-048d-4d24-85c2-28c7a5fc91ee", "protection_data": { "family_id": "9d102db7-048d-4d24-85c2-28c7a5fc91ee", "parent_id": null, "source_id": null, "creator_type": "User", "copy_signature": null, "source_timestamp": null, "creator_type_l10n": "User", "is_app_consistent": null, "created_by_rule_id": null, "created_by_rule_name": null, "expiration_timestamp": null } }, { "id":"f0480b0f-cc6f-431b-9e18-e4b39b2b13e1", "protection_data": { "family_id": "f0480b0f-cc6f-431b-9e18-e4b39b2b13e1", "parent_id": null, "source_id": null, "creator_type": "User", "copy_signature": null, "source_timestamp": null, "creator_type_l10n": "User", "is_app_consistent": null, "created_by_rule_id": null, "created_by_rule_name": null, "expiration_timestamp": null } } ] |