Skip to main content

System users

Сreate a new user

Request Structure:

http://<cluster>:<port>/api/system/users/add

Post data:

access_token = <access_token>
username = testuser
password = testpass

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "179ad45c6ce2cb97cf1029e212046e81"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user already exists
-username and password must not be empty

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/users/add'
data = {
        'username': 'testuser',
        'password': 'testpass'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Delete user

Request Structure:

http://<cluster>:<port>/api/system/users/delete

Post data:

access_token = <access_token>
username = testuser

The response from the server:

{
 "msg": {},
 "status": "success",
 "error": ""
}

Errors:

-user does not exist
-Can not delete last user

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/users/delete'
data = {
        'username': 'testuser'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Set new user data

Request Structure:

http://<cluster>:<port>/api/system/users/set

Post data:

access_token = <access_token>
username = testuser
password = newtestpass
email = testuser@clastercp.com

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user does not exist

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/users/set'
data = {
        'username': 'testuser',
        'password': 'newtestpass',
        'email': 'testuser@clastercp.com'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Get user data

Request Structure:

http://<cluster>:<port>/api/systems/users/get

Post data:

access_token = <access_token>
username = testuser

The response from the server:

{
 "msg": {
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

-user does not exist

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/users/get'
data = {
        'username': 'testuser'
}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)

 

Get all users data

Request Structure:

http://<cluster>:<port>/api/system/users/get

Post data:

access_token = <access_token>

The response from the server:

{
 "msg": {
  "admin": {
   "password": "21232f297a57a5a743894a0e4a801fc3"
  },
  "testuser": {
   "password": "37b032c83f249979fc5db9b0b391ef4a",
   "email": "testuser@clastercp.com"
  }
 },
 "status": "success",
 "error": ""
}

Errors:

Example:

import requests
import json

api_url = "http://<IP>:<PORT>/api/"
access_token = 'BLABLALBA'

path = 'system/users/get'
data = {}

def send(path, data):
    data['access_token'] = access_token
    send = requests.post(url=api_url + path, data=data)
    print(send.text)
    
send(path, data)