Operations

The HTTP methods are used for manipulating the resource defined in the YANG model for the CRUD operations. You must employ appropriate access control mechanisms to limit what operations can be allowed by a user.

POST Method

The POST method is sent by the client to create a data resource or invoke an operation resource. The server uses the target resource type to determine how to process the request. It is supported for all the resource types. Use the POST method to create the top-level configuration data resource or to create a child data resource. You can use the POST method to invoke RPC operation. The message-body or the payload in the POST method contain the resource to be created. When the creation is successful, "201 Created" status line is returned and there is no response message-body.

To create a top-level resource, use the following example.

curl -v -X POST -d "<mpls />" -u admin:password https://<> /restconf/data/brocade-mpls:mpls-config/router 
-H "Content-Type: application/yang-data+xml"
Response body
< HTTP/1.1 201 Created
< Date: Wed, 02 Nov 2016 22:46:15 GMT
< Server: SLX-OS WWW
< Authentication-Token: TEM5Wk59XV5xRFxOdVtydF9kWDZwd2hHRGV6Q0B0NXk=
< Location: http://localhost/rest/config/running/router/mpls
< Cache-control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 0
< Content-Type: text/html
< 
* Connection #0 to host 10.24.12.135 left intact
If the data resource already exists, the POST request fails and a "409 Conflict" status-line is returned. The error-tag value "resource-denied" is used in this case.
curl -v -X POST -H "Content-Type: application/yang-data+json" -d "{\"mpls\": {}}
-u admin:password https://<> /restconf/data/brocade-mpls:mpls-config/router -k
In case of a conflict, you receive the following response.
< HTTP/1.1 409 Conflict
< Date: Thu, 16 Feb 2017 20:21:37 GMT
< Server: SLX-OS WWW
< Authentication-Token: ZjlLUzswdkY9XkZbNUVoOmwzVFdoUkhtWF1Lc0NsWH0=
< Cache-control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 62
< Content-Type: text/json

  {
  "error": {
    "-xmlns": "urn:ietf:params:xml:ns:yang:ietf-restconf",
    "error-type": "protocol",
    "error-tag": "resource-denied",
    "error-message": "Data resource already exists"
  }
}
The following example invokes an RPC operation.
curl -v -k -X POST -H "Accept: application/yang-data+xml" -d "<show-firmware-version></show-firmware-version>" 
-u admin:password https://10.20.192.65:443/restconf/operations/show-firmware-version
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 10.20.192.65...
* TCP_NODELAY set
* Connected to 10.20.192.65 (10.20.192.65) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=IN; ST=TN; L=CHN; O=HCL; OU=SQA; CN=10.20.192.65
*  start date: Dec 26 12:00:30 2019 GMT
*  expire date: Dec 25 12:00:30 2020 GMT
*  issuer: C=IN; ST=TN; L=CHN; O=HCL; OU=SQA; CN=10.20.192.65; emailAddress=dpanneerselvam@extreme.com
*  SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* Server auth using Basic with user 'admin'
> POST /restconf/operations/show-firmware-version HTTP/1.1
> Host: 10.20.192.65
> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
> User-Agent: curl/7.58.0
> Accept: application/yang-data+xml
> Content-Length: 47
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 47 out of 47 bytes
< HTTP/1.1 200 OK
< Date: Fri, 27 Dec 2019 10:46:10 GMT
< Server: SLX-OS WWW
< Authentication-Token: VG5OY3dwTmgvTDFadVpeeVBna1U5ZExcVl9Fb1R7aHE=
< Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 1169
< Content-Type: application/yang-data+xml
< Vary: Accept-Encoding
< Pragma: no-cache
<
<output xmlns='urn:brocade.com:mgmt:brocade-firmware-ext'>
  <show-firmware-version>
    <os-name>SLX-OS Operating System Software</os-name>
    <os-version>20.1.1</os-version>
    <copy-right-info>Copyright (c) 1995-2019 Extreme Networks, Inc.</copy-right-info>
    <build-time>Thu Dec 26 11:10:42 2019
</build-time>
    <firmware-full-version>20.1.1_bld85</firmware-full-version>
    <control-processor-vendor> GenuineIntel</control-processor-vendor>
    <control-processor-chipset> Intel(R) Xeon(R) CPU D-1527 @ 2.20GHz</control-processor-chipset>
    <control-processor-cpucores> 4 cores</control-processor-cpucores>
    <control-processor-microcode> 0x7000017</control-processor-microcode>
    <control-processor-memory>31653 MB</control-processor-memory>
    <node-info>
      <slot-no>0</slot-no>
      <node-instance-no>1</node-instance-no>
      <node-type>type-mm</node-type>
      <firmware-version-info>
        <application-name>SLX-OS</application-name>
        <primary-version>20.1.1_bld85</primary-version>
        <secondary-version>20.1.1_bld85</secondary-version>
      </firmware-version-info>
    </node-info>
  </show-firmware-version>
</output>
* Connection #0 to host 10.20.192.65 left intact

PUT Method

The PUT method is sent by the client to create or replace the target data resource. The target resource for PUT method for data creation is the new resource. Both data and datastore is supported for PUT method. A request message-body must be present, representing the new data resource, else the server returns "400 Bad Request" status-line. The error-tag value "invalid-value" is used in this case.

When new data resource is created, PUT method respond as "201 Created" as shown below .
curl -v -X PUT -d "<lsp-metric>20</lsp-metric>" -u admin:password 
https://10.24.12.133:443/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/lsp=lsp1/lsp-metric
Response body
HTTP/1.1 201 Created
      Date: Mon, 23 Apr 2016 17:04:00 GMT
      Server: example-server
      Last-Modified: Mon, 23 Apr 2016 17:04:00 GMT
When the same data resource is updated, PUT method respond as "204 No Content" as shown below.
curl -v -X PUT -d "<lsp-metric>22</lsp-metric>" -u admin:password 
https://10.24.12.133:443/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/lsp=lsp1/lsp-metric
Response body
HTTP/1.1 204 No Content
      Date: Mon, 23 Apr 2016 17:04:00 GMT
      Server: example-server
      Last-Modified: Mon, 23 Apr 2016 17:04:00 GMT

PATCH Method

The PATCH method is used for creating or updating the child resource. Here, only the mere PATCH method is supported. A request message-body must be present, representing the new data resource, otherwise the server returns "400 Bad Request" status-line. The error-tag value "invalid-value" is used in this case. The target resource must be the parent of the child resource to be created.

For Leaflist case, you must not use this method to change the key values of the leaf list instance.
curl -v -X PATCH -d “<policy><retry-time>{uint32}</retry-time></policy>" -u admin:password 
http://10.24.12.135:443/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/mpls/policy 
-H "Accept: application/yang-data+xml"
Response body
HTTP/1.1 204 No Content
      Date: Mon, 23 Apr 2016 17:04:00 GMT
      Server: example-server
      Last-Modified: Mon, 23 Apr 2016 17:04:00 GMT
If you try to PATCH a request which is not available, a Bad Request status line is returned and the error tag as invalid-value is used.
curl -v -X PATCH -d <policy3><retry-time>{uint32}</retry-time></policy3>" 
-u admin:password http://10.24.12.135:443/restconf/data/brocade-mpls:mpls-config/router/mplsmpls-cmds-holder/mpls/policy3/ 
-H "Accept: application/yang-data+xml"
Response body
< HTTP/1.1 400 Bad Request
< Date: 2017-02-16 20:53:01
< Server: SLX-OS Wave WWW
< Authentication-Token: fGVXWXlHYEo7Yl52W1YzRTBXVztTb3BvamltUDZPY0c=
< Cache-control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Type: text/html
< Content-Length: 0
< Connection: close
<
<error xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error-type>protocol</error-type>
    <error-tag>invalid-value</error-tag>
    <error-message>Data resource does not exists</error-message>
  </error>

DELETE Method

The DELETE method is used to delete the target resource. If the DELETE request succeeds, a "204 No Content" status-line is returned. If the target resource represents a configuration leaf-list or list data node, it must represent a single YANG leaf-list or list instance.
curl -v -X DELETE -u admin:password 
https://<>/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/mpls/policy 
-H "Accept: application/yang-data+xml"
HTTP/1.1 204 No Content
      Date: Mon, 23 Apr 2016 17:49:40 GMT
      Server: example-server
If a DELETE request is sent for unconfigured data resource. Then the server responds as "Not found.
curl -v -X DELETE -u admin:password 
https://<>/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/mpls/policy 
-H "Accept: application/yang-data+xml"
Response body
< HTTP/1.1 404 Not Found
< Server: 
< Date: Thu, 27 Apr 2017 09:18:11 GMT
< Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 0
< Content-Type: text/html
< Pragma: no-cache
If a DELETE request is sent for data resource which is unknown to server, it responds as "Bad Request" and a bad-element error-tag is shown below.
curl -v -X DELETE -u admin:password 
https://<>/restconf/data/brocade-mpls:mpls-config/router/mpls/mpls-cmds-holder/mpls/policy123 
-H "Accept: application/yang-data+xml"
Response body
HTTP/1.1 400 Bad Request
      Date: Mon, 23 Apr 2016 17:49:40 GMT
      Server: example-server

   <error xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error-type>protocol</error-type>
    <error-tag>bad-element</error-tag>
    <error-message>Data resource does not exists</error-message>
    </error>