seanbeirne | f5a3a21 | 2023-03-06 09:12:49 +0000 | [diff] [blame] | 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) 2023 Nordix Foundation |
| 4 | |
| 5 | .. DO NOT CHANGE THIS LABEL FOR RELEASE NOTES - EVEN THOUGH IT GIVES A WARNING |
| 6 | .. _inventoryquerying: |
| 7 | |
| 8 | |
| 9 | Inventory Query Endpoints |
| 10 | ######################### |
| 11 | |
| 12 | .. toctree:: |
| 13 | :maxdepth: 1 |
| 14 | |
| 15 | Introduction |
| 16 | ============ |
| 17 | |
| 18 | For querying the NCMP Inventory we have one Post endpoint: |
| 19 | |
| 20 | - ncmpInventory/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 | If no matching CM Handles are found an empty array is returned. |
| 23 | |
| 24 | Request Body |
| 25 | ============ |
| 26 | |
| 27 | Currently this endpoint allows three criteria to be query on: |
| 28 | |
| 29 | - *hasAllProperties* returns CM Handles which have the public properties provided. |
| 30 | |
| 31 | - *hasAllAdditionalProperties* returns CM Handles which have the private or additional properties (key and value) provided. |
| 32 | |
| 33 | - *cmHandleWithDmiPlugin* returns CM Handles which match the CPS Dmi Plugin provided. |
| 34 | |
| 35 | 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. |
| 36 | |
| 37 | Casing conventions: 'camelCasing' and 'kebab-casing' |
| 38 | ---------------------------------------------------- |
| 39 | |
| 40 | .. note:: |
| 41 | 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` |
| 42 | |
| 43 | Request Body example using all available query criteria. This query would return all CM Handles which have the specified public properties of Color yellow, Shape circle, Size small, have the specified private/additional properties of Price 5, Year 2022 and Quantity 12 and have related to DMI plugin dmiPlugin1: |
| 44 | |
| 45 | .. code-block:: json |
| 46 | |
| 47 | { |
| 48 | "cmHandleQueryParameters": [ |
| 49 | { |
| 50 | "conditionName": "hasAllProperties", |
| 51 | "conditionParameters": [ |
| 52 | { |
| 53 | "Color": "yellow" |
| 54 | }, |
| 55 | { |
| 56 | "Shape": "circle" |
| 57 | }, |
| 58 | { |
| 59 | "Size": "small" |
| 60 | } |
| 61 | ] |
| 62 | }, |
| 63 | { |
| 64 | "conditionName": "hasAllAdditionalProperties", |
| 65 | "conditionParameters": [ |
| 66 | { |
| 67 | "Price": "5" |
| 68 | }, |
| 69 | { |
| 70 | "Year": "2022" |
| 71 | }, |
| 72 | { |
| 73 | "Quantity": "12" |
| 74 | } |
| 75 | ] |
| 76 | }, |
| 77 | { |
| 78 | "conditionName": "cmHandleWithDmiPlugin", |
| 79 | "conditionParameters": [ |
| 80 | { |
| 81 | "dmiPluginName": "dmiPlugin1" |
| 82 | } |
| 83 | ] |
| 84 | } |
| 85 | ] |
| 86 | } |
| 87 | |
| 88 | Has all Properties |
| 89 | ------------------ |
| 90 | |
| 91 | With the *hasAllProperties* condition, we can provide a list of property keys and values. The CM Handles returned will have these public 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". |
| 92 | |
| 93 | .. code-block:: json |
| 94 | |
| 95 | { |
| 96 | "cmHandleQueryParameters": [ |
| 97 | { |
| 98 | "conditionName": "hasAllProperties", |
| 99 | "conditionParameters": [ |
| 100 | { |
| 101 | "Color": "yellow" |
| 102 | }, |
| 103 | { |
| 104 | "Shape": "circle" |
| 105 | }, |
| 106 | { |
| 107 | "Size": "small" |
| 108 | } |
| 109 | ] |
| 110 | } |
| 111 | ] |
| 112 | } |
| 113 | |
| 114 | Has all additional Properties |
| 115 | ----------------------------- |
| 116 | |
| 117 | With the *hasAllAdditionalProperties* condition, we can provide a list of property keys and values. The CM Handles returned will have these additional 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 "Price" with value "5", a key of "Year" with value "2022" and a key of "Quantity" with value "12". |
| 118 | |
| 119 | .. code-block:: json |
| 120 | |
| 121 | { |
| 122 | "cmHandleQueryParameters": [ |
| 123 | { |
| 124 | "conditionName": "hasAllAdditionalProperties", |
| 125 | "conditionParameters": [ |
| 126 | { |
| 127 | "Price": "5" |
| 128 | }, |
| 129 | { |
| 130 | "Year": "2022" |
| 131 | }, |
| 132 | { |
| 133 | "Quantity": "12" |
| 134 | } |
| 135 | ] |
| 136 | } |
| 137 | ] |
| 138 | } |
| 139 | |
| 140 | Has all DMI Plugins |
| 141 | ------------------- |
| 142 | |
| 143 | With the *cmHandleWithDmiPlugin* condition, we can provide a dmiPluginName. The CM Handles returned will have this DMI Plugin Name value in at least one of the following related leaves: dmi-service-name, dmi-data-service-name and dmi-model-service-name. For the example request a CM Handle will be returned if it has my-dmi-plugin as a value in at least one of the aforementioned leaves. |
| 144 | |
| 145 | .. code-block:: json |
| 146 | |
| 147 | { |
| 148 | "cmHandleQueryParameters": [ |
| 149 | { |
| 150 | "conditionName": "cmHandleWithDmiPlugin", |
| 151 | "conditionParameters": [ |
| 152 | { |
| 153 | "dmi-service-name": "my-dmi-plugin" |
| 154 | } |
| 155 | ] |
| 156 | } |
| 157 | ] |
| 158 | } |