DuraCloud Release 3.1 : REST API Examples Using curl

 

Convenience Variables

The curl commands below can be used directly if you define the following variables in your shell

host=<duracloud-hostname>
space-0=<any-name>
space-1=<any-name>
user=<username>
pword=<password>
file=<any-file-name>

DuraStore Notes

The curl commands in the DuraStore section expect a test file for uploads.

echo hello > ${file}

Note that if the target of a content or space retrieval (GET) has access permissions set to "OPEN", then the "-u" option in the curl commands is not required.

DuraStore

Get Stores
curl -u ${user}:${pword} https://${host}/durastore/stores
Get Spaces
curl -u ${user}:${pword} https://${host}/durastore/spaces
curl -u ${user}:${pword} https://${host}/durastore/spaces?storeID=1
Create Space
curl -u ${user}:${pword} -X PUT https://${host}/durastore/${space-0}
curl -u ${user}:${pword} -H "x-dura-meta-city: arlington" -H "x-dura-meta-state: va" -X PUT https://${host}/durastore/${space-1}?storeID=1
Store Content
curl -u ${user}:${pword} -T ${file} https://${host}/durastore/${space-0}/test.txt
curl -u ${user}:${pword} -T ${file} https://${host}/durastore/${space-0}/item.txt
Get Space
curl -u ${user}:${pword} https://${host}/durastore/${space-0}
curl -u ${user}:${pword} https://${host}/durastore/${space-1}?storeID=1
curl -u ${user}:${pword} https://${host}/durastore/${space-0}?prefix=test
Set Space Properties
curl -u ${user}:${pword} -H "x-dura-meta-country: usa" -X POST https://${host}/durastore/${space-0}
Get Space Properties
curl -u ${user}:${pword} -I https://${host}/durastore/${space-0}
curl -u ${user}:${pword} -I https://${host}/durastore/${space-1}?storeID=1
Get Content
curl -u ${user}:${pword} https://${host}/durastore/${space-0}/test.txt
curl -u ${user}:${pword} https://${host}/durastore/${space-0}/test.txt?storeID=0\&attachment=true
Set Content Properties
curl -u ${user}:${pword} -X POST -H "x-dura-meta-color: green" https://${host}/durastore/${space-0}/test.txt
Get Content Properties
curl -u ${user}:${pword} -I https://${host}/durastore/${space-0}/test.txt
Delete Content
curl -u ${user}:${pword} -X DELETE https://${host}/durastore/${space-0}/test.txt
Delete Space
curl -u ${user}:${pword} -X DELETE https://${host}/durastore/${space-0}
curl -u ${user}:${pword} -X DELETE https://${host}/durastore/${space-1}?storeID=1

DuraBoss Report API

Get Latest Storage Report
curl -u ${user}:${pword} https://${host}/duraboss/report/storage
Get Storage Report List
curl -u ${user}:${pword} https://${host}/duraboss/report/storage/list
Get Storage Report Info
curl -u ${user}:${pword} https://${host}/duraboss/report/storage/info
Start Storage Report
curl -u ${user}:${pword} -X POST https://${host}/duraboss/report/storage
Stop Storage Report
curl -u ${user}:${pword} -X DELETE https://${host}/duraboss/report/storage
Schedule Storage Report (to begin Jan 1, 2020 at 01:01:01 and repeat every 10 min)
curl -u ${user}:${pword} -X POST https://${host}/duraboss/report/storage/schedule?startTime=1577840461000\&frequency=600000
Cancel Storage Report Schedule
curl -u ${user}:${pword} -X DELETE https://${host}/duraboss/report/storage/schedule