github.com/hostari/pterodactyl_panel_client

Crystal wrapper over Pterodactyl Panel APOI

0 stars
0 dependents
License: MIT

Nothing has been indexed for 0.2.2 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  pterodactyl_panel_client:
    github: hostari/pterodactyl_panel_client
    version: ~> 0.2.2

Then run:

shards install

shard.yml

No shard.yml has been indexed for 0.2.2. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

pterodactyl_panel_client

Pterodactyl v1 API Client

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      pterodactyl_panel_client:
        github: hostari/pterodactyl_panel_client
  2. Run shards install

Usage

require "pterodactyl_panel_client"

Build a new Pterodactyl Panel Client

client_sdk = Pterodactyl::Client::Sdk.new("p2.hostari.com", client_token: "ptlc_...")
application_sdk = Pterodactyl::Application::Sdk.new("p2.hostari.com", application_token: "ptla_...")

Resource Methods

API Reference is available on Dashflo

Client Resource Methods

These methods are scoped to the user accessing them (i.e. if you query for servers, you will only see your servers and not other's servers). You must authenticate using a token starting with ptlc_ and this is generated when you create a user using the application resource method.

  • list servers
  • account => get account details
  • account => update email
  • network => list allocations
  • network => assign allocation
  • network => set allocation note
  • network => set primary allocation
  • network => unassign allocation
  • backups => list backups
  • backups => create backup
  • backups => backup detaials
  • backups => download backup
  • backups => delete backup
  • settings => rename server
  • settings => reinstall server
  • startup
    • list variables
    • update variable
  • get server details
  • get console details
  • get resource usage
  • send command
  • change power state

Application Resource Methods

To use these methods, you must authenticate using a token starting with ptla_ which can be generated if you are an Admin on your Pterodactyl panel.

Create user

client.create_user(email: "apiuser@example.com", username: "apiuser", first_name: "api", last_name: "user")
{"object":"user","attributes":{"id":18,"external_id":null,"uuid":"f2d27757-38b5-4fa2-811a-b41397c0a470","username":"xaviapitest8","email":"xavi+apitest8@hostari.com","language":"en","root_admin":false,"2fa":false,"avatar_url":"https:\/\/www.gravatar.com\/avatar\/30532f3d3853d1c7949849dabe641fc2.jpg","admin_role_id":null,"role_name":null,"created_at":"2023-02-13T18:11:36+00:00","updated_at":"2023-02-13T18:11:36+00:00"},"meta":{"token":"ptlc_U1XFrTgLb8PLqoGNzyCoFFwRtbgiA3IyYzdegLfbXTe"}}

List locations

client.list_locations

Get Location details

client.get_location(1)

List servers

client.list_servers

Get server details

client.get_server(5)

Update server details

client.update_server_details(5, name: "name of the server", user: 1, external_id: "external id of the server", description: "description of the server")

Update build

client.update_server_build(5, allocation: 1, memory: 512, swap: 0, disk: 200, io: 500, cpu: 0, threads: nil, feature_limits: {"databases" => 5, "allocations" => 5, "backups" => 2})

Update startup

client.update_server_startup(5, startup: "java -Xms128M -Xmx{{SERVER_MEMORY}}M -jar {{SERVER_JARFILE}}", environment: {
    "SERVER_JARFILE": "server.jar",
    "VANILLA_VERSION": "latest"
  }, egg: 5, image: "quay.io/pterodactyl/core:java", skip_scripts: false)

Create server

create_server_request = CreateServerRequest.new(
  name: "Building",
  user: 1,
  egg: 1,
  docker_image: "quay.io/pterodactyl/core:java",
  startup: "java -Xms128M -Xmx128M -jar server.jar",
  environment: {
    "BUNGEE_VERSION" => "latest",
    "SERVER_JARFILE" => "server.jar"
  },
  limits: {
    "memory": 128,
    "swap": 0,
    "disk": 512,
    "io": 500,
    "cpu": 100
  },
  feature_limits: {
    "databases": 5,
    "backups": 1
  },
  allocation: {
    "default": 17
  }
)
client.create_server(create_server_request)

Suspend server

client.suspend_server(5)

Reinstall server

client.reinstall_server(5)

Delete server

client.delete_server(5) # defaults to force: false
client.delete_server(5, force: true)

List nests

client.list_nests

Get nest details

client.get_nest(1)

List eggs - Retrieves a list of eggs given a nest id

client.get_eggs(1)

Get egg - Get egg details given an egg id and nest id

client.get_egg(1, nest_id: 1)

Development

TODO: Write development instructions here

Contributing

  1. Fork it (https://github.com/hostari/pterodactyl_panel_client/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors