puffb/README.md

72 lines
1.7 KiB
Markdown
Raw Normal View History

2024-05-31 14:06:23 -04:00
# puffb
2024-05-31 09:22:07 -04:00
2024-05-31 14:06:23 -04:00
puffb is a small Python module for interacting with a Pufferpanel daemon.
2024-05-31 09:22:07 -04:00
Made this in my spare time because I needed it.
## Usage
### Prerequisites
First make sure you have Pufferpanel set up, and a deploy a server you intend to interact with it.
Create an OAuth2 application for this server. Like it says, **write down the secret key in a safe place. It is only ever displayed once.**
Now you have Pufferpanel, a server, it's server ID (randomly generated 8 character string, usually displayed in the URL in the browser), client ID and secret ID.
Make sure you have the requests and json modules available.
2024-05-31 09:27:46 -04:00
### Usage
2024-05-31 09:22:07 -04:00
```python
2024-05-31 14:06:23 -04:00
import puffb
2024-05-31 09:22:07 -04:00
...
```
2024-05-31 14:06:23 -04:00
Now you are ready to create a puffb!
2024-05-31 09:22:07 -04:00
Using the information you gathered before, create an object:
```python
2024-05-31 14:06:23 -04:00
server = puffb.Panel('your-server-url', 'your-client-id', 'your-secret-key', 'your-server-id')
2024-05-31 09:22:07 -04:00
```
Or, alternatively, if you want to use a client that has access to multiple servers at once:
```python
2024-05-31 14:06:23 -04:00
admin = puffb.Panel('your-server-url', 'your-client-id', 'your-secret-key')
2024-05-31 09:22:07 -04:00
```
Keep in mind that with this method, you will have to specify the server ID for most commands. Instead of
```python
admin.stop()
```
you must now type
```python
admin.stop(serverID = 'a1b2c3d4')
```
Now you can run various methods that return useful information about your server, or interact with it.
Examples:
```python
server.logs()
# Returns logs as a string
server.stats()
# {'cpu_usage': 5, 'ram_usage': 135.50}
server.status()
# True
# (Returns True if running, False if not)
server.stop()
# 204
server.edit_data(key = 'server-name', value = 'new and better name!')
# 204
```
Most of the `/daemon` endpoints specified in the Pufferpanel API docs are available for use through this module.