Usage examples in CURL

Review this section for code examples that are generated using curl. You can use this information as reference for performing different procedures.

Notes:
  • The following curl usage examples do not include all actions that might be taken on system objects.
  • For usage examples made using the Python 3 language, see Getting started.
  • For examples that use the Perl programming language, see RESTful API usage examples in Perl.
Each curl example takes the following form:
curl -k -X POST -H header_1 -H header_2... -d 
‘JSON’ https://system_ip:7443/rest/target

Where the following definitions apply:

  • POST is the only HTTPS method that the Spectrum Virtualize RESTful API supports.
  • Headers (header_1 ) are individually-specified HTTP headers (for example, Content-Type and X-Auth­Username).
  • -d is followed by JSON input (for example, ‘{"raid_level": "raid5"}’).
  • system_ip is the IP address to which you are sending requests.
  • target is the target object of commands, which includes any object IDs, names, and parameters.

Authentication

The following is an example of the correct procedure for authenticating. You authenticate by first producing an authentication token and then using that token in all future commands until the session ends. For more information on authentication, see Authentication overview and API management.
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Username: 
superuser' -H 'X-Auth-Password: passw0rd' 
https://192.168.10.109:7443/rest/auth
This yields an authentication token that you use for all other commands.
{"token": "38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e"}

Making an array

You can use commands only after authentication, including the command to make an array on the system. The following example demonstrates the use of the token in place of the authentication headers used in the authentication process.
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: 
38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e'
-d '{"level": "draid6", "drive": "6:7:8:9:10", "draid6grp"}'
           https://192.168.10.109:7443/rest/mkarray

Changing array settings

The next example shows how to modify an array member's attributes to change member 24 for new drive 15 by using a distributed rebuild to a rebuild area:
curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: 
38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e'
-d '{"member": "24", "newdrive": "15",
     "immediate": "0"}' https://192.168.10.109:7443/rest/charraymember

Removing the array

The final example shows how to remove an array MDisk from the storage pool. For more information on managing the array, see rmarray.

curl -k -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: 
38823f60c758dca26f3eaa17dc4664964905a6f058ae2ec92e0f0b63fcf08a3e' 
-d '{"mdisk": "6", "mdiskgrp_10"}' https://192.168.10.109:7443/rest/rmarray