forked from Alex/Pterodactyl-Panel
API enhancements, return node config, return 200 not 201
This commit is contained in:
parent
ab19e2ee96
commit
84a4c8b7f4
@ -5,6 +5,14 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||
|
||||
## v0.5.0-pre.2 (Bodacious Boreopterus)
|
||||
|
||||
### Added
|
||||
* Return node configuration from remote API by using `/api/nodes/{id}/config` endpoint. Only accepts SSL connections.
|
||||
|
||||
### Changed
|
||||
* Creating a user, server, or node now returns `HTTP/1.1 200` and a JSON element with the user/server/node's ID.
|
||||
|
||||
## v0.5.0-pre.2 (Bodacious Boreopterus)
|
||||
|
||||
### Added
|
||||
* Added support for file copying through the file manager. [#127](https://github.com/Pterodactyl/Panel/issues/127)
|
||||
* Creating new files and folders directly from the right-click dropdown menu in the file manager.
|
||||
|
@ -85,7 +85,7 @@ class NodeController extends BaseController
|
||||
* 'daemonSFTP' => 2022,
|
||||
* 'daemonListen' => 8080
|
||||
* }, headers={"Authorization": "Bearer <jwt-token>"}),
|
||||
* @Response(201),
|
||||
* @Response(200),
|
||||
* @Response(422, body={
|
||||
* "message": "A validation error occured.",
|
||||
* "errors": {},
|
||||
@ -102,9 +102,7 @@ class NodeController extends BaseController
|
||||
try {
|
||||
$node = new NodeRepository;
|
||||
$new = $node->create($request->all());
|
||||
return $this->response->created(route('api.nodes.view', [
|
||||
'id' => $new
|
||||
]));
|
||||
return [ 'id' => $new ];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
} catch (DisplayException $ex) {
|
||||
@ -129,23 +127,23 @@ class NodeController extends BaseController
|
||||
*/
|
||||
public function view(Request $request, $id, $fields = null)
|
||||
{
|
||||
$query = Models\Node::where('id', $id);
|
||||
$node = Models\Node::where('id', $id);
|
||||
|
||||
if (!is_null($request->input('fields'))) {
|
||||
foreach(explode(',', $request->input('fields')) as $field) {
|
||||
if (!empty($field)) {
|
||||
$query->addSelect($field);
|
||||
$node->addSelect($field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!$query->first()) {
|
||||
if (!$node->first()) {
|
||||
throw new NotFoundHttpException('No node by that ID was found.');
|
||||
}
|
||||
|
||||
return [
|
||||
'node' => $query->first(),
|
||||
'node' => $node->first(),
|
||||
'allocations' => [
|
||||
'assigned' => Models\Allocation::where('node', $id)->whereNotNull('assigned_to')->get(),
|
||||
'unassigned' => Models\Allocation::where('node', $id)->whereNull('assigned_to')->get()
|
||||
@ -158,6 +156,59 @@ class NodeController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function config(Request $request, $id)
|
||||
{
|
||||
if (!$request->secure()) {
|
||||
throw new BadRequestHttpException('This API route can only be accessed using a secure connection.');
|
||||
}
|
||||
|
||||
$node = Models\Node::where('id', $id)->first();
|
||||
if (!$node) {
|
||||
throw new NotFoundHttpException('No node by that ID was found.');
|
||||
}
|
||||
|
||||
return [
|
||||
'web' => [
|
||||
'listen' => $node->daemonListen,
|
||||
'ssl' => [
|
||||
'enabled' => ($node->scheme === 'https'),
|
||||
'certificate' => '/etc/certs/' . $node->fqdn . '/fullchain.pem',
|
||||
'key' => '/etc/certs/' . $node->fqdn . '/privkey.pem'
|
||||
]
|
||||
],
|
||||
'docker' => [
|
||||
'socket' => '/var/run/docker.sock',
|
||||
'autoupdate_images' => true
|
||||
],
|
||||
'sftp' => [
|
||||
'path' => $node->daemonBase,
|
||||
'port' => (int) $node->daemonSFTP,
|
||||
'container' => '0x0000'
|
||||
],
|
||||
'logger' => [
|
||||
'path' => 'logs/',
|
||||
'src' => false,
|
||||
'level' => 'info',
|
||||
'period' => '1d',
|
||||
'count' => 3
|
||||
],
|
||||
'remote' => [
|
||||
'download' => route('remote.download'),
|
||||
'installed' => route('remote.install')
|
||||
],
|
||||
'uploads' => [
|
||||
'maximumSize' => 100000000
|
||||
],
|
||||
'keys' => [
|
||||
$node->daemonSecret
|
||||
],
|
||||
'query' => [
|
||||
'kill_on_fail' => true,
|
||||
'fail_limit' => 3
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* List all Node Allocations
|
||||
*
|
||||
|
@ -77,9 +77,7 @@ class ServerController extends BaseController
|
||||
try {
|
||||
$server = new ServerRepository;
|
||||
$new = $server->create($request->all());
|
||||
return $this->response->created(route('api.servers.view', [
|
||||
'id' => $new
|
||||
]));
|
||||
return [ 'id' => $new ];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
} catch (DisplayException $ex) {
|
||||
|
@ -129,9 +129,7 @@ class UserController extends BaseController
|
||||
try {
|
||||
$user = new UserRepository;
|
||||
$create = $user->create($request->input('email'), $request->input('password'), $request->input('admin'), $request->input('custom_id'));
|
||||
return $this->response->created(route('api.users.view', [
|
||||
'id' => $create
|
||||
]));
|
||||
return [ 'id' => $create ];
|
||||
} catch (DisplayValidationException $ex) {
|
||||
throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true));
|
||||
} catch (DisplayException $ex) {
|
||||
|
@ -128,6 +128,11 @@ class APIRoutes
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@view'
|
||||
]);
|
||||
|
||||
$api->get('nodes/{id}/config', [
|
||||
'as' => 'api.nodes.view',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@config'
|
||||
]);
|
||||
|
||||
$api->delete('nodes/{id}', [
|
||||
'as' => 'api.nodes.delete',
|
||||
'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@delete'
|
||||
|
Loading…
Reference in New Issue
Block a user