1 .. 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
5 .. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING
9 CM Handle Query Endpoints
10 #########################
18 For querying CM Handles we have two Post endpoints:
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.
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.
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.
29 Currently this endpoint allows three criteria to be query on:
31 - *hasAllModules* returns CM Handles which have the module names provided.
33 - *hasAllProperties* returns CM Handles which have the properties (key and value) provided.
35 - *cmHandleWithCpsPath* returns CM Handles which match the CPS Path provided.
37 Not 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.
39 Casing conventions: 'camelCasing' and 'kebab-casing'
40 ----------------------------------------------------
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`
45 Request 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:
50 "cmHandleQueryParameters": [
52 "conditionName": "hasAllModules",
53 "conditionParameters": [
55 "moduleName": "my-module-1"
58 "moduleName": "my-module-2"
61 "moduleName": "my-module-3"
66 "conditionName": "hasAllProperties",
67 "conditionParameters": [
80 "conditionName": "cmHandleWithCpsPath",
81 "conditionParameters": [
83 "cpsPath": "//state[@cm-handle-state='ADVISED']"
94 With 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".
99 "cmHandleQueryParameters": [
101 "conditionName": "hasAllModules",
102 "conditionParameters": [
104 "moduleName": "my-module-1"
107 "moduleName": "my-module-2"
110 "moduleName": "my-module-3"
120 With 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".
125 "cmHandleQueryParameters": [
127 "conditionName": "hasAllProperties",
128 "conditionParameters": [
143 CM Handle with CPS Path
144 -----------------------
146 The *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.
151 "cmHandleQueryParameters": [
153 "conditionName": "cmHandleWithCpsPath",
154 "conditionParameters": [
156 "cpsPath": "//state[@cm-handle-state='LOCKED']"