...
List of new APIs
Get all dataspaces
v1URL
}Response body
Code Block {“dataspace-names”: [“data-space1”,” data-space2”,” data-space3”]
Response body(ref. get anchors)
[ { "dataspaceName": "testDataspace-1" }, { "dataspaceName": "testDataspace-2"Code Block
, { "dataspaceName": "testDataspace-3" } ]}
Get single dataspace
v1URL
Response body
Code Block { “dataspaceName”:”data-space1” }
Get all schema sets for a dataspaces
v1URL
“schema-set-names”Response body (Reference get all dataspaces)
Code Block {
] }“schemaSetNames”: [“schemaset-1”,” schemaset-1”,” schemaset-1”
Response body (Reference get schema-set)
[ { "dataspaceName": "testDataspace", "moduleReferences": [ { "name": null, "namespace": "http://example.com/example-2", "revision": "2021-01-28" } ], "name": "example-1-yang" }, { "dataspaceName": "testDataspace", "moduleReferences": [ { "name": null, "namespace": "http://example.com/example-2", "revision": "2021-01-28" }Code Block
, "name": "example-2-yang" } ]]
Response body(Reference :get anchors)
[ { "dataspaceName": "testDataspace", "schemaSetName": "testSchema" }, { "dataspaceName": "testDataspace", "schemaSetName": "testSchema"Code Block
, { "dataspaceName": "testDataspace", "schemaSetName": "testSchema" } ]}
List of existing API's that can be updated
...
- Create multiple root nodes in parallel (ref. Jira- CPS-341)
URL : POST http:// IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=/
Existing request payload
New request payload (ref JSON file in CPS-341)
Code Block { "first-container": { "a-leaf": "a-value", "b-leaf": "b-value" } }
Code Block { "first-container": { "a-leaf": "a-value", "b-leaf": "b-value" }, "second-container": { "x-leaf": "x-value", "y-leaf": "y-value" }, "last-container": { "x-leaf": "x-value", "y-leaf": "y-value" } }
Note: For get multiple nodes we will use same API for get singular node to return. Can we have new end point for getting all root nodes ‘/nodes’.
- Create Dataspace should return JSON not have response body
URL : POST http://IP:PORT/cps/api/v1v2/dataspaces?dataspace-name=testDataspace
Current response body
testDataspace
Current response type
Text/plain
New response body
{ “dataspaceName”: “testDataspace” }Code Block
Application/jsonNo response body
New response type
No response type
- Create schema-set should return JSON not have response body
URL : POST http://IP:PORT/cps/api/v1v2/dataspaces/<dataspace-name>/schema-sets
Current response body
schema-set1
Current response type
Text/plain
New response body
{ "dataspaceName": "testDataspace", "moduleReferences": [ { "name": null, "namespace": "http://example.com/example-2", "revision": "2021-01-28" } ], "name": "example-2-yang" }Code Block
Application/jsonNo response body
New response type
No response type
- Create an anchor should return JSON not have response body
URL : POST http://IP:PORT/cps/api/v1v2/dataspaces/<dataspace-name>/anchors?schema-set-name=<schema-set-name>&anchor-name=<anchor_name>
Create Node should return JSON responseCurrent response body
No Content
Current response type
New response body
Code Block { "nodeName": "sampleNode", "anchorName": "testAnchor", "dataspaceName": "testDataspace" }
Application/jsonNew response type
Current response body
anchor-test1
Current response type
Text/plain
New response body
Code Block { "name": "testAnchor", "dataspaceName": "testDataspace", "schemaSetName": "example-2-yang" }
New response type
Application/json
URL: POST http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=/
No response body
New response type
No response type
- Create Node: if leaf list has only one leaf, then don’t force to use [] in request payload?
Current error message:
Only error code 500 Internal Server Error is returned.
The logs are as follows
Code Block org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Node (org:onap:ccsdk:sample?revision=2020-09-15)authors is not a simple type
here authors is name of leaf-list in schema/yang resource
Code Block leaf-list authors { type string; }
Sample error message:
Code Block Node (org:onap:ccsdk:sample?revision=2020-09-15)authors in schema is a leaf-list. Data received is of type list (or leaf).
Note: We need to handle above error and add a leaf list if there is only one leaf in leaf-list without forcing []. Include list as it accepts data without [], so do we need the error or change leaf-list to accept without []
CPS API error responses
Query a node
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes/query?cps-path=/
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
Create Schema Set
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/schema-sets
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
Get a Schema Set
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/schema-sets/<schema-set-name>
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND ",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Schema Set not found.",
"details": "Schema Set with name ABC was not found for dataspace XYZ."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Schema Set not found.",
"details": "Schema Set with name ABC was not found for dataspace XYZ."
} |
Delete Schema
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/schema-sets/<schema-set-name>
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND ",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Schema Set not found.",
"details": "Schema Set with name ABC was not found for dataspace XYZ."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Schema Set not found.",
"details": "Schema Set with name ABC was not found for dataspace XYZ."
} |
Create Anchor
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors?schema-set-name=ran&anchor-name=ran
...
Current Error Code
...
500 Internal Server Error
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND ",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
Get All Anchors
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
Get an Anchor
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
Delete an Anchor
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
{
"status": "400 BAD_REQUEST",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
Create Node
...
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=/
...
Current Error Code
Code Block |
---|
500 Internal Server Error |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Dataspace not found",
"details": "Dataspace with name XYZ does not exist."
} |
...
Current Error Code
Code Block |
---|
500 Internal Server Error |
...
Updated Error Code
Code Block |
---|
{
"status": "404 NOT_FOUND",
"message": "Anchor not found",
"details": "Anchor with name ABC does not exist in dataspace XYZ."
} |
Note: When an invalid json is passed it just returns 400 Bad Request without details. When a valid json is passed with typo then returns 500 server error should be 400 with response message
Get a Node
As per the discussion with CPS team, it was concluded that the proposal for changing the error code response for following API's is not required at the moment. This decision was made with reference to the research and decisions found at the following Epic CPS Exceptions and REST APIs HTTP Response Codes. Although an inconsistency was found with the API "Create a Node" which can be found below at point number 13. It is to be resolved in upcoming release.
Query a node
Create Schema Set
Get a Schema Set
Delete Schema
Create Anchor
Get All Anchors
Get an Anchor
Delete an Anchor
Get a Node
Delete a Node
Replace Descendants of a Node
Update a data node leaves for a given dataspace and anchor and a parent node xpath
Create Node
When an invalid json is passed (for example JSON with missing brackets) API returns 400 Bad Request without details.
When a valid json is passed with typo (for example JSON having a misspelled key) then returns 500 server error, should return 400 with response message
nodeAPI: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/
{Current Error Code
Code Block
"status": "400 BAD_REQUEST", "message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }500
Internal Server Error
Updated Error Code
Code Block
"404 NOT_FOUND",{ "status":
"message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }Current Error Code
{ "status": "400 BADCode Block
"Anchor not found","400 BAD_REQUEST", "message":
"details": "Anchor with name ABC does not exist in dataspace XYZ." }Updated Error Code
Code Block { "status": "404 NOT_FOUND", "message": "Anchor not found", "details": "Anchor with name ABC does not exist in dataspace XYZ." }
Delete a Node
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=/
Current Error Code
{ "status": "400 BAD_REQUEST"Code Block
"message"Dataspace not found",
: "Dataspace not found", ""
"Dataspace with name XYZ does notdetails":
exist.
}"
Updated Error Code
{ "status": "404 NOT_FOUND", "message": "Dataspace not found", "details": "Dataspace with name XYZ does notCode Block
{Dataspace with name XYZ does not exist." }
Current Error Code
Code Block
"status": "400 BAD_REQUEST", "message": "Anchor not found", "details": "Anchor with name ABC does not exist in dataspace XYZ." }500
Updated Error Code
Code Block { "status": "404 NOT_FOUND", "message": "Anchor not found", "details": "Anchor with name ABC does not exist in dataspace XYZ." }
Replace Descendants of a Node
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=
Current Error Code
Code Block { "status": "400 BAD_REQUEST", "message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }
"404 NOT_FOUND",Internal Server Error
Updated Error Code
Code Block { "status":
"message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }Current Error Code
{ "status": "400 BADCode Block
": "Anchor not found", "details"400 BAD_REQUEST", "message
"Anchor with name ABC does not exist in dataspace XYZ."":
}Updated Error Code
{ "status": "404 NOT_FOUND", "message": "Anchor not found"Code Block
"Anchor with name ABC does not exist in dataspace XYZ.""Anchor not found", "details":
}Update a data node leaves for a given dataspace and anchor and a parent node xpath
API: http://IP:PORT/cps/api/v1/dataspaces/<dataspace-name>/anchors/<anchor-name>/nodes?xpath=
Current Error Code
Code Block { "status": "400 BAD_REQUEST", "message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }
Updated Error Code
Code Block { "status": "404 NOT_FOUND", "message": "Dataspace not found", "details": "Dataspace with name XYZ does not exist." }
Current Error Code
Code Block { "status": "400 BAD_REQUEST", "message": "Anchor not found", "details": "Anchor with name XYZ does not exist in dataspace XYZ." }
Updated Error Code
Note: when successful only returns 200 OK status code nothing in response body Need a response body in json formatCode Block { "status": "404 NOT_FOUND", "message": "Anchor not found", "details": "Anchor with name XYZ does not exist in dataspace XYZ." }
"Anchor with name ABC does not exist in dataspace XYZ." }