Skip to content

RESTful API For User

Echo edited this page May 22, 2018 · 13 revisions
获取指定用户信息
Request
GET /saltshaker/api/v1.0/user/u-3d48618a283111e8a7e3000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "data": {
        "id": "u-d74e5e0c44f011e89fa5000c298454d8",
        "acl": [],
        "role": [
            "r-9e3be2ca318f11e8ab56000c298454d8"
        ],
        "groups": [
            "g-2b001f4e423111e89ff9000c298454d8",
            "g-25ba977e49ae11e89eb0000c298454d8",
            "g-fe0a5f5a4abd11e88d9d000c298454d8",
            "g-057fd4224abe11e88d9d000c298454d8",
            "g-0b19039a4abe11e88d9d000c298454d8"
        ],
        "product": [
            "p-4bc4a5b83bd011e8aa0e000c298454d8",
            "p-b4fbeca83f9f11e89556000c298454d8"
        ],
        "username": "admin"
    },
    "status": true,
    "message": ""
}
获取用户列表
Request
GET /saltshaker/api/v1.0/user

Response
HTTP/1.1 200 OK
Content-Type: application/json

   {
        "data": [
            {
            "id": "u-d74e5e0c44f011e89fa5000c298454d8",
            "acl": [],
            "role": [
                {
                    "id": "r-9e3be2ca318f11e8ab56000c298454d8",
                    "name": "超级管理员"
                }
            ],
            "groups": [
                {
                    "id": "g-2b001f4e423111e89ff9000c298454d8",
                    "name": "x01"
                },
                {
                    "id": "g-25ba977e49ae11e89eb0000c298454d8",
                    "name": "x03"
                },
                {
                    "id": "g-fe0a5f5a4abd11e88d9d000c298454d8",
                    "name": "x02"
                },
                {
                    "id": "g-057fd4224abe11e88d9d000c298454d8",
                    "name": "x04"
                },
                {
                    "id": "g-0b19039a4abe11e88d9d000c298454d8",
                    "name": "test222"
                }
            ],
            "product": [
                {
                    "id": "p-4bc4a5b83bd011e8aa0e000c298454d8",
                    "name": "x"
                },
                {
                    "id": "p-b4fbeca83f9f11e89556000c298454d8",
                    "name": "xe"
                }
            ],
            "username": "admin",
            "mail": "22@test.com",
        }
        ],
        "status": true,
        "message": ""
   }
添加用户
Request
POST /saltshaker/api/v1.0/user

POST Body
{
     "username": "salt1",
     "password": "salt"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
删除用户
Request
DELETE /saltshaker/api/v1.0/user/u-b0175be62b1d11e886cb000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
修改用户
Request
PUT /saltshaker/api/v1.0/user/u-feef9dfc28e611e8a7e3000c298454d8

PUT Body
{
       "acl": ["a-897e48cc31b811e8ab56000c298454d8"],
       "role": ["r-35d85a1a333311e8aa5f000c298454d8"],
       "groups": ["g-142120c8323411e8ab56000c298454d8","g-191b9cc0323411e8ab56000c298454d8"],
       "product": [],
       "username": "admin",
       "password": "",
       "mail": "test@sina.cn"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
注册用户
Request
POST /saltshaker/api/v1.0/user/register

POST Body
{
    "mail": "test03@test.com",
    "password": "aSaD4p1/OdEHCuPMO33NqwsHbbdUyMZc9Mj3WgwDT+GDVOxToYTnPstCpR4XHTjpNGrSmBKFJaw1fx+GUI3Pa18wJIzV+68h90ayIL",
    "username": "test03"
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
重置用户密码 会通过注册时的邮箱发送到对应邮箱中
Request
GET /saltshaker/api/v1.0/user/reset/u-a092de10577911e8a07b000c298454d8

Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
用户自己修改密码
Request
POST /saltshaker/api/v1.0/user/reset/owner/u-a092de10577911e8a07b000c298454d8

POST Body
{
    "old_password":"aSaD4p1/OdEHCuPMO33NqwsHbbdUyMZc9Mj3WgwDT+GDVOxToYTnPstCpR4XHTjpNGrSmBKFJaw1fx+GUI3PL",
    "new_password":"aSaD4p1/OdEHCuPMO33NqwsHbbdUyMZc9Mj3WgwDT+GDVOxToYTnPstCpR4XHTjpNGrSmBKFJaw1fx+GUI3PL",
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}
用户自己修改邮箱用户名信息
Request
PUT /saltshaker/api/v1.0/user/change/u-a092de10577911e8a07b000c298454d8

PUT Body
{
    "username":"admin",
    "mail":"xxx@xxx.com",
}
Response
HTTP/1.1 200 OK
Content-Type: application/json

{
    "status": true,
    "message": ""
}