Download OpenAPI specification:Download
AAPF WebAPI provides REST like APIs to control AAClusters.
This document describes the specifications of the apis and its usage.
AAPF WebAPI can be called using XMLHTTPRequest (in AAPF WebUI) and any HTTP 1.1 Clients such as cURL.
Most of the apis require authentication before call these. We use the JSON Web Token (JWT) based authentication mechanism like OAuth 2.0.
For GUI/CUI application, do following to call apis for username and password based authentication:
/api/v1/login to authenticate user/api/v1/login api returns two JWT when the authentication succeeded:Authorization: Bearer <Access Token> headerAuthorization header to authenticate the request/api/v1/access-token-refresh to get new Access TokencURL Example:
#!/bin/bash
set -eu
#Get access token
auth_json=$(curl -v -X POST -H 'Content-Type: application/json' \
-d '{ "username": "user1", "password": "user1pass" }' \
"localhost:3000/api/v1/login")
access_token=$(echo ${auth_json} | jq -r .accessToken)
#Call api
curl -v -X GET \
-H "Authorization: Bearer ${access_token}" \
"localhost:3000/api/v1/aaclusters"
For the command line tools, scripts and other applications, "AAPF API Token" should be used to call apis instead of Access Token. It's suitable for automated operation, calling apis from other application and calling apis from command line because AAPF API Token is never expired.
cURL Example:
#!/bin/bash
set -eu
api_token="<AAPF API Token>"
#Call api
curl -v -X GET \
-H "Authorization: Bearer ${api_token}" \
"localhost:3000/api/v1/aaclusters"
To get AAPF API Token, access the Manage AAPF API Tokens page in AAPF WebUI or use /api/v1/api-tokens api.
The error response will depend on the following HTTP status codes:
400 Bad Request for when the request was not processed, as the server could not understand what the client is asking for.401 Unauthorized for when the request lacks valid credentials and it should re-request with the required credentials.404 Not Found indicates that the requested resource was not found.500 Internal Server Error indicates that the request is valid, but the server could not fulfill it due to some unexpected condition.The error message is nothing more than reference information for the error code.
Login to AAPF WebAPI Server.
| username required | string User name. |
| password required | string Password to login. |
{- "username": "user1",
- "password": "passOfUser1"
}{- "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNTEwMDQyNTA5LCJleHAiOjE1MTAwNDk3MDksInVzZXIiOnsidXNlcm5hbWUiOiJ1c2VyMSJ9fQ.LKKXIwAsehTHEPbUZ7iher9SEChc6z_ch2kNdeM1ABU",
- "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicmVmcmVzaCIsImlhdCI6MTUxMDA0MjUwOSwiZXhwIjoxNTE1MjI2NTA5LCJ1c2VyIjp7InVzZXJuYW1lIjoidXNlcjEifX0.HCKU1_q9jZGnFjej8qXmxMt5PwWPSHq8vAJa36-iGyE"
}Change user password.
This may return following errors:
| oldPassword required | string Old password |
| newPassword required | string New password |
{- "oldPassword": "user1pass",
- "newPassword": "1234qwer"
}{- "message": "Your password has been changed !"
}#!/bin/bash -eu # Usage: logout.sh [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$1" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$1" fi result=$(curl -v -X POST -H 'Content-Type: application/json' \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/logout") echo ${result} | jq . || echo ${result}
{ }Refresh Access Token using Refresh Token.
| refreshToken required | string Refresh Token. |
{- "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoicmVmcmVzaCIsImlhdCI6MTUxMDA0MjUwOSwiZXhwIjoxNTE1MjI2NTA5LCJ1c2VyIjp7InVzZXJuYW1lIjoidXNlcjEifX0.HCKU1_q9jZGnFjej8qXmxMt5PwWPSHq8vAJa36-iGyE"
}{- "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNTEwMDQyNTA5LCJleHAiOjE1MTAwNDk3MDksInVzZXIiOnsidXNlcm5hbWUiOiJ1c2VyMSJ9fQ.LKKXIwAsehTHEPbUZ7iher9SEChc6z_ch2kNdeM1ABU"
}Get a list of AAPF API Tokens which is owned by a request user. This list is ordered by the creation time.
#!/bin/bash -eu # Usage: api_tokens_list.sh [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$1" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$1" fi result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/api-tokens") echo ${result} | jq . || echo ${result}
{- "apiTokens": [
- {
- "tokenName": "APItoken1",
- "createdAt": "2017-05-25T15:15:11.000000+09:00"
}, - {
- "tokenName": "APItoken2",
- "createdAt": "2017-10-30T12:24:36.000000+09:00"
}
]
}Create a new AAPF API Token which is owned by a request user. When user enters a blank or duplicate name, it will return an error message.
| tokenName required | string <= 512 characters AAPF API Token name what user set before. |
| password required | string User password |
{- "password": "passOfUser1"
}{- "apiToken": {
- "tokenName": "APItoken",
- "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0eXBlIjoiYWNjZXNzIiwiaWF0IjoxNTEwMDQyNTA5LCJleHAiOjE1MTAwNDk3MDksInVzZXIiOnsidXNlcm5hbWUiOiJ1c2VyMSJ9fQ.LKKXIwAsehTHEPbUZ7iher9SEChc6z_ch2kNdeM1ABU",
- "createdAt": "2017-05-25T15:15:11.000000+09:00"
}
}Get information about an AAPF API Token which is owned by a request user.
| tokenName required | string <= 512 characters AAPF API Token name what user set before. |
#!/bin/bash -eu # Usage: api_token_info.sh tokenName [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$2" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$2" fi if [ "$1" != "" ]; then result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/api-tokens/$1") else echo "Usage: api_token_info.sh tokenName [access_token]" exit 1 fi echo ${result} | jq . || echo ${result}
{- "apiToken": {
- "tokenName": "APItoken",
- "createdAt": "2017-05-25T15:15:11.000000+09:00"
}
}Delete an AAPF API Token which is owned by a request user.
| tokenName required | string <= 512 characters AAPF API Token name what user set before. |
#!/bin/bash -eu # Usage: api_token_delete.sh tokenName [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$2" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$2" fi if [ "$1" != "" ]; then result=$(curl -v -X DELETE \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/api-tokens/$1") else echo "Usage: api_token_delete.sh token_id [access_token]" exit 1 fi echo ${result} | jq . || echo ${result}
{ }Gets a list of AAClusters which is owned by a request user. It is sorted by the cluster name.
If the request user has no AAClusters, returns an empty list:
{ aaclusters: [] }#!/bin/bash -eu # Usage: aacluster_list.sh [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$1" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$1" fi result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/aaclusters") echo ${result} | jq . || echo ${result}
{- "aaclusters": [
- {
- "name": "sample",
- "status": "created",
- "services": [
- {
- "name": "jupyter-notebook",
- "numberOfInstances": 1,
- "instances": [
- {
- "index": 1,
- "status": "ready",
- "health": null,
- "createdAt": "2017-08-01T01:55:59.474387+09:00",
- "updatedAt": "2017-08-01T01:56:36.358779+09:00",
- "urlPath": "/proxy/abcdefg123/jupyter",
- "jupyterToken": "c6db3a7b715b04402b6a241faa6cf16274403bf50a7bbf91"
}
], - "image": {
- "repositoryName": "aa_jupyter_notebook",
- "displayName": "Jupyter Notebook",
- "description": "Standard Jupyter Notebook image provided by AAPF."
}, - "perfType": {
- "name": "fixed-instance-small",
- "displayName": "Fixed Instance(small)",
- "resources": {
- "cpu": 0.5,
- "memory": 1024,
- "nvidia.com/gpu": null
}
}, - "alerts": [ ]
}, - {
- "name": "spark-master",
- "numberOfInstances": 0,
- "instances": [ ],
- "image": { },
- "perfType": { },
- "alerts": [ ]
}, - {
- "name": "spark-worker",
- "numberOfInstances": 0,
- "instances": [ ],
- "image": { },
- "perfType": { },
- "alerts": [ ]
}
], - "createdAt": "2017-08-01T01:57:02.401372+09:00"
}
]
}Gets information of an AACluster which is owned by a request user.
| nameOfAACluster required | string <= 512 characters The name of the AACluster. |
#!/bin/bash -eu # Usage: aacluster_get.sh [cluster_name [access_token]] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} CLUSTER_NAME=${1:-sample} if [ "$2" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$2" fi result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/aaclusters/${CLUSTER_NAME}") echo ${result} | jq . || echo ${result}
{- "aacluster": {
- "name": "sample",
- "status": "created",
- "services": [
- {
- "name": "jupyter-notebook",
- "numberOfInstances": 1,
- "instances": [
- {
- "index": 1,
- "status": "ready",
- "health": null,
- "createdAt": "2017-08-01T01:55:59.474387+09:00",
- "updatedAt": "2017-08-01T01:56:36.358779+09:00",
- "urlPath": "/proxy/abcdefg123/jupyter",
- "jupyterToken": "c6db3a7b715b04402b6a241faa6cf16274403bf50a7bbf91"
}
], - "image": {
- "repositoryName": "aa_jupyter_notebook",
- "displayName": "Jupyter Notebook",
- "description": "Standard Jupyter Notebook image provided by AAPF."
}, - "perfType": {
- "name": "fixed-instance-small",
- "displayName": "Fixed Instance(small)",
- "resources": {
- "cpu": 0.5,
- "memory": 1024,
- "nvidia.com/gpu": null
}
}, - "alerts": [ ]
}, - {
- "name": "spark-master",
- "numberOfInstances": 0,
- "instances": [ ],
- "image": { },
- "perfType": { },
- "alerts": [ ]
}, - {
- "name": "spark-worker",
- "numberOfInstances": 0,
- "instances": [ ],
- "image": { },
- "perfType": { },
- "alerts": [ ]
}
], - "createdAt": "2017-08-01T01:57:02.401372+09:00"
}
}Creates a new AACluster which is owned by a request user.
| nameOfAACluster required | string <= 512 characters The name of the AACluster. |
required | object The parameters of service instances for the Jupyter Notebook |
{- "jupyterNotebook": {
- "image": {
- "repositoryName": "aa_jupyter_notebook"
}, - "perfType": "small"
}
}{- "message": "Accepted creating AACluster named 'sample'."
}Deletes an existing AACluster which is owned by a request user.
| nameOfAACluster required | string <= 512 characters The name of the AACluster. |
#!/bin/bash -eu # Usage: aacluster_delete.sh [cluster_name [access_token]] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} CLUSTER_NAME=${1:-sample} if [ "$2" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$2" fi curl -v --no-buffer -X DELETE \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/aaclusters/${CLUSTER_NAME}" | jq .
{- "message": "Accepted deleting AACluster named 'sample'."
}Gets a list of performance types. It is sorted by the name.
If there is no performance type, returns an empty list:
{ perfTypes: [] }#!/bin/bash -eu # Usage: perf_type_list.sh [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$1" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$1" fi result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/perf-types") echo ${result} | jq . || echo ${result}
{- "perfTypes": [
- {
- "name": "0010_micro",
- "displayName": "Micro (Fixed Performance)",
- "resources": {
- "cpu": 0.25,
- "memory": 512,
- "nvidia.com/gpu": null
}
}
]
}Gets a list of available images. It is sorted by the repository name.
If there is no available images, returns an empty list:
{ images: [] }#!/bin/bash -eu # Usage: image_list.sh [access_token] AAWEB_ENDPOINT=${AAWEB_ENDPOINT:=localhost:3000/api/v1} if [ "$1" == "" ]; then auth_json=$(curl -X POST -H 'Content-Type: application/json' \ -d '{ "username": "user1", "password": "user1pass" }' \ "${AAWEB_ENDPOINT}/login") access_token=$(jq -r .accessToken <(echo ${auth_json})) else access_token="$1" fi result=$(curl -v -X GET \ -H "Authorization: Bearer ${access_token}" \ "${AAWEB_ENDPOINT}/images") echo ${result} | jq . || echo ${result}
{- "images": [
- {
- "repositoryName": "aa_jupyter_notebook",
- "displayName": "Jupyter Notebook",
- "description": "Standard Jupyter Notebook image provided by AAPF."
}
]
}