blob: 529297daa7924d10ef307d5322158e776a0bbdf7 [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
halil.cakal230afc12023-11-30 11:22:20 +00003.. Copyright (C) 2022-2023 Nordix Foundation
lukegleesonde294742022-07-25 11:00:11 +01004
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
lukegleeson291d9062022-08-26 11:46:22 +010039Casing conventions: 'camelCasing' and 'kebab-casing'
emacleeb176de22022-08-31 15:53:10 +010040----------------------------------------------------
41
lukegleeson291d9062022-08-26 11:46:22 +010042.. note::
43 By convention REST JSON return bodies use 'camelCasing'. By convention field names in yang modelled data use 'kebab-casing'. Therefore some inconsistencies can be seen in the JSON use in CPS REST interfaces. For CM Handle related endpoints we return data in 'camelCasing'. But for *cmHandleWithCpsPath*, the query is accessing yang modelled field names and as such needs to use 'kebab-casing'. Therefore the dmi-registry field names should be referenced when using the *cmHandleWithCpsPath* condition: :doc:`modeling`
44
lukegleesonde294742022-07-25 11:00:11 +010045Request 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:
46
47.. code-block:: json
48
49 {
50 "cmHandleQueryParameters": [
51 {
52 "conditionName": "hasAllModules",
53 "conditionParameters": [
54 {
55 "moduleName": "my-module-1"
56 },
57 {
58 "moduleName": "my-module-2"
59 },
60 {
61 "moduleName": "my-module-3"
62 }
63 ]
64 },
65 {
66 "conditionName": "hasAllProperties",
67 "conditionParameters": [
68 {
69 "Color": "yellow"
70 },
71 {
72 "Shape": "circle"
73 },
74 {
75 "Size": "small"
76 }
77 ]
78 },
79 {
80 "conditionName": "cmHandleWithCpsPath",
81 "conditionParameters": [
82 {
83 "cpsPath": "//state[@cm-handle-state='ADVISED']"
84 }
85 ]
halil.cakal230afc12023-11-30 11:22:20 +000086 },
87 {
88 "conditionName": "cmHandleWithTrustLevel",
89 "conditionParameters": [
90 {
91 "trustLevel": "COMPLETE"
92 }
93 ]
lukegleesonde294742022-07-25 11:00:11 +010094 }
95 ]
96 }
97
98
99Has all Modules
100---------------
101
102With 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".
103
104.. code-block:: json
105
106 {
107 "cmHandleQueryParameters": [
108 {
109 "conditionName": "hasAllModules",
110 "conditionParameters": [
111 {
112 "moduleName": "my-module-1"
113 },
114 {
115 "moduleName": "my-module-2"
116 },
117 {
118 "moduleName": "my-module-3"
119 }
120 ]
121 }
122 ]
123 }
124
125Has all Properties
126------------------
127
128With 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".
129
130.. code-block:: json
131
132 {
133 "cmHandleQueryParameters": [
134 {
135 "conditionName": "hasAllProperties",
136 "conditionParameters": [
137 {
138 "Color": "yellow"
139 },
140 {
141 "Shape": "circle"
142 },
143 {
144 "Size": "small"
145 }
146 ]
147 }
148 ]
149 }
150
151CM Handle with CPS Path
152-----------------------
153
154The *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.
155
156.. code-block:: json
157
158 {
159 "cmHandleQueryParameters": [
160 {
161 "conditionName": "cmHandleWithCpsPath",
162 "conditionParameters": [
163 {
164 "cpsPath": "//state[@cm-handle-state='LOCKED']"
165 }
166 ]
167 }
168 ]
emacleeb176de22022-08-31 15:53:10 +0100169 }
halil.cakal230afc12023-11-30 11:22:20 +0000170
171CM Handle with Trust Level
172--------------------------
173
174With the *cmHandleWithTrustLevel* condition, we can provide just one trust level. The CM handles returned will have this trust level. Providing more than one parameter causes unexpected results. Condition parameter name is not being validated.
175
176.. code-block:: json
177
178 {
179 "cmHandleQueryParameters": [
180 {
181 "conditionName": "cmHandleWithTrustLevel",
182 "conditionParameters": [
183 {
184 "trustLevel": "COMPLETE"
185 }
186 ]
187 }
188 ]
189 }