...
RESTCONF/NETCONF relationship
![](/download/attachments/103420488/image2021-5-10_16-28-3.png?version=1&modificationDate=1623147106000&api=v2)
REST Data API
Request Format for Data Access
The DMI APIs for data access are similar to corresponding NCMP APIs. The following list is a summary of the main differences:
- The URI prefix is /dmi instead of /ncmp.
- For non-passthrough datastores, the resource path will be converted from cpsPath to RESTConfPath
The body for each request will contain additional information and any data provided on the NCMP interface (write operations) will be embedded in a larger JSON structure as described in example below.
Since all requests will have a message body, in some cases the HTTP method will be different to allow passing data. Thus PUT is used instead of GET and DELETE.
Request Format for Data Access
Code Block |
---|
language | xml |
---|
title | request body |
---|
|
{
|
Code Block |
---|
language | xml |
---|
title | request body |
---|
|
{
“operation”: “<operation>”, // Valid operations are: “create”, “read”, “update” and “delete”.
// For update, replace and patch is distinguished by the HTTP method (PUT or PATCH).
“data-type”: “<mime-type>”, // Indicates format for the embedded data.
// Shall use MIME type syntax, e g “application/yang-data+json”.
// Shall only be present for create and update operations.
“data”: { // Embedded data. Must be valid JSON object.
<data> // Shall only be present for create and update operations.
},
“additionalProperties”: { // Additional properties for CM handle previously added by DMI plugin and stored in NCMP.
<properties>
}
} for create and update operations.
},
“additionalProperties”: { // Additional properties for CM handle previously added by DMI plugin and stored in NCMP.
<properties>
}
} |
Expand |
---|
|
Expand |
---|
|
The DMI APIs for data access are similar to corresponding NCMP APIs. The following list is a summary of the main differences:
The URI prefix /dmi instead of /ncmpFor non-passthrough datastores, the resource path will be converted from cpsPath to RESTConfPathThe body for each request will contain additional information and any data provided on the NCMP interface (write operations) will be embedded in a larger JSON structure as described in request format for data access above.
Since all requests will have a message body, in some cases the HTTP method will be different to allow passing data. Thus PUT is used instead of GET and DELETE. |
| Usecase | REST Method | URI |
---|
1 | Add a data resource for a cmHandle | POST | {dmi-root}/dmi/v1/ch/<cmhandle>/data/ds/ncmp-datastore:running/{parent-data-resource-identifier} { <new-yang-data-resource> } Content-Type: application/json "data" payload : yang-data+json | 2 | Delete a data resource for a cmHandle | PUT | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:running/{resource-identifier} | 3 | Patch a data resource for a cmHandle | PATCH | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:running/{resource-identifier} { <yang-data-for-merging> } Content-Type: application/json "data" payload : yang-data+json | 4 | Patch multiple child resources for a single cmHandle | PATCH | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:running/{resource-identifier}
Content-Type: application/json "data" payload : yang-patch+json | 5 | Execute a yang action on a cmhandle instance | POST | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:operational/{resource-identifier}/{action}
input: { "param1Name" :"param1Value”, "param2Name" : "param2Value” }
Note : If the "action" statement has no "input" section, the request message MUST NOT include a message-body | 6 | Execute an rpc operation | POST | {dmi-root}/dmi/v1/operations/ch/<cm-handle>/ds/ncmp-datastore:operational/ {module-name}:{action} { input: { "param1Name" : "param1Value”, "param2Name" : "param2Value” } } Note: If there is no "input" section, the request MUST NOT include a message-body | 7 | Read a filtered set of data under a data resource for a cmHandle | PUT | {dmiroot}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:operational/{resource-identifier}?fields={fields-expression} Option | Description |
---|
fields | Request a subset of the target resource contents |
| 8 | Read data resources with specified fields under a given data resource for a given cmHandle | PUT | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:operational/{resource-identifier}?fields={fields-expression}
Option | Description |
---|
fields | Request a subset of the target resource contents |
| 9 | Get data resource with 'fileds' for a cmhandle with a given scope condition | PUT | {dmi-root}/dmi/v1/ch/{cm-handle}/data/ds/ncmp-datastore:operational/{resourcepath}?fields={fields}&scope={scope} | 10 | Read descendant nodes to a given depth for a given cmHandle | PUT | {dmi-root}/dmi/v1/ch/{cm-handle}/data/ds/ncmp-datastore:operational/{resource-identifier}?depth={level}
Option | Description |
---|
depth | Request limited sub-tree depth in the reply content If '1' then only immediate resource is retrieved If '2' then resource plus next level resources are retrieved |
| 11 | Replace data for a CMHandle | PUT | {dmi-root}/dmi/v1/ch/<cm-handle>/data/ds/ncmp-datastore:running/{resource-identifier} {data : { .... the complete tree config to be replaced }} |
|
...