[AAI] Fix doc config files
[aai/aai-common.git] / docs / AAI REST API Documentation / nodesApi.rst
1 .. contents::
2    :depth: 3
3 ..
4 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
5 .. http://creativecommons.org/licenses/by/4.0
6
7 Nodes Query
8 ===========
9
10 In working with AAI's standard REST API, you may have noticed that
11 certain API paths have a hierarchy to them and require a client to
12 know multiple object keys to preform GETs. For example: the vserver
13 object is under tenant, which is itself under cloud-region. If you
14 wanted to look up a vserver by name, you would still need to know the
15 tenant-id and cloud-region-id (and cloud-owner) in order to
16 successfully perform that GET. The nodes API allows for more freedom
17 in querying AAI, allowing clients to circumvent the need to know
18 every key in the hierarchy. Using the previous example, the below is
19 how the API called would change for looking up a vserver by name:
20
21   GET /aai/v$/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers?vserver-name={vserver-name}
22   becomes
23   GET /aai/v$/nodes/vservers?vserver-name={vserver-name}
24
25 A side effect of this is that if the same vserver name was reused between
26 multiple cloud-regions or tenants the client will receive multiple
27 vservers in the response. Vserver ID and vserver name are
28 intentionally non-unique outside of their cloud-region/tenant
29 hierarchy, as are many other keys for nested objects.
30
31 API URI
32 ~~~~~~~
33
34 nodes can be used to start a URI from any node type, whether singular or plural.
35
36     GET /aai/v$/nodes/{plural}
37     OR
38     GET /aai/v$/nodes/{singular}/{key}
39
40 From there, it can be expanded on similarly to our Resources API.  For example:
41
42     GET /aai/v$/nodes/{plural}?{property}={value}
43
44     GET /aai/v$/nodes/tenant/{tenant-id}/vservers
45
46     GET /aai/v$/nodes/generic-vnf/{vnf-id}/related-to/platforms
47
48 Optional Query Parameters
49 ~~~~~~~~~~~~~~~~~~~~~~~~~
50 The Nodes API can make use of all the optional query
51 parameters available on the standard REST API.
52
53 Depth
54 ~~~~~
55
56 You can pass a depth query parameter to indicate what level of child objects you want
57 returned. By default the output will be depth = 0 (no "children", only
58 "cousin" relationships). When using depth in conjunction with the
59 format query parameter, it will only apply to the on the resource or
60 resource_and_url formats.
61
62    GET /aai/v$/nodes/{plural}/{singular}/{key}?depth={integer}
63
64 Nodes Only
65 ~~~~~~~~~~
66
67 You can pass a nodes only query parameter to have the output only contain
68 the object properties with no relationships.
69
70    GET /aai/v$/nodes/{plural}/{singular}/{key}?nodes-only
71    OR
72    GET /aai/v$/nodes/{plural}/{singular}/{key}?format={format}&nodesOnly=true
73
74 Format
75 ~~~~~~
76
77 You can optionally request an output format different from the default
78 REST API output. You can reference the list of formats on the
79 Query wiki page for the full list of available
80 formats and examples.
81
82    GET /aai/v$/nodes/{plural}/{singular}/{key}?format={format}
83
84 Usage with Custom Query
85 ~~~~~~~~~~~~~~~~~~~~~~~
86
87 The Nodes API can be called directly or as the start node for Custom
88 Queries. Please reference the Custom Queries wiki page for full
89 documentation on how to use that interface.
90
91    PUT /aai/v$/query?format={format} with payload like..
92    { "start": ["nodes/{plural}/{singular}/{key}"], "query": "query/{query-name}" }