mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 16:46:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			930 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			930 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Pterodactyl\Repositories\Wings;
 | 
						|
 | 
						|
use Webmozart\Assert\Assert;
 | 
						|
use Pterodactyl\Models\Server;
 | 
						|
use Psr\Http\Message\ResponseInterface;
 | 
						|
use GuzzleHttp\Exception\TransferException;
 | 
						|
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
 | 
						|
 | 
						|
class DaemonPowerRepository extends DaemonRepository
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Sends a power action to the server instance.
 | 
						|
     *
 | 
						|
     * @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
 | 
						|
     */
 | 
						|
    public function send(string $action): ResponseInterface
 | 
						|
    {
 | 
						|
        Assert::isInstanceOf($this->server, Server::class);
 | 
						|
 | 
						|
        try {
 | 
						|
            return $this->getHttpClient()->post(
 | 
						|
                sprintf('/api/servers/%s/power', $this->server->uuid),
 | 
						|
                ['json' => ['action' => $action]]
 | 
						|
            );
 | 
						|
        } catch (TransferException $exception) {
 | 
						|
            throw new DaemonConnectionException($exception);
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |