Go to main content

Remote Administration Daemon Developer's Guide

Exit Print View

Updated: April 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 58  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 \
 localhost/api/com.oracle.solaris.rad.zfsmgr/1.0/ZfsDataset/rpool/_rad_method/create_filesystem \ 
 --unix-socket /system/volatile/rad/radsocket-http -b cookie.txt \ 
 --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 59  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 \
 localhost/api/com.oracle.solaris.rad.dlmgr/1.0/Datalink/net0/_rad_method/setProperty \
 --unix-socket /system/volatile/rad/radsocket-http \ 
 --data '{"properties":"maxbw=300","flags":1}' -b cookie.txt

Sample response:

{
        "status": "success",
        "payload": null
}
Example 60  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 \
 localhost/api/com.oracle.solaris.rad.zfsmgr/1.0/ZfsDataset/rpool/_rad_method/get_filesystems \ 
 --unix-socket /system/volatile/rad/radsocket-http -b cookie.txt \
 --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 61  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 \
    localhost/api/com.oracle.solaris.rad.usermgr/1.0/UserMgr/_rad_method/deleteUser \ 
    --data '{"username":"tuser4"}' \
    --unix-socket /system/volatile/rad/radsocket-http -b cookie.txt

Sample response:

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