Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel3

Introduction

These APIs provide services for manipulating ote-stack platform on AI Edge Blueprint. 

API Definitions

otestack v1

User Management

1.Login

POST /v1/authorization

Description

...

Code Block
titleExample
collapsetrue
POST /v1/authorization 
Body: 
{ 
	"user": "u1", 
	"password": "xxx" 
} 
Response: 
{ 
	"token": "eyxxxxxxxxxxxxxx", 
	"code": 200, 
	"message": "success" 
} 

2.Update Token

PUT /v1/authorization

Description

...

Code Block
titleExample
collapsetrue
PUT /v1/authorization 
Header: Authorization: eyxxxxxxxxxxxxxx 
Response: { 
	"token": "eyyxxxxxxxxxxxx2", 
	"code": 200, 
	"message": "success" 
} 

3.Create User

POST /v1/user

Description

Create a user without access token authorization. This user will be available after system administrator approval.

...

Code Block
titleExample
collapsetrue
POST /v1/user 
body: 
{ 
	"user": "u1", 
	"password": "xxX@1234", 
	"phone": "12345678910", 
	"realName": "hello" 
	"isAdmin": true 
} 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

4.Update Password

PUT /v1/user

Description

Change the password of the logged-in user.

...

Code Block
titleExample
collapsetrue
PUT /v1/user 
body: 
{ 
	"oldPassword": "xxx0", 
	"password": "xxx" 
} 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

5.Delete User

DELETE /v1/admin/user/[userid]

...

Code Block
titleExample
collapsetrue
DELETE /v1/admin/user/1 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

6.Reset Password

PUT /v1/admin/user/[userId]/password

...

Code Block
titleExample
collapsetrue
PUT /v1/admin/user/1/password 
Body: 
{ 
	"password": "xxx" 
} 
Response: 
{
	"code": 200, 
	"message": "success" 
}

7.Get User List

GET /v1/admin/user

Description

...

Code Block
titleExample
collapsetrue
GET /v1/admin/user 
Response: 
{ 
	"data": 
	[ 
	{"id":1, "user":"user1", "status":3, "realName":"user1", "phone":"18923441163", "createTime":1551758321, "updateTime":1551758321 }, 
	{"id":2, "user":"user2", "status":3, "realName":"user2", "phone":"18923441123", "createTime":1551758321, "updateTime":1551758321 } 
	],
	"total": 2, 
	"code": 200, 
	"message": "Success" 
}

8.Audit User

PUT /v1/admin/user/[userId]

...

Code Block
titleExample
collapsetrue
PUT /v1/admin/user/1
body: 
{ 
	"status": 0 
} 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

9.Logout

DELETE /v1/authorization

Description

...

Code Block
titleExample
collapsetrue
DELETE /v1/authorizations 
Header: Authorization: eyxxxxxxxxxxxxxx 
Response: 
{ 
	"code": 200, 
	"message": "Success" 
} 

10.Get Authorization Information

GET /v1/authorization

Description

...

Code Block
titleExample
collapsetrue
GET /v1/authorization 
Response: 
{ 
	"data": 
	{ 
		"displayName": "ote_test1", 
		"hasRepoAccount": true, 
		"role": 4, 
		"privateProject": true, 
		"enableIngress": false, 
		"enableAlert": true, 
		"enableAdminAutoDeploy": true 
	},
	"code": 200, 
	"message": "Success" 
}

11.Create Sub-User 

POST /v1/admin/user

Description

...

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Business Management

1.Create Business

POST /v1/business

Description

...

Code Block
titleExample
collapsetrue
POST /v1/business
{
"name": "name",
"introduce": "intrduce",
"objective": "objective",
"scale": "scale"
}

2.Get Business List

GET /v1/business

Description

...

Code Block
titleExample
collapsetrue
GET /v1/business
{
	"data": [
	{
   	 	"name": "name",
   	 	"userId": 123,
   	 	"comment": "comment",
   	 	"id": 1,
   	 	"status": 0,
   	 	"createTime": 1590062196,
   	 	"updateTime": 1590062196
	}
  	],
	"total": 1,
	"code":200,
	"message": "Success"
}

3.Get Business

GET /v1/business/id/[id]

Description

...

Code Block
collapsetrue
GET /v1/business/id/1

