REST APIs
Overview
vME APIs is the REST APIs to manage ZFS elements and container engine on vME appliance.
info
Each API contains a header consisting of username and api-key:
headers = {
"username" : <username>,
"api-key": <api-key>
}
Elementary Management APIs
Pool APIs
Show pools
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/pool/show"
response = requests.get(url, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/pool/show"
Create a pool
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/pool/create"
parameters = {
"name" : "demo-pool"
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-pool"}' \
"https://<vME_ip_address>/pool/create"
Parameters:
name
- required. A name of a pool to be created.device
- optional. A path of device, default is<empty_string>
. If the given device path is empty or unfound, it will be generated with the following details:device_path
- optional. A head path of device, default is/opt/vme
.device_name
- optional. A name of device, default is None. The device_name will be generated by 8 characters random name if it is None.cap
- optional. A size of device (Mb), default is24000
.
Destroy a pool
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/pool/destroy"
parameters = {
"name" : "demo-pool"
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-pool"}' \
"https://<vME_ip_address>/pool/destroy"
Parameters:
name
- required. A name of a pool to be destroyed.
Source APIs
Show sources
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/source/show"
parameters = {
'pool_name' : 'demo-pool'
}
response = requests.get(url, params=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/source/show?pool_name=demo-pool"
Parameters:
pool_name
- optional. A name of pool. If the pool name is satisfied, all sources contained in the given pool will be shown.source_name
- optional. A name of source. If the parent source name is satisfied, all sub-sources of the given source will be shown.
Create a source
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/source/create"
parameters = {
'pool_name' : 'demo-pool',
'name' : 'foo',
'compression' : 'lzjb'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "name": "foo", "compression" : "lzjb"}' \
"https://<vME_ip_address>/source/create"
Parameters:
name
- required. A name of a source to be created.pool_name
- optional. A name of a pool that the source will be created inside, default isvme-pool
.dbtype
- optional. A database type name, such as mysql, mariadb, mssql, mongodb etc., used to label a source, default isunknown
.quota
- optional. A limitation size property of the created source, default isNone
.compression
- optional. A compression type property of the created source, i.e.on
,off
,lzjb
,gzip
,gzip-1
,gzip-2
,gzip-3
,gzip-4
,gzip-5
,gzip-6
,gzip-7
,gzip-8
,gzip-9
,zle
,lz4
, default isoff
.
Rename a source
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/source/rename"
parameters = {
'pool_name' : 'demo-pool',
'currentname' : 'foo',
'newname' : 'foo-foo'
}
response = requests.put(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X PUT \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "currentname": "foo", "newname": "foo-foo"}' \
"https://<vME_ip_address>/source/rename"
Parameters:
currentname
- required. A previous source name.newname
- required. A new source name.pool_name
- required. A name of a pool that used to specify the renamed source.
Destroy a source
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/source/destroy"
parameters = {
"pool_name" : "demo-pool",
"source_name" : "foo"
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo"}' \
"https://<vME_ip_address>/source/destroy"
Parameters:
source_name
- required. A name of a source to be destroyed.pool_name
- required. A name of a pool that used to specify the destroyed source.
Snapshot APIs
Show snapshots
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/snapshot/show"
parameters = {
'pool_name' : 'demo-pool'
}
response = requests.get(url, params=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/snapshot/show?pool_name=demo-pool"
Parameters:
pool_name
- optional. A name of a pool. If the pool name is satisfied, all snapshots of any sources inside the given pool will be shown.source_name
- optional. A name of a source. If the source name is satisfied, all snapshots of the given source will be shown.sort
- optional. Boolean option to sorting the snapshot by date creation, default isFalse
.
Create a snapshot
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/snapshot/create"
parameters = {
'pool_name' : 'demo-pool',
'source_name' : 'foo',
'name' : 'today'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo", "name": "today"}' \
"https://<vME_ip_address>/snapshot/create"
Parameters:
name
- required. A name of a snapshot to be created.source_name
- required. A name of a source for the created snapshot.pool_name
- optional. A name of a pool that used to specify the source, default isvme-pool
.recursive
- optional. Recursive option, default isFalse
.
Rename a snapshot
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/snapshot/rename"
parameters = {
'pool_name' : 'demo-pool',
'source_name' : 'foo',
'currentname' : 'today',
'newname' : 'tomorrow'
}
response = requests.put(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X PUT \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo", "currentname": "today", "newname": "tomorrow"}' \
"https://<vME_ip_address>/snapshot/rename"
Parameters:
currentname
- required. A previous snapshot name.newname
- required. A new snapshot name.source_name
- required. A name of a source for the renamed snapshot.pool_name
- optional. A name of a pool that used to specify the source, default isvme-pool
.
Rollback a snapshot
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/snapshot/rollback"
parameters = {
'pool_name' : 'demo-pool',
'source_name' : 'foo',
'snapshot_name' : 'today'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo", "snapshot_name": "today"}' \
"https://<vME_ip_address>/snapshot/rollback"
Parameters:
snapshot_name
- required. A name of a snapshot to be rollbacked.source_name
- required. A name of a source for the rollbacked snapshot.pool_name
- optional. A name of a pool that used to specify the source, default isvme-pool
.
Destroy a snapshot
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/snapshot/destroy"
parameters = {
"pool_name" : "demo-pool",
"source_name" : "foo",
"snapshot_name" : "today"
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo", "snapshot_name": "today"}' \
"https://<vME_ip_address>/snapshot/destroy"
Parameters:
snapshot_name
- required. A name of a snapshot to be destroyed.source_name
- required. A name of a source for the destroyed snapshot.pool_name
- optional. A name of a pool that used to specify the source, default isvme-pool
.
Clone APIs
Show clones
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/clone/show"
parameters = {
'pool_name' : 'demo-pool'
}
response = requests.get(url, params=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/clone/show?pool_name=demo-pool"
Parameters:
pool_name
- optional. A name of a pool. If the pool name is satisfied, all clones contained in the given pool will be shown.source_name
- optional. A name of a source. If the source name is satisfied, all clones of the given source will be shown.snapshot_name
- optional. A name of a snapshot. If the snapshot name is satisfied, all clones related with the given snapshot will be shown.
Create a clone/clonefarm
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/clone/create"
parameters = {
'pool_name' : 'demo-pool',
'source_name' : 'foo',
'snapshot_name' : 'today',
'name' : 'foo-copy'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "source_name": "foo", "snapshot_name": "today", "name": "foo-copy"}' \
"https://<vME_ip_address>/clone/create"
Parameters:
snapshot_name
- required. A name of a snapshot for the craeted clone.name
- optional. A name of a clone to be created. The name will be auto-generated if it isn't assigned.source_name
- optional. A name of a source with respect to asnapshot_name
. It will be in requried if the snapshot name isn't full-path name.pool_name
- optional. A name of a pool that used to specify the source, default isvme-pool
.size
- optional. A number of clonefarm, default is1
.dbtype
- optional. A database type name, such as mysql, mariadb, mssql, mongodb etc., used to label a source, default isunknown
.
Rename a clone
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/clone/rename"
parameters = {
'pool_name' : 'demo-pool',
'currentname' : 'foo-copy',
'newname' : 'foo-copy-2'
}
response = requests.put(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X PUT \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "currentname": "foo-copy", "newname": "foo-copy-2"}' \
"https://<vME_ip_address>/clone/rename"
Parameters:
currentname
- required. A previous clone name.newname
- required. A new clone name.pool_name
- required. A name of a pool that used to specify the renamed clone.
Destroy a clone
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/clone/destroy"
parameters = {
"pool_name" : "demo-pool",
"clone_name" : "foo-copy"
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"pool_name": "demo-pool", "clone_name": "foo-copy"}' \
"https://<vME_ip_address>/clone/destroy"
Parameters:
clone_name
- required. A name of a clone to be destroyed.pool_name
- required. A name of a pool that used to specify the destroyed clone.
Container APIs
Pull database image
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/image/pull"
parameters = {
'repository' : 'mariadb',
'tag' : 'latest'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"repository": "mariadb", "tag": "latest"}' \
"https://<vME_ip_address>/docker/image/pull"
Parameters:
repository
- required. The repository name/path.tag
- optional. The image tag, default islatest
.dbtype
- optional. A database type name, such as mysql, mariadb, mssql, mongodb etc. that used to label an image, default isrepository
name.credential
- optional. A credential for the pulling requirement, for example{"username" : <username>, "password" : <password>}
.
info
List all database images
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/image/list"
response = requests.get(url, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/docker/image/list"
Remove a database image
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/image/remove"
parameters = {
'image' : 'mariadb'
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"image": "mariadb"}' \
"https://<vME_ip_address>/docker/image/remove"
Parameters:
image
- required. An imagename
orname:tag
orid
to be removed.
Create a database container
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/container/create"
parameters = {
'image' : 'mariadb:latest',
'name' : 'demo-db-01',
'volumes' : ['/demo-pool/clones/foo-copy:/var/lib/mysql'],
'environment' : ['MARIADB_ROOT_PASSWORD=Default123'],
'ports' : "12341:3306"
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{ "image": "mariadb:latest", "name": "demo-db-01", "volumes": ["/demo-pool/clones/foo-copy:/var/lib/mysql"], "environment": ["MARIADB_ROOT_PASSWORD=Default123"], "ports": "12341:3306"}' \
"https://<vME_ip_address>/docker/container/create"
Parameters:
image
- required. An image name.name
- optional. A name of a container to be created. The name will be random generated if it isn't assigned.environment
- optional. Environment variables to set inside the container, as a dictionary or a list of strings in the format["SOMEVARIABLE=xxx"]
.volumes
- optional. A list or dictionary to configure volumes mounted inside the container. The list consists of the couple path strings that is of the form"<source/clone_path>:<container_db_path>"
.ports
- optional. Ports to bind inside the container. It is a string as the form"<host_port>:<container_port>"
where the container port is an exposed port. For example:"12345:3306"
for MySQL. One can assign it in several ports as separable by comma , or a range, i.e."12345:3306,8888:8080"
or"12345:3306,8880-8888:8080-8088"
.dbtype
- optional. A database type name, such as mysql, mariadb, mssql, mongodb etc., used to label a container, default is<dbtype_of_image>
.
List all database containers
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/container/list"
response = requests.get(url, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X GET \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
"https://<vME_ip_address>/docker/container/list"
Start a database container
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/container/start"
parameters = {
'name' : 'demo-db-01'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-db-01"}' \
"https://<vME_ip_address>/docker/container/start"
Parameters:
name
- required. A containername
orid
.
Stop a database container
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/container/stop"
parameters = {
'name' : 'demo-db-01'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-db-01"}' \
"https://<vME_ip_address>/docker/container/stop"
Parameters:
name
- required. A containername
orid
.
Remove a database container
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/container/image/remove"
parameters = {
'name' : 'demo-db-01',
'volume' : true
}
response = requests.delete(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X DELETE \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-db-01", "volume" : true}' \
"https://<vME_ip_address>/docker/container/remove"
Parameters:
name
- required. A containername
orid
to be removed.volume
- optional. Boolean option to remove the volumes associated with the container, default isFalse
.
Execute a command inside the database container
- Python
- Curl
# Download the requests library from https://docs.python-requests.org/en/latest/
import requests
url = "https://<vME_ip_address>/docker/container/exec"
parameters = {
'name' : 'demo-db-01',
'command' : 'mysql --user=root --password=\"default123\" -e \"source /var/lib/mysql/nation.sql\"'
}
response = requests.post(url, json=parameters, headers=headers)
if response.status_code < 500:
print(response.json())
curl -X POST \
-H "Content-Type: application/json" \
-H 'username: <username>' \
-H 'api-key: <api-key>' \
-d '{"name": "demo-db-01", "command": "mysql --user=root --password=\"default123\" -e \"source /var/lib/mysql/nation.sql\""}' \
"https://<vME_ip_address>/docker/container/exec"
Parameters:
name
- required. A containername
orid
.command
- required. A string or list of commands to be executed.