Browse Source

GetNodeInfo

Dennis 2 years ago
parent
commit
6bbbfa041e
1 changed files with 27 additions and 0 deletions
  1. 27 0
      app/Classes/Pterodactyl.php

+ 27 - 0
app/Classes/Pterodactyl.php

@@ -86,6 +86,33 @@ class Pterodactyl
         if ($response->failed()) throw self::getException("Failed to get nodes from pterodactyl - ", $response->status());
         return $response->json()['data'];
     }
+    
+    /**
+     * @return mixed
+     * @throws Exception
+     * @description Returns the infos of a single node
+     */
+        public static function getNode($id) {
+        try {
+            $response = self::client()->get('/application/nodes/' . $id);
+        } catch(Exception $e) {
+            throw self::getException($e->getMessage());
+        }
+        if($response->failed()) throw self::getException("Failed to get node id " . $id . " - " . $response->status());
+        return $response->json()['attributes'];
+    }
+    
+    
+
+    public static function getServers() {
+        try {
+            $response = self::client()->get('/application/servers');
+        } catch (Exception $e) {
+            throw self::getException($e->getMessage());
+        }
+        if($response->failed()) throw self::getException("Failed to get list of servers - ", $response->status());
+        return $response->json()['data'];
+    }
 
     /**
      * @return null