Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

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

API Definitions

User Management

Login

POST /v1/authorization

Description

An access token, which contains user information and expiry time, will be returned by presenting username and password. The client should includes the token in the authorization header of HTTP request to access subsequent request until the token is expired. During the validity period (1 hour), the new token with new expiry time can be obtained through the Update token API with current token.

Parameters

NameTypeRequiredDefaultDescription
userstringyes
user name
passwordstringyes
user password

Response codes

Code

Description

200

Successful

500

Unexpected internal errors

422Parameter validation error

Example

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

Update Token

PUT /v1/authorization

Description

Returns a new authorization token with new expiry time.

Parameters

Name

Type

Required

Default

Description

Authorizationstringyes
token string in Authorization Header

Response codes

Code

Description

200

Successful

500

Unexpected internal errors

422Parameter validation error

Example

Example
PUT /v1/authorization 
Header: Authorization: eyxxxxxxxxxxxxxx 
Response: { 
	"token": "eyyxxxxxxxxxxxx2", 
	"code": 200, 
	"message": "success" 
} 

Create User

POST /v1/user

Description

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

Parameters

Name

Type

Required

Default

Description

userstringyes
User name
passwordstringyes
Password should be 8-20 characters long with at least 1 uppercase, 1 lowercase and 1 number.
phonestringyes
Phone number
isAdminboolyes
true: general administrator, false: general user
realNamestringyes
Real name

Response code

状态码

说明

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

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

Update Password

PUT /v1/user

Description

Change the password of the logged-in user.

Parameters

Name

Type

Required

Default

Description

oldPasswordstringyes
old password
passwordstringyes
new password

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

请求示例
PUT /v1/user 
body: 
{ 
	"oldPassword": "xxx0", 
	"password": "xxx" 
} 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

Delete User

DELETE /v1/admin/user/[userid]

Description

This can only be done by general administrator and system administrator. General administrator can delete user in own business namespace while system administrator can delete all users.

Parameters

Name

type

Required

Default

Description

useriduint64yes
User id that needs to be deleted.

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

请求示例
DELETE /v1/admin/user/1 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

Reset Password

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

Description

This can only be done by general administrator and system administrator. General administrator can update user in own business namespace while system administrator can update all users.

Parameters

Name

Type

Required

Description

userIduint64yesUserId that needs to update. Located in url path.
passwordstringyesNew password that will be updated.Located in body.

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

请求示例
PUT /v1/admin/user/1/password 
Body: 
{ 
	"password": "xxx" 
} 
Response: 
{
	"code": 200, 
	"message": "success" 
}

Get User List

GET /v1/admin/user

Description

This can only be done by general administrator and system administrator. General administrator can get users in own business namespace while system administrator can get all users.

Parameters

Name

Type

Required

Default

Description

orderBystringno
id
orderBy allows sorting by id and user_name.
orderstringnoascsort order: asc, desc
pageintno1page number
pageSizeintno10page size

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Response Parameters

Name

Type

Description

id
intUser id
user
stringUser name
statusint

Status  

0: Pending

1: Approved

2: Not Approved

3: Forbidden

realNamestringReal name
phonestringPhone number
totalintTotal number of users

createTime

int

Create time of user

updateTime

int

Update time of user

Example

使用示例
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" 
}

Audit User

PUT /v1/admin/user/[userId]

Description

This can only be done by system administrator for auditing new user. The new user will be available to create business namespace after system administrator approval.

Parameters

Name

Type

Required

Description

userIduint64yesUserID that needs to be audited.
statusintyes

Status  

0: Pending

1: Approved

2: Not Approved

3: Forbidden


Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

请求示例
PUT /v1/admin/user/1
body: 
{ 
	"status": 0 
} 
Response: 
{ 
	"code": 200, 
	"message": "success" 
}

Logout

DELETE /v1/authorization

Description

Logout by deleting the access token.

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Example

请求示例
DELETE /v1/authorizations 
Header: Authorization: eyxxxxxxxxxxxxxx 
Response: 
{ 
	"code": 200, 
	"message": "Success" 
} 

Get Authorization Information

GET /v1/authorization

Description

Return the authorization information, such as user name, user role.  

Response parameters

Name

Type

Description

displayName

string

User name

hasRepoAccount

bool

Whether or not the user has created a harbor account

role

int

User role:

0: register user that waiting for approval

1:approved user that do not has business namespace

2:general user

3:business administrator

4:system administrator

privateProject

bool

Flag to indicate if the project is private.

enableIngress

bool

Flag to indicate if the ingress is enabled.

enableAlertboolFlag to indicate if the alert information is enabled.

enableAdminAutoDeploy

bool

Allow deployment that admin submits run automatically without audit.

Example

请求示例
GET /v1/authorization 
Response: 
{ 
	"data": 
	{ 
		"displayName": "ote_test1", 
		"hasRepoAccount": true, 
		"role": 4, 
		"privateProject": true, 
		"enableIngress": false, 
		"enableAlert": true, 
		"enableAdminAutoDeploy": true 
	},
	"code": 200, 
	"message": "Success" 
}

Create Sub-User 

POST /v1/admin/user

Description

Create a user with access token authorization. This user will has the same business namespace with current logged-in administrator. This can only be done by general administrator and system administrator.

Parameters

Name

Type

Required

Default

Description

userstringyes
user name
passwordstringyes
password
phonestringyes
phone number
isAdminboolyes
true: admin false: general user
realNamestringyes
real name

Response code

Code

Description

200

Success

500

Unexpected internal errors

422Parameter validation error

Business Management

Create Business

POST /v1/business

Description

Create a new business namespace. This can only be done by admin who do not create business yet.

Parameters

NameTypeRequiredDefaultDescription
namestringyes
Business name
introducestringyes
Introduction of business
objectivestringyes
purpose for creating business
scalestringyes
the scale of resources excepted to use

Example

请求示例
POST /v1/business
{
"name": "name",
"introduce": "intrduce",
"objective": "objective",
"scale": "scale"
}

Get Business List

GET /v1/business

Description

Return the business list.

parameters

NameTypeRequiredDefault意义
pageintno1page
pageSizeintno10page size
orderBystringnoidorderBy allows sorting by id.
orderstringnoascsort order: asc, desc
namestringno
business name filter

Response parameters

NameTypeRequiredDescription
namestringyesbusiness name
userIdintyesuser id
commentstringyesaudit comment
statusint8yes

status

0: pending

1: approved

2: disapproved

3: deleted

Example

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

Get Business

GET /v1/business/id/[id]

Description

Get the specify business.

Parameters

NameTypeRequiredDescription
namestringyesbusiness name
userIdintyesuse id
introducestringyesIntroduction of business
objectivestringyespurpose for creating business
scalestringyesthe scale of resources excepted to use

Example

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"
}
  • No labels