Metadata-Version: 2.4
Name: optimihost
Version: 0.2.0
Summary: API For optimihost
Home-page: https://github.com/iamkubi/pydactyl
Author: OptimiHost and EAMCVD
Author-email: info@optimihost.com
Project-URL: Website, https://developer.optimihost.com/
Project-URL: Source, https://github.com/iamkubi/pydactyl
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Requires-Python: >=3.4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.21.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# optimihost API

An easy to use Python wrapper for the OptimiHost API.

## Installing

To install with pip:

```shell
pip install optimihost
```
### Exploring the API
In addition to the documentation you can explore the interface in an 
interactive Python interpreter using built-ins like `dir()` and the
`__doc__` attribute as shown below.

```python
from optimihost import Connect

api = Connect('<api_key>')

[i for i in dir(api.client.servers) if not i.startswith('_')]
# ['account', 'backups', 'databases', 'files', 'get_server', 'get_server_utilization', 'list_permissions', 'list_servers', 'network', 'schedules', 'send_console_command', 'send_power_action', 'servers', 'settings', 'startup', 'users']
[i for i in dir(api.client.servers.settings) if not i.startswith('_')]
# ['reinstall_server', 'rename_server']
print(api.client.servers.settings.rename_server.__doc__)
# Renames the server.
#        Args:
#            server_id(str): Server identifier (abbreviated UUID)
#            name(str): New name for the server
```

### Client API
The Client API or Account API is accessed by users of the Pterodactyl panel. 
Below is the layout of the Client API namespace.

```python
api.client.account
api.client.servers
api.client.servers.backups
api.client.servers.databases
api.client.servers.files
api.client.servers.network
api.client.servers.schedules
api.client.servers.settings
api.client.servers.startup
api.client.servers.users
```

A full list of methods available can be found in the [documentation][docs]. 


Below are examples of how you might get information about your servers.

```python
from optimihost import Connect

# Create a client to connect to the panel and authenticate with your API key.
api = Connect('MySuperSecretApiKey')

# Get a list of all servers the user has access to
my_servers = api.client.servers.list_servers()
# Get the unique identifier for the first server.
srv_id = my_servers[0]['attributes']['identifier']

# Check the utilization of the server
srv_utilization = api.client.servers.get_server_utilization(srv_id)
print(srv_utilization)

# Turn the server on.
api.client.servers.send_power_action(srv_id, 'start')
```
