- CPS-731Getting issue details... STATUS
Scope
It should be able to query all cm handles with a given set of public cm handle properties.
Requirements
- We want all cm-Handles where both things are true.
- If one or both are null return empty list (no conditions)
- Those properties also need to exist.
- If query body does not follow supported structure return 400.
- Empty query will return all cm-Handles.
A/C:
- Demo - with "and" behavior
- CI Test - two attributes
Issues/Decisions
Issue | Notes | Decision | |
---|---|---|---|
1 | Does request body need to declare "publicCmHandleProperties"? | Do we need to explicitly declare "publicCmHandleProperties"? Will there be another possible variation to this in the future? { "publicCmHandleProperties" : { "Name-1" : "some-value", "Name-2" : "other-value" } } | Yes |
2 | Are public properties always be in the format of "name" : x, "value": y? | In the fragment table there are example that follow this format { "name": "Contact", "value": "newemailforstore@bookstore.com" } | Yes. |
3 | Will there only ever be 1 kv pairs in public properties? | Yes | |
4 | Does the order matter? | Does { "publicCmHandleProperties" : { "Name-1" : "some-value", "Name-2" : "other-value" } } == { "publicCmHandleProperties" : { "Name-2" : "other-value", "Name-1" : "some-value" } } | No |
5 | Should search be case sensitive? | depend on CPSPath functionality - may be case-sensitive https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html | Investigation Pending |
6 | What format should the response take? | We have two options currently:
[ "cmHandle1", "cmHandle2", ..., "cmHandleN" ] 2. Return CM Handle Objects
Contact Tony Finnerty & kieran mccarthy regarding this. | Tony Finnerty Has no opinion on this matter |
Analysis/Implementation Proposal
High level Jiras:
- - CPS-901Getting issue details... STATUS
- - CPS-902Getting issue details... STATUS
- - CPS-903Getting issue details... STATUS
- - CPS-904Getting issue details... STATUS
Possible High-Level Implementation Steps:
Match all xpaths using CPS Path Query
Iterate over the list and retrieve all attributes
- Iterate over the attributes and collect those instances that match
- Return collected list of cm handles
Interface Proposal
# | URI | Design Notes | Comment(s) |
---|---|---|---|
1 | POST /ncmp/v1/data/ch/searches | Scenario : Request received to return all cm handles matching properties given Request Body { "publicCmHandleProperties" : { "Name-1" : "some-value", "Name-2" : "other-value" } } { "publicCmHandleProperties": { "name": "Contact", "value": "newemailforstore@bookstore.com" } } Response Body Example 1 [ "cmHandle1", "cmHandle2", ..., "cmHandleN" ] |
Below is a sample yaml for OpenAPI.
Public Properties are stored in the fragment table in CPS as seen below:
PoC Gerrit Review
A PoC has been coded and can be found here: https://gerrit.onap.org/r/c/cps/+/127541
# | Scenario | Screenshot |
---|---|---|
1 | Both properties match (CM Handles Returned that Match) | |
2 | One property doesn't match (Nothing Returned) | |
3 | No properties given - all cm handles returned (that contain public properties) | |
4 | Return 400 (BAD_REQUEST) |
Testing
Edge Cases
- Null name, Value
- Empty name, Value
Future Example (Out-of-scope)
POST /ncmp/v1/data/ch/searches
{ "publicCmHandleProperties" : { "publicPropertyName-1" : "publicPropertyValue-1", "publicPropertyName-2" : "publicPropertyValue-2" }, "modules": [ { "moduleName": "", (Mandatory) "revision": "" (Optional) } ] }
Modules in the example are to demonstrate future intentions but is out of scope for this user story.
References
CPS Swagger: http://localhost:8883/swagger-ui/index.html?configUrl=%2Fv3%2Fapi-docs%2Fswagger-config
https://docs.onap.org/projects/onap-cps/en/latest/cps-path.html
https://www.freeformatter.com/xpath-tester.html#ad-output
//public-properties[@name='Contact' and @value='xyz']/ancestor::cm-handles
org.onap.cps.spi.impl.CpsDataPersistenceQueryDataNodeSpec#Query for attribute by cps path of type ancestor with #scenario.