{
"data": {
    "name": "name",
    "userId": 123,
    "introduce": "introduce",
    "objective": "",
    "scale": "1400000000",
    "comment": "comment",
    "id": 1,
    "status": 0,
    "createTime": 1590062196,
    "updateTime": 1590062196
  }
"code":200,
"message": "Success"
}

4.Audit Business

PUT /v1/business/id/[id]

Description

...

Code Block
collapsetrue
PUT /v1/business/id/1

{
    "comment": "pass",
    "status": 1
}

Cluster Management

1.Get Cluster List

GET /v1/cluster

Description

...

Code Block
titleExample
collapsetrue
GET /v1/cluster?clusterLabel=all&page=1&pageSize=10
Response:
{
    "code" : 200,
    "message" : "success",
    "data": [
         { "clusterName": "GuangZhou", "nodeCount": 1, "isReady": false},
         { "clusterName": "BeiJing",   "nodeCount": 2, "isReady": true}
    },
    "total": 2
}

2.Add Label to Cluster

POST /v1/cluster/label

Description

...

Code Block
title请求示例
collapsetrue
POST /v1/cluster/label
{
    "clusterLabel": "label1",
    "clusterName": ["GuangZhou", "BeiJing"]
}
Response
{
    "code" : 200,
    "message" : "success"
}

3.Delete Label

DELETE /v1/cluster/label

Description

...

Code Block
collapsetrue
DELETE /v1/cluster/label
{
    "clusterLabel": "label1",
    "clusterName": ["GuangZhou", "BeiJing"]
}
Response
{
    "code" : 200,
    "message" : "success"

}

4.Get Label List

GET /v1/cluster/label

Description

...

Code Block
collapsetrue
GET /v1/cluster/label
Response:
{
    "code" : 200,
    "message" : "success",
    "data": [
         "label1", "label2"
    ]
}

5.Get Label

GET /v1/cluster/label/[clusterNamel]

...

Code Block
collapsetrue
GET /v1/cluster/label/cluster1?page=1&pageSize=10
Response:
{
    "code" : 200,
    "message" : "success",
    "data": [
         { "clusterLabel":"GuangZhou", "createTime": 1234567890 },
         { "clusterLabel":"BeiJing", "createTime": 1234567891 }
    ],
    "total": 2
}

Node Management

1.Get Node List

GET /v1/node

Description

Parameters

...

Code Block
collapsetrue
GET /v1/node
Response:
{
    "code" : 200,
    "message" : "success",
    "data": [
         {
           "nodeName": "GZ1", 
           "operatingSystem": "Linux", 
           "clusterName": "GuangZhou", 
           "kernelVersion" : "2.6",
           "isReady": true,
           "ip": "1.2.3.4"
         },
         {
           "nodeName": "BJ1", 
           "operatingSystem": "Linux", 
           "clusterName": "BeiJing", 
           "kernelVersion" : "2.6",
           "isReady": true,
           "ip": "1.2.3.4"
         }
    },
    "meta": {
        "readyNodeCount": 2 
    },
    "total": 2
}

2.Add Label to Node

POST /v1/node/label

Description

...

Code Block
title请求示例
collapsetrue
POST /v1/node/label
{
    "nodeLabel": "label1",
    "clusterName": "c1",
    "nodeName": ["GuangZhou", "BeiJing"]
}
Response:
{
    "code" : 200,
    "message" : "success"
}

3.Delete Label

DELETE /v1/node/label

Description

...

Code Block
collapsetrue
DELETE /v1/node/label
{
    "nodeLabel": "label1",
    "clusterName": "c1",
    "nodeName": ["GuangZhou", "BeiJing"],
    "deleteDeploy": true
}
Response:
{
    "code" : 200,
    "message" : "success"
}

4.Get Label List

GET /v1/node/label

Description

...

Code Block
collapsetrue
GET /v1/node/label?clusterName=c1
Response:
{
    "code" : 200,
    "message" : "success",
    "data": ["label1"]
}

Repository Management

1.Get Images

GET /v1/repository/image

Description

List images of the specified project.

Parameters

Name

Type

Required

Default

Description

orderBy

string

no

id

OrderBy allows sorting by id.

order

string

no

desc

Sort order: asc, desc.

page

int

no

1

The page number.

pageSize

int

no

10

The size of per page, 0 for no limited.

projectNamestringyes
The name of project.
imageNamestringno
Image name for filtering result.

...

Code Block
collapsetrue
GET /v1/repository/image
Response:
{
    "data": [
        {
            "projectName": "test",
            "public": false,
            "imageName": "test/test-demo1",
            "imageAddress": "registry.dcdn.baidu.com/test/test-demo1",
            "createTime": 1551758321,
            "updateTime": 1551758321
        },
        {
            "projectName": "test2",
            "public": false,
            "imageName": "test2/test-demo2",
            "imageAddress": "registry.dcdn.baidu.com/test2/test-demo2",
            "createTime": 1551758321,
            "updateTime": 1551758321

        }
    ],
    "total": 2,
    "code": 200,
    "message": "success"
}

2.Get Tag of Image

GET /v1/repository/image/tag?imageName=[imageName]

Description

List tags under the specific image name.

...

Code Block
collapsetrue
GET /v1/repository/image/tag?imageName=test/demo1

{
    "data": [
        {
            "tag": "latest",
            "imageAddress": "registry.dcdn.baidu.com/test/test-demo1",
            "createTime": 1551758321,
            "updateTime": 1551758321
        },
        {
            "tag": "v1",
            "imageAddress": "registry.dcdn.baidu.com/test/test-demo1",
            "createTime": 1551758321,
            "updateTime": 1551758321

        }
    ],
    "total": 2,
    "code": 200,
    "message": "success"
}

3.Delete Image

DELETE /v1/repository/image

Description

Delete multiple images specified by name.

...

Code Block
title请求示例
collapsetrue
DELETE /v1/repository/image
Body: 
{
   "imageName": ["img1", "img2"]
}


Response:
{
    "code": 200,
    "message": "success"
}

4.Delete Tag of Image

DELETE /v1/repository/image/tag

Description

Delete the image specified by name and tags.

Parameters

Name

Type

Required

Default

Description

tag

[ ]stringyes
tags of image that needs to be removed
imageNamestringyes
name of image that needs to be removed

...

Code Block
collapsetrue
DELETE /v1/repository/image/tag
Body: 
{
   "imageName": "test/demo1"
   "tag": ["v1", "v2"]
}


Response:
{
    "code": 200,
    "message": "success"
}

5.Create User

POST /v1/repository/user

Description

...

Code Block
collapsetrue
POST /v1/repository/user
{
"user": "user1",
"password": "xxxx"
}

Response:
{
    "code": 200,
    "message": "success"
}

6.Update Password

PUT /v1/repository/user

Description

...

Code Block
collapsetrue
PUT /v1/repository/user
{
"password": "xxxx"
}

Response:
{
    "code": 200,
    "message": "success"
}

7.Get Projects of Repository

GET /v1/repository/project

...

Name

Type

Description

projectId

intProject ID.

projectName

stringThe name of the project

createTime

stringThe creation time of the project.

updateTime

stringThe update time of the project.
publicboolThe public status of the project.
imageCountintThe count of the images under this project.

total

intTotal number of the projects.

...

Code Block
collapsetrue
GET /v1/repository/project

Response:
{
"data": [ {
  "projectId": 13,
  "projectName": "calico",
  "createTime": 1551758321,
  "updateTime": 1551758321,
  "imageCount": 3,
  "public": true
  } ],
"total": 2,
"code": 200,
"message": "success"
}

8.Create Project

POST /v1/repository/project

...

Name

Type

Required

Default

Description

projectNamestringyes
The name of project.
publicboolyes
The public status of the project.

Response code

Code

Description

201

Project created successfully.

400

Unsatisfied with constraints of the project creation.

401

User need to log in first.

409

Project name already exists.

415

The Media Type of the request is not supported, it has to be "application/json"

500

Unexpected internal errors.

...

Code Block
collapsetrue
POST /v1/repository/project
{
  "projectName": "calico",
  "public": true
}

Response:
{
"code": 200,
"message": "success"
}

9.Delete Project

DELETE /v1/repository/project

...

Code Block
collapsetrue
DELETE /v1/repository/project
{
  "projectId": [ 1, 2 ]
}

Response:
{
"code": 200,
"message": "success"
}

10.Create External Repository

POST /v1/repository/third

...

