misc_pterodactyl-panel/app/Http/Controllers/Api/Application/Nodes/NodeConfigurationController.php

28 lines
930 B
PHP
Raw Normal View History

2020-04-12 17:20:09 -07:00
<?php
namespace Pterodactyl\Http\Controllers\Api\Application\Nodes;
use Pterodactyl\Models\Node;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Requests\Api\Application\Nodes\GetNodeRequest;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class NodeConfigurationController extends ApplicationApiController
{
/**
* Returns the configuration information for a node. This allows for automated deployments
* to remote machines so long as an API key is provided to the machine to make the request
* with, and the node is known.
*
2021-02-24 18:28:24 -07:00
* @throws \Illuminate\Contracts\Container\BindingResolutionException
2020-04-12 17:20:09 -07:00
*/
2021-03-05 10:03:12 -07:00
public function __invoke(GetNodeRequest $request, Node $node): string
2020-04-12 17:20:09 -07:00
{
2021-02-24 18:28:24 -07:00
if ($request->query('format') === 'yaml') {
return $node->getYamlConfiguration();
}
return new JsonResponse($node->getConfiguration());
2020-04-12 17:20:09 -07:00
}
}