Skip to content

Commit 44b9b94

Browse files
committed
Implement Request Console
1 parent 3e86cdb commit 44b9b94

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Models/Servers/Server.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,21 @@ public function changeName(string $name): Server
463463
}
464464
}
465465

466+
/**
467+
* Requests credentials for remote access via vnc over websocket to keyboard, monitor, and mouse for a server
468+
*
469+
* @see https://docs.hetzner.cloud/#resources-server-actions-post-16
470+
* @return \LKDev\HetznerCloud\Models\Actions\Action
471+
* @throws \LKDev\HetznerCloud\APIException
472+
*/
473+
public function requestConsole(): Action
474+
{
475+
$response = $this->httpClient->post($this->replaceServerIdInUri('servers/{id}/actions/request_console'));
476+
if (! HetznerAPIClient::hasError($response)) {
477+
return Action::parse(json_decode((string) $response->getBody())->action);
478+
}
479+
}
480+
466481
/**
467482
* @param string $uri
468483
* @return string
@@ -481,6 +496,7 @@ public static function parse($input)
481496
if ($input == null) {
482497
return null;
483498
}
499+
484500
return (new self($input->id))->setAdditionalData($input);
485501
}
486502
}

0 commit comments

Comments
 (0)