Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Issues and Decisions

DateIssue/QuestionsDecisions

 

Should dry-run be a path parameter or a query parameter? 

Overview

Currently when persisting any data in CPS the data validation is performed using the yang schema and upon successful validation the data is stored in CPS DB. But in case the data validation fails a 500 response is returned by CPS.

...

The following example shows the expected changes to existing APIs to implement a dry-run flag:

#API

Request parameters

Response CodesScenarios
1

Create a Node:

/v2/dataspaces/{dataspace-name}/anchors/{anchor-name}/nodes


Parameter NameInRequiredDescription
dataspace-namePathtruedataspace name
anchor-namePathtrueanchor name
xpathQuerytruexpath of node
dry-runQueryfalse

flag to enable or disable data validation

(set to false by default)


  • 200 (OK)
    • success
  • 400
    • dataspace not found
      DataspaceNotFoundException
    • anchor not found
      AnchorNotFoundException
    • Data node not found
      DataNodeNotFoundException
    • invalid xpath
      CpsPathException
  • 500
    • unexpected error

Scenario 1: dry run set to false

  • In this case there will be no functional change in the APIs, and they would return appropriate response codes with messages in case of any failure.
  • In case of successful validation, the data will be persisted, and a 200-response code is returned with nothing in response body
  • In case of validation failure, the data validation error is returned with appropriate message and a 400-response code.

Scenario 2: dry run set to true

  • In this case the APIs will return the same response codes. The only difference will be
,
  • :
    • in case data validation passes, then it would return a 200-response code without any response body,
but
    • and the data will not be persisted in case of POST operation or modified in case of PUT/PATCH operations.
    • another approach that can be taken here is, in case it passes validation, then a 200-response code will be returned with response message saying that validation has passed but the data will not be persisted or modified.
    • In case of validation failure, the data validation error is returned with appropriate message and a 400-response code.

References:

...