Code Block
collapsetrue
POST /v1/repository
Body:
{
    "repositoryId": "repo1",
    "address": "127.0.0.1",
    "user": "user1",
    "password": "password1"
}


Response:
{
"code": 200,
"message": "success"
}

11.Delete External Repository

DELETE /v1/repository/third

...

Code Block
collapsetrue
DELETE /v1/repository
Body:
{
    "repositoryId": ["repo1", "repo2"]
}
Response:
{
	"code": 200,
	"message": "success"
}

12.Get External Repository List

GET /v1/repository/third

Description

...

Code Block
collapsetrue
GET /v1/repository/third?pageSize=0
response:
{
    "data": [ {
                "id": 1,
                "repositoryId":"yq01",
                "address":"xxzxsdsdsds",
                "user":"ddddddd"
    }, {
                "id": 2,
                "repositoryId":"yq02",
                "address":"xxzxsdsdsds",
                "user":"ddddddd"
    } ],
    "code": 200,
    "total": 2,
    "message": "Success"
}

13.Get External Repository  

GET /v1/repository/third/[repoId]

...

Code Block
collapsetrue
GET /v1/repository/third/repo1
Response:
{
    "data": {
                "repositoryId":"yq01",
                "address":"xxzxsdsdsds",
                "user":"ddddddd"
    },
    "code": 200,
    "message": "Success"
}

Application Management

1.Create Application

POST /v1/app

Parameters

Name

Type

Required

Description

appName

stringyesThe name of applicaton
deployTypestringyes

Deployment mode: Only deployment or daemonset can be set

imagestringyesImage repository with specified tag.
versionstringyesMain version with format x.x, for example 1.1.
repositoryIdstringnoThe ID of repository whose secret can be used to pull docker image.
portarrayyesThe exposed port.
commandstringnoStart command line.
volumearraynoVolume information.
envarraynoExecuting environment.
replicasuint32noDefault replicas. Effective only at deployment.
minReplicasuint32noMinimal replicas. Effective only at deployment.
maxReplicasuint32noMaximun replicas. Effective only at deployment.
minCPUuint32yesMinimal cpu (%)
maxCPUuint32yesMaximun cpu(%)
GPUuint32noGPU count
isHPAboolyes
Allow to use horizontal pod autoscaler
targetCPUUtilizationuint32yes

CPU utilization which will trigger autoscale

targetMemUtilizationuint32yes
CPU utilization which will trigger autoscale
minMemoryuint32yes
Minimal memory (MB)
maxMemoryuint32yes
Maximun memory (MB)

maxUnavailable

uint32yes
Max unavailable pod

maxSurge

uint32yesmax surge pod

minReadySeconds

uint32yesmin ready seconds for updating

...

Code Block
titleExample
collapsetrue
POST  /v1/app
Body:
{
    "appName": "nginx1",
    "deployType": "deployment",
    "image": "nginx:latest",
    "version": "1.2",
    "repositoryId": "repo1",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 10,
    "maxCPU": 200,
    "isHPA": true,
    "targetCPUUtilization": 100,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
}
Response:
{
	"code": 200,
	"message": "success"
}

2.Delete Application

DELETE /v1/app

Parameters

NameTypeRequiredDescription

appId

[ ]intyesThe IDs of application

...

Code Block
collapsetrue
DELETE  /v1/app
{
   "appId": [1,2,3,4]
}

3.List Applications

GET /v1/app

Description

List applications.

...

Code Block
collapsetrue
Get /v1/app
{
  "apps": [ {
    "id": 1,
    "appName": "nginx1",
    "status": 1,
    "deployType": "deployment",
    "image": "nginx:latest",
    "projectName": "proj1",
    "repositoryId": "repo1",
    "version": "1.2.3.4",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "dependence": [
       {"name": "nginx", "service": "xxxx", "port": 9090 } ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 0.1,
    "maxCPU": 2,
    "GPU": 2,
    "isHPA": true,
    "targetCPUUtilization": 1,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
    "createTime": 1551758321,
    "updateTime": 1551758321},
  ]
  "total": 1,
  "code": 200,
  "message": "Success"
}

4.Get Application

GET /v1/app/id/{appId}

Description

...

Code Block
collapsetrue
GET  /v1/app/id/1
{
  "data": {
    "id": 1,
    "appName": "nginx1",
    "status": 1,
    "deployType": "deployment",
    "image": "nginx",
    "projectName": "proj1",
    "repositoryId": "repo1",
    "version": "1.2.3",
    "replicas": 10,
    "port": [
       {"port": 8080, "hostPort": 9090}],
    "command": "",
    "volume": [
       {"path": "/host/usr/bin", "hostPath": "/usr/bin", "readOnly": true},
       {"path": "/host/usr/sbin", "hostPath": "/usr/sbin", "readOnly": true} ],
    "dependence": [
       {"name": "nginx", "service": "xxxx", "port": 9090 } ],
    "env": [
       {"name": "NGINX_PATH", "value": "/usr/share/nginx/" } ],
    "minReplicas": 2,
    "maxReplicas": 20,
    "minCPU": 0.1,
    "maxCPU": 2,
    "GPU": 1,
    "isHPA": true,
    "targetCPUUtilization": 1,
    "targetMemUtilization": 150,
    "minMemory": 100,
    "maxMemory": 200,
    "maxUnavailable": 1,
    "maxSurge": 1,
    "minReadySeconds": 10,
    "createTime": 1551758321,
    "updateTime": 1551758321
  },
  "code": 200,
  "message": "Success"
}

5.Upload Helm Chart to Create Application 

POST /v1/app/chart

Description

...

Code Block
POST /v1/app/chart
appName=test
version=1.1
chart=@file

curl 0.0.0.0/v1/app/chart -F "version=1.2" -F "appName=test1" -F "chart=@file"

Deployment Management

1.Create Deployment

POST /v1/deploy

Description

...

Code Block
collapsetrue
POST  /v1/deploy/install
Body:
{
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.1",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "comment": ""
}
Response:
{
    "code": 200,
    "message": "success"
}

2.Delete Deployment

DELETE /v1/deploy/{deployName}

...

Code Block
collapsetrue
DELETE  /v1/deploy/deploy1
Response:
{
    "code": 200,
    "message": "success"
}

3.Upgrade Deployment

POST /v1/deploy/id/{deployId}

...

Code Block
collapsetrue
POST  /v1/deploy/id/1
Body:
{
    "version": "1.1.1.2"
}
Response:
{
    "code": 200,
    "message": "success"
}

4.List Deployment

GET /v1/deploy

Description

...

Code Block
collapsetrue
GET  /v1/deploy?pageSize=10&page=1
Response:
{
 "data": [ {
    "id": 1,
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.1",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "deployType": 1
    "status": 6,
	"errorMessage": "{\"running\": 10, \"error\": 3, \"total\": 13}",
    "comment": ""
    "editable": true,
    "createTime": 1551758321,
    "updateTime": 1551758321}
  ],
  "total": 1 
}

5.Rollback Deployment

PUT /v1/deploy/id/{deployId}

...

Code Block
collapsetrue
PUT  /v1/deploy/id/1
Body:
{
    "version": "1.1.1.2",
    "comment": ""
}
Response:
{
    "code": 200,
    "message": "success"
}

6.Get Deployment

GET /v1/deploy/id/{deployId}

...

Code Block
collapsetrue
GET  /v1/deploy/id/1
Response:
{
  "data" : {
    "id": 1,
    "deployName": "nginx1",
    "appName": "nginx1",
    "version": "1.1.1.2",
    "cluster": "cluster1",
    "nodeLabel": "node1",
    "status": 6,
    "comment": "",
    "errorMessage": "{\"running\": 10, \"error\": 3, \"total\": 13}",
    "deployType": 1,
    "createTime": 1551758321,
    "updateTime": 1551758321
    }
  }
}

7.Delete Deployment

DELETE /v1/deploy/id/{deployId}

...

Code Block
collapsetrue
DELETE  /v1/deploy/id/1

8.Audit Deployment

PUT /v1/admin/deploy

Description

...

Code Block
POST /v1/admin/deploy
Body:
{
  "id": 123456,
  "status": 0,
  "comment": "xxxx"
}

9.List Audit List of Deployment

GET /v1/admin/deploy

Description

...

Name

Type

Required

Default

Description

orderBystringno
id
orderBy allows sorting by id.
orderstringnodescorder sort: asc,desc
businessNamestringno
The name of business for filtering result
pageintno1The page number
pageSizeintno10The page size of per page

...