blob: 5655d6c4a1a4369bb92705a93f7e31746430d764 [file] [log] [blame]
lukegleesonde294742022-07-25 11:00:11 +01001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3.. Copyright (C) 2022 Nordix Foundation
4
5.. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING
6.. _cmhandlequerying:
7
8
9CM Handle Query Endpoints
10#########################
11
12.. toctree::
13 :maxdepth: 1
14
15Introduction
16============
17
18For querying CM Handles we have two Post endpoints:
19
20- ncmp/v1/ch/searches Returns all CM Handles which match the query properties provided. Gives a JSON payload of the **details** of all matching CM Handles.
21
22- ncmp/v1/ch/id-searches Returns all CM Handles IDs which match the query properties provided. Gives a JSON payload of the **ids** of all matching CM Handles.
23
24/searches returns whole CM Handle object (data) whereas /id-searches returns only CM Handle IDs. Otherwise these endpoints are intended to be functionally identical so both can be queried with the same request body. If no matching CM Handles are found an empty array is returned.
25
26Request Body
27============
28
29Currently this endpoint allows three criteria to be query on:
30
31- *hasAllModules* returns CM Handles which have the module names provided.
32
33- *hasAllProperties* returns CM Handles which have the properties (key and value) provided.
34
35- *cmHandleWithCpsPath* returns CM Handles which match the CPS Path provided.
36
37Not all request body combinations have been validated and as such request bodies which do not conform to the structure as documented here can produce results in which all CM Handles are returned.
38
39Request Body example using all available query criteria. This query would return all CM Handles which have the specified modules my-module-(1-3), have the specified properties of Color yellow, Shape circle, Size small and are in a sync state of ADVISED:
40
41.. code-block:: json
42
43 {
44 "cmHandleQueryParameters": [
45 {
46 "conditionName": "hasAllModules",
47 "conditionParameters": [
48 {
49 "moduleName": "my-module-1"
50 },
51 {
52 "moduleName": "my-module-2"
53 },
54 {
55 "moduleName": "my-module-3"
56 }
57 ]
58 },
59 {
60 "conditionName": "hasAllProperties",
61 "conditionParameters": [
62 {
63 "Color": "yellow"
64 },
65 {
66 "Shape": "circle"
67 },
68 {
69 "Size": "small"
70 }
71 ]
72 },
73 {
74 "conditionName": "cmHandleWithCpsPath",
75 "conditionParameters": [
76 {
77 "cpsPath": "//state[@cm-handle-state='ADVISED']"
78 }
79 ]
80 }
81 ]
82 }
83
84
85Has all Modules
86---------------
87
88With the *hasAllModules* condition, we can provide a list of module names. The CM Handles returned will have these module names. The parameter names must be as below with the key of each of the module names being "moduleName" where "my-module-X" is to be replaced with the name of the module to query with. The returned CM Handle must have all supplied modules. For the example request, a CM Handle will be returned if it has "my-module-1", "my-module-2" and "my-module-3".
89
90.. code-block:: json
91
92 {
93 "cmHandleQueryParameters": [
94 {
95 "conditionName": "hasAllModules",
96 "conditionParameters": [
97 {
98 "moduleName": "my-module-1"
99 },
100 {
101 "moduleName": "my-module-2"
102 },
103 {
104 "moduleName": "my-module-3"
105 }
106 ]
107 }
108 ]
109 }
110
111Has all Properties
112------------------
113
114With the *hasAllProperties* condition, we can provide a list of property keys and values. The CM Handles returned will have these properties. The parameter names must be as below with key and value for each property. The returned CM Handle must have all supplied properties. For the example request, a CM Handle will be returned if it has properties where there is a key of "Color" with value "yellow", a key of "Shape" with value "circle" and a key of "Size" with value "small".
115
116.. code-block:: json
117
118 {
119 "cmHandleQueryParameters": [
120 {
121 "conditionName": "hasAllProperties",
122 "conditionParameters": [
123 {
124 "Color": "yellow"
125 },
126 {
127 "Shape": "circle"
128 },
129 {
130 "Size": "small"
131 }
132 ]
133 }
134 ]
135 }
136
137CM Handle with CPS Path
138-----------------------
139
140The *cmHandleWithCpsPath* condition allows any data of the CM Handle to be queried as long as it is accessible by CPS path. CPS path is described in detail in :doc:`cps-path`. For this endpoint, the ancestor of CM Handles is appended automatically so that a CM Handle is always returned. For example ``//state[@cm-handle-state='LOCKED']`` will become ``//state[@cm-handle-state='LOCKED']/ancestor::cm-handles``. The yang model for the dmi-registry can be found in :doc:`modeling` under the NCMP Modeling Section. Please note that although CM Handle additional-properties are shown in the dmi-registry yang model, these are considered private properties and cannot be used to query CM Handles. Any attempt to use the additional-properties to query will return an empty array.
141
142.. code-block:: json
143
144 {
145 "cmHandleQueryParameters": [
146 {
147 "conditionName": "cmHandleWithCpsPath",
148 "conditionParameters": [
149 {
150 "cpsPath": "//state[@cm-handle-state='LOCKED']"
151 }
152 ]
153 }
154 ]
155 }