|
@@ -14,17 +14,6 @@ use Illuminate\Support\Facades\Http;
|
|
|
|
|
|
class Pterodactyl
|
|
class Pterodactyl
|
|
{
|
|
{
|
|
- /**
|
|
|
|
- * @return null
|
|
|
|
- * @throws Exception
|
|
|
|
- */
|
|
|
|
- public static function getNests()
|
|
|
|
- {
|
|
|
|
- $response = self::client()->get('/application/nests');
|
|
|
|
- if ($response->failed()) throw self::getException();
|
|
|
|
- return $response->json()['data'];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
//TODO: Extend error handling (maybe logger for more errors when debugging)
|
|
//TODO: Extend error handling (maybe logger for more errors when debugging)
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -70,6 +59,17 @@ class Pterodactyl
|
|
return $response->json()['data'];
|
|
return $response->json()['data'];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @return null
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ public static function getNests()
|
|
|
|
+ {
|
|
|
|
+ $response = self::client()->get('/application/nests');
|
|
|
|
+ if ($response->failed()) throw self::getException();
|
|
|
|
+ return $response->json()['data'];
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @return mixed
|
|
* @return mixed
|
|
* @throws Exception
|
|
* @throws Exception
|
|
@@ -84,10 +84,10 @@ class Pterodactyl
|
|
/**
|
|
/**
|
|
* @param Node $node
|
|
* @param Node $node
|
|
* @return mixed
|
|
* @return mixed
|
|
|
|
+ * @throws Exception
|
|
*/
|
|
*/
|
|
public static function getFreeAllocationId(Node $node)
|
|
public static function getFreeAllocationId(Node $node)
|
|
{
|
|
{
|
|
-
|
|
|
|
return self::getFreeAllocations($node)[0]['attributes']['id'] ?? null;
|
|
return self::getFreeAllocations($node)[0]['attributes']['id'] ?? null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -114,6 +114,7 @@ class Pterodactyl
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param Node $node
|
|
* @param Node $node
|
|
|
|
+ * @return array|mixed
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public static function getAllocations(Node $node)
|
|
public static function getAllocations(Node $node)
|
|
@@ -142,21 +143,21 @@ class Pterodactyl
|
|
public static function createServer(Server $server, Egg $egg, int $allocationId)
|
|
public static function createServer(Server $server, Egg $egg, int $allocationId)
|
|
{
|
|
{
|
|
return self::client()->post("/application/servers", [
|
|
return self::client()->post("/application/servers", [
|
|
- "name" => $server->name,
|
|
|
|
- "external_id" => $server->id,
|
|
|
|
- "user" => $server->user->pterodactyl_id,
|
|
|
|
- "egg" => $egg->id,
|
|
|
|
- "docker_image" => $egg->docker_image,
|
|
|
|
- "startup" => $egg->startup,
|
|
|
|
- "environment" => $egg->getEnvironmentVariables(),
|
|
|
|
- "limits" => [
|
|
|
|
|
|
+ "name" => $server->name,
|
|
|
|
+ "external_id" => $server->id,
|
|
|
|
+ "user" => $server->user->pterodactyl_id,
|
|
|
|
+ "egg" => $egg->id,
|
|
|
|
+ "docker_image" => $egg->docker_image,
|
|
|
|
+ "startup" => $egg->startup,
|
|
|
|
+ "environment" => $egg->getEnvironmentVariables(),
|
|
|
|
+ "limits" => [
|
|
"memory" => $server->product->memory,
|
|
"memory" => $server->product->memory,
|
|
"swap" => $server->product->swap,
|
|
"swap" => $server->product->swap,
|
|
"disk" => $server->product->disk,
|
|
"disk" => $server->product->disk,
|
|
"io" => $server->product->io,
|
|
"io" => $server->product->io,
|
|
"cpu" => $server->product->cpu
|
|
"cpu" => $server->product->cpu
|
|
],
|
|
],
|
|
- "feature_limits" => [
|
|
|
|
|
|
+ "feature_limits" => [
|
|
"databases" => $server->product->databases,
|
|
"databases" => $server->product->databases,
|
|
"backups" => $server->product->backups,
|
|
"backups" => $server->product->backups,
|
|
"allocations" => $server->product->allocations,
|
|
"allocations" => $server->product->allocations,
|