Skip to main content

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>
}

img alt

Elementary Management APIs

Pool APIs

Show pools

# 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())

Create a pool

# 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())

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 is 24000.

Destroy a pool

# 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())

Parameters:

  • name - required. A name of a pool to be destroyed.

Source APIs

Show sources

# 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())

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

# 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())

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 is vme-pool.
  • dbtype - optional. A database type name, such as mysql, mariadb, mssql, mongodb etc., used to label a source, default is unknown.
  • quota - optional. A limitation size property of the created source, default is None.
  • 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 is off.

Rename a source

# 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())

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

# 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())

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

# 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())

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 is False.

Create a snapshot

# 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())

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 is vme-pool.
  • recursive - optional. Recursive option, default is False.

Rename a snapshot

# 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())

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 is vme-pool.

Rollback a snapshot

# 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())

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 is vme-pool.

Destroy a snapshot

# 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())

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 is vme-pool.

Clone APIs

Show clones

# 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())

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

# 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())

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 a snapshot_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 is vme-pool.
  • size - optional. A number of clonefarm, default is 1.
  • dbtype - optional. A database type name, such as mysql, mariadb, mssql, mongodb etc., used to label a source, default is unknown.

Rename a clone

# 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())

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

# 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())

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

# 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())

Parameters:

  • repository - required. The repository name/path.
  • tag - optional. The image tag, default is latest.
  • dbtype - optional. A database type name, such as mysql, mariadb, mssql, mongodb etc. that used to label an image, default is repository name.
  • credential - optional. A credential for the pulling requirement, for example {"username" : <username>, "password" : <password>}.
info

vME supports the following official database images: MySQL, MariaDB, MSSQL, MongoDB, Postgres, Oracle, IBM/DB2, and Couchbase.

List all database images

# 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())

Remove a database image

# 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())

Parameters:

  • image - required. An image name or name:tag or id to be removed.

Create a database container

# 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())

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

# 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())

Start a database container

# 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())

Parameters:

  • name - required. A container name or id.

Stop a database container

# 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())

Parameters:

  • name - required. A container name or id.

Remove a database container

# 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())

Parameters:

  • name - required. A container name or id to be removed.
  • volume - optional. Boolean option to remove the volumes associated with the container, default is False.

Execute a command inside the database container

# 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())

Parameters:

  • name - required. A container name or id.
  • command - required. A string or list of commands to be executed.