Go to main content

Remote Administration Daemon Client User's Guide

Exit Print View

Updated: November 2020
 
 

REST Requests

    A REST request is associated with an HTTP operation and can use any of the following HTTP operations based on the type of request:

  • GET – Retrieve a resource or a collection of resources

  • POST – Create a new resource

  • PUT – Update a resource

  • DELETE – Delete a resource

    Because REST for RAD supports only JSON as the content type, you must include one of the following values in the HTTP header of a REST request:

  • Set the value of the Content-Type field to application/json.

  • Set the value of the Accept field to */* or application/json.

REST Request Examples

The following examples show how to use REST to create, read, update, and delete RAD resources.

Example 49  Creating a Resource by Using REST

This example shows how to create a ZFS file system named p2 in rpool/export/home/testuser.

Sample request:

# curl -H 'Content-Type:application/json' -X PUT -b cookiejar \
   https://radserver.example.com/api/com.oracle.solaris.rad.zfsmgr/1.0/ZfsDataset/rpool/_rad_method/create_filesystem \
   --data '{"name":"rpool/export/home/testuser/p2"}'

Sample response:

{
        "status": "success",
        "payload": {
                "href": "/api/com.oracle.solaris.rad.zfsmgr/1.0/ZfsDataset/_rad_reference/5889"
        }
}
Example 50  Updating a Resource by Using REST

This example shows how to update the value of the maxbw property for the net0 interface.

Sample request:

# curl -H 'Content-Type:application/json' -X PUT -b cookiejar \
   https://radserver.example.com/api/com.oracle.solaris.rad.dlmgr/1.1/Datalink/net0/_rad_method/setProperty \
   --data '{"properties":"maxbw=300","flags":1}'

Sample response:

{
        "status": "success",
        "payload": null
}
Example 51  Querying a Resource by Using REST

This example shows how to get a list of all the ZFS file systems available in rpool.

Sample request:

# curl -H 'Content-Type:application/json' -X PUT -b cookiejar \
   https://radserver.example.com/api/com.oracle.solaris.rad.zfsmgr/1.0/ZfsDataset/rpool/_rad_method/get_filesystems \
   --data'{"recursive":true}'

Sample response:

{
        "status": "success",
        "payload": [
                "rpool/ROOT",
                "rpool/ROOT/solaris",
                "rpool/ROOT/solaris/var",
                "rpool/VARSHARE",
                "rpool/VARSHARE/zones",
                "rpool/VARSHARE/pkg",
                "rpool/VARSHARE/pkg/repositories",
                "rpool/export",
                "rpool/export/home",
                "rpool/export/home/testuser"
        ]
}
Example 52  Deleting a Resource by Using REST

This example shows how to delete a user named tuser4.

Sample request:

# curl -H 'Content-Type:application/json' -X PUT -b cookiejar \
    https://radserver.example.com/api/com.oracle.solaris.rad.usermgr/1.0/UserMgr/_rad_method/deleteUser \
    --data '{"username":"tuser4"}'

Sample response:

{
        "status": "success",
        "payload": null
}