Skip to content

Commit

Permalink
新增多用户设置API
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou-Shilin committed Jul 22, 2023
1 parent d566b4c commit 410f82d
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# BaimoMCSManager API for `Python`
![PRs welcome](https://img.shields.io/badge/PRs-welcome-20BF20)
![PRs Welcome](https://img.shields.io/badge/Support-MCSM_9.9.0-red)
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-20BF20)](https://github.com/Zhou-Shilin/BaimoMCSManager-API/pulls)
![Support MSCM 9.9.0](https://img.shields.io/badge/Support-MCSM_9.9.0-blue)
![Apache License](https://img.shields.io/badge/License-Apache-red)
这是一个适用于Python语言的第三方库,让你在Python中更方便地调用[MCSM-API
](https://docs.mcsmanager.com/#/zh-cn/apis/readme)管理你的服务器。

Expand All @@ -10,10 +11,10 @@
当前进展:
- [x] 面板通用设置 ( `common.py`)
- [x] 应用实例管理 (`applications.py`)
- [x] 多用户管理 (`auth.py`)
- [ ] 实例文件管理 (`files.py`)
- [ ] 计划任务管理 (`plans.py`)
- [ ] 守护进程管理 ( `remote_service.py`)
- [ ] 多用户管理 (`auth.py`)

## 📖使用方法
施工中……
124 changes: 124 additions & 0 deletions users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
from request_sender import sendRequest

"""
多用户设置
本项目使用Apache License 2.0开原协议。您在修改、分发本项目中的任意一个文件时,必须阅读、同意并遵守该协议。
This project uses the Apache License 2.0 open source agreement. You must read, agree to, and abide by this agreement when modifying or distributing any of the files in this project.
白墨麒麟Hot / 白墨麒麟 / BaimoQilin / Zhou-Shilin / 周示麟
"""

def create_user(url, apikey, username, password, permission):
# 创建用户
# 返回类型:bool
# 返回内容解释:True(成功)

# 参数说明:
# username: 用户名
# password: 密码
# permission: -1(封禁);1(普通权限);10(最高权限)

api_url = url + "/api/overview/setting"

_body = {
'username': username,
'password': password,
'permission': permission,
}

response = sendRequest(api_url, apikey, method="post", body=_body)

return True

def delete_user(url, apikey, uuid):
# 删除用户
# 返回类型:bool
# 返回内容解释:True(成功)

# 参数说明:
# uuid: 需要删除的用户的uuid,可以指定多个 例:["uuid", "uuid2", "uuid3"]

api_url = url + "/api/overview/setting"

_body = {
uuid
}

response = sendRequest(api_url, apikey, method="delete", body=_body)

return True

def get_overview(url, apikey):
# 用户数据总览
# 返回类型:json
# 返回内容解释:详见https://docs.mcsmanager.com/#/zh-cn/apis/panel/user_overview

api_url = url + "/api/auth/overview"

response = sendRequest(api_url, apikey)

return response

def get_info(url, apikey, uuid, advanced=True):
# 查看用户数据
# 返回类型:json
# 返回内容解释:详见https://docs.mcsmanager.com/#/zh-cn/apis/panel/info

# 参数说明
# uuid:用户uuid

_body = {
"apikey": apikey,
"advanced": advanced,
"uuid": uuid
}

api_url = url + "/api/auth/"

response = sendRequest(api_url, apikey, body=_body)

return response

def update_user_settings(url, apikey, uuid, permission, instance):
# 更改用户信息
# 返回类型:bool
# 返回内容解释:True(成功)

# 参数说明:
# uuid: 用户uuid
# perimission: -1(封禁);1(普通权限);10(最高权限)
# instance: 用户可以控制的实例,列表。例:
"""
// 目标用户能管理的实例,分别是守护进程UUID,实例UUID
[
{
"serviceUuid": "0e865f1f14c14906894698cc71f4e574",
"instanceUuid": "11e2f159b43f447eacb213b2cdc6df2a"
},
{
"serviceUuid": "07027a72d147487aa0a2ca0616231f22",
"instanceUuid": "11e2f159b43f447eacb213b2cdc6df2a"
},
{
"serviceUuid": "0e865f1f14c14906894698cc71f4e574",
"instanceUuid": "11e2f159b43f447eacb213b2cdc6df2a"
}
]"""


api_url = url + "/api/auth"


_body = {
"uuid": uuid,
"config": {
"permission": permission,
"instances": instance
}
}

response = sendRequest(api_url, apikey, method="put", body=_body)

return response

0 comments on commit 410f82d

Please sign in to comment.