一个易于使用的Python包装器,用于翼龙面板API。

py-dactyl的Python项目详细描述


毕指

Latest buildLatest docsCoverageLatest version

一个易于使用的Python包装器,用于翼龙面板API。在

项目状态

翼龙0.7的包装基本上是完整的。它将更新为 使用1.0版本,很可能会放弃对0.7的支持 那时。支持0.7的旧版本仍然可用。在

如果遇到问题,请查找尚未实现的API,或者 功能请求请提交Github issue。在

安装

要使用pip安装:

pip install py-dactyl

入门

翼龙有两种不同类型的API密钥:客户端(也称为帐户)和应用程序。任何用户都可以生成accountapi密钥来控制自己的服务器。管理员用户的帐户API密钥将能够访问任何服务器的客户端API。客户机API不包含任何破坏性函数,因此可以相对安全地进行试验。在

应用程序API密钥只能由管理员生成。这些密钥可以用于创建、修改和删除服务器等。它们可以访问面板上的任何服务器,并且可能具有破坏性,因此请小心使用。在

客户端API

翼龙面板的用户可以访问客户端API或帐户API。下面是如何获取服务器信息的示例。在

^{pr2}$

应用程序API

应用程序API是翼龙面板的管理API。 下面是如何使用此API的示例。在

frompydactylimportPterdoactylClient# Create a client to connect to the panel and authenticate with your API key.client=PterodactylClient('https://panel.mydomain.com','MySuperSecretApiKey')# Create a server.  Customize the Nest and Egg IDs to match the IDs in your panel.# This server is created with a limit of 8000 MB of memory, no access to swap, unlimited disk space, in location_id 1.client.servers.create_server(name='My Paper Server',user_id=1,nest_id=1,egg_id=3,memory_limit=8000,swap_limit=0,disk_limit=0,location_ids=[1])<Response[201]>

201响应表示成功,但是如果 请求Pydactyl将引发包含其他详细信息的异常。什么时候? 将location_ids字段更新到无效位置时,将显示错误:

client.servers.create_server(name='My Paper Server',user_id=1,nest_id=1,egg_id=3,memory_limit=8000,swap_limit=0,disk_limit=0,location_ids=[199])Traceback(mostrecentcalllast):File"<input>",line6,in<module>File"D:\code\pydactyl\pydactyl\api\servers.py",line268,increate_servermode='POST',data=data,json=False)File"D:\code\pydactyl\pydactyl\api\base.py",line98,in_api_request'code'],errors['detail'])pydactyl.exceptions.PterodactylApiError:BadAPIRequest(400)-NoViableNodeException-Nonodessatisfyingtherequirementsspecifiedforautomaticdeploymentcouldbefound.

可以使用User类添加、修改和删除面板用户。在

# Create a new userresult=client.user.create_user('test_user','test@gmail.com','Test','Name')# Get the ID of the created useruser_id=result['attributes']['id']# Get the user info, also returned by create_user()client.user.get_user_info(user_id){'object':'user','attributes':{'id':14,'external_id':None,....# Delete the userclient.user.delete_user(user_id=14)

分页反应

Pydactyl API响应返回可迭代的PaginatedResponse对象 根据需要自动获取额外的页面。现在是 仅由get_node_allocations()使用,但所有Pydactyl方法都会及时使用 将返回此响应。在

# Create a list of all portsallocs=client.nodes.list_node_allocations(node_id)ports=[]forpageinallocs:foriteminpage.data:ports.append(item['attributes']['port'])len(ports)151

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Hibernate会话/模板返回null   java Bluetooth无法连接到OBD2   smartGWT中的行分隔符的java等价物?   java如何删除可执行路径错误   java使用ICE Tar库对大文件进行Tar   java Spring Boot/JavaFX:添加一个仍然可以访问JPA的关机挂钩(ctrlc)   使用输入流读取java属性文件   如何在Java中迭代HashSet元素时覆盖该元素   内容类型中的javascript set charset=“utf8”   使用cassandra触发器的java   用户界面什么是适合我的GUI(JAVA)的update()方法   Java实例控制   java前置摄像头无法在不同设备上工作   java方法组织。postgresql。jdbc。连接。createClob()尚未实现