-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
811 additions
and
745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,56 @@ | ||
<?php | ||
|
||
namespace HCGCloud\Pterodactyl\Actions; | ||
|
||
use HCGCloud\Pterodactyl\Resources\Allocation; | ||
|
||
trait ManagesAllocations | ||
{ | ||
/** | ||
* Get the collection of allocations for a given node. | ||
* | ||
* @param integer $nodeId | ||
* @return array | ||
*/ | ||
public function allocations($nodeId, int $page = 1) | ||
{ | ||
$data = $this->get("api/application/nodes/$nodeId" . "/allocations?page=" . $page); | ||
$transform = $this->transformCollection( | ||
$data['data'], | ||
Allocation::class | ||
); | ||
return [ | ||
'data' => $transform, | ||
'meta' => $data['meta'] | ||
]; | ||
} | ||
|
||
/** | ||
* Create new allocation(s). | ||
* | ||
* @param integer $nodeId | ||
* @param array $data | ||
* @return void | ||
*/ | ||
public function createAllocation($nodeId, array $data) | ||
{ | ||
return $this->post("api/application/nodes/$nodeId/allocations", $data); | ||
} | ||
|
||
/** | ||
* Delete the given allocation. | ||
* | ||
* @param integer $nodeId | ||
* @param integer $allocationId | ||
* @param array $data | ||
* @return void | ||
*/ | ||
public function deleteAllocation($nodeId, $allocationId) | ||
{ | ||
return $this->delete("api/application/nodes/$nodeId/allocations/$allocationId"); | ||
} | ||
} | ||
<?php | ||
|
||
namespace HCGCloud\Pterodactyl\Actions; | ||
|
||
use HCGCloud\Pterodactyl\Resources\Allocation; | ||
|
||
trait ManagesAllocations | ||
{ | ||
/** | ||
* Get the collection of allocations for a given node. | ||
* | ||
* @param int $nodeId | ||
* | ||
* @return array | ||
*/ | ||
public function allocations($nodeId, int $page = 1) | ||
{ | ||
$data = $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page); | ||
$transform = $this->transformCollection( | ||
$data['data'], | ||
Allocation::class | ||
); | ||
|
||
return [ | ||
'data' => $transform, | ||
'meta' => $data['meta'], | ||
]; | ||
} | ||
|
||
/** | ||
* Create new allocation(s). | ||
* | ||
* @param int $nodeId | ||
* @param array $data | ||
* | ||
* @return void | ||
*/ | ||
public function createAllocation($nodeId, array $data) | ||
{ | ||
return $this->post("api/application/nodes/$nodeId/allocations", $data); | ||
} | ||
|
||
/** | ||
* Delete the given allocation. | ||
* | ||
* @param int $nodeId | ||
* @param int $allocationId | ||
* @param array $data | ||
* | ||
* @return void | ||
*/ | ||
public function deleteAllocation($nodeId, $allocationId) | ||
{ | ||
return $this->delete("api/application/nodes/$nodeId/allocations/$allocationId"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.