Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

API v1 documentation

Roman Mirr edited this page Oct 17, 2020 · 1 revision

Overview

Some operations like creation of container take a while, therefore enqueued. As a result client should receive ID of job.

Substitute version of API instead {{API_VER}}.

Authentication

Currently there is no API authentication.

Response of failed request

{
    "code": 123,
    "message": "some error"
}

Container management

Create a container

Enqueue creation of container.

Request

curl -X POST 'http://localhost:5000/{{API_VER}}/containers/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "ct100",
    "ostemplate": "template1"
}'

Response

HTTP status 202 (Accepted).

Example:

{
    "message": "success",
    "job_id": "fa205b0e-3f3f-4e93-9bb0-d1e9c6467e4e"
}

Get information about container by ID

Request

curl -X GET 'http://localhost:5000/v0.1/containers/:id'

:id is UUID of container. For example, 54e21881-8620-4bb0-95f1-05f143973a6e

Response

{
    "message": "success",
    "container": {
        "id": "54e21881-8620-4bb0-95f1-05f143973a6e",
        "name": "ct100",
        "ostemplate": "template1",
        "parameters": null,
        "created_at": "2020-10-16T15:16:16Z"
    }
}

Update a container

:id is UUID of job. For example, 95944ace-9a36-47f0-8d7e-8ed8ac4125a0

Request

curl -X PATCH 'http://localhost:5000/{{API_VER}}/containers/:id' \
--header 'Content-Type: application/json' \
--data-raw '{
    "parameters":
 	{
                "hostname": "hostname1",
		"cpus": "2",
		"memsize": "1",
		"memsize_units": "G",
		"ipadd": "10.0.0.1",
		"size": "10",
		"size_units": "G",
		"nameserver": "1.1.1.1,8.8.8.8"
	}
}'

Response

{
    "message": "success",
    "code": 0
}

Jobs

Get job by ID

Request

curl -X GET 'http://localhost:5000/{{API_VER}}/jobs/:id'

:id is UUID of job. For example, 95944ace-9a36-47f0-8d7e-8ed8ac4125a0

Response

Example:

{
    "message": "success",
    "status": "done",
    "entity_type": "container",
    "entity_id": "54e21881-8620-4bb0-95f1-05f143973a6e"
}

entity_type represents type of entity. entity_id is an ID of entity.