|
1 | 1 | <?php |
2 | 2 |
|
3 | | -require_once __DIR__.'/../bootstrap.php'; |
| 3 | +require_once __DIR__ . '/../bootstrap.php'; |
4 | 4 |
|
5 | 5 | $serverType = $hetznerClient->serverTypes()->get(1); |
6 | | -$location = $hetznerClient->locations()->all('fsn1')[0]; |
7 | | -$image = $hetznerClient->images()->all('ubuntu-18.04')[0]; |
| 6 | +$location = $hetznerClient->locations()->getByName("fsn1"); |
| 7 | +$image = $hetznerClient->images()->getByName("ubuntu-20.04"); |
8 | 8 | $apiResponse = $hetznerClient->servers()->createInLocation('my-example-server.test', $serverType, $image, $location); |
9 | 9 | $server = $apiResponse->getResponsePart('server'); |
10 | 10 | $action = $apiResponse->getResponsePart('action'); |
11 | | -echo 'Server: '.$server->name.PHP_EOL; |
12 | | -echo 'IP: '.$server->publicNet->ipv4->ip.PHP_EOL; |
13 | | -echo 'Password: '.$apiResponse->getResponsePart('root_password').PHP_EOL; |
14 | | -echo 'Now we wait on the success of the server creation!'.PHP_EOL; |
15 | | -echo date('H:i:s').PHP_EOL; |
16 | | -\LKDev\HetznerCloud\Models\Actions\Actions::waitActionCompleted($action); |
17 | | -echo date('H:i:s').PHP_EOL; |
| 11 | +echo 'Server: ' . $server->name . PHP_EOL; |
| 12 | +echo 'IP: ' . $server->publicNet->ipv4->ip . PHP_EOL; |
| 13 | +echo 'Password: ' . $apiResponse->getResponsePart('root_password') . PHP_EOL; |
| 14 | +echo 'Now we wait on the success of the server creation!' . PHP_EOL; |
| 15 | +echo date('H:i:s') . PHP_EOL; |
| 16 | +$action->waitUntilCompleted(); |
| 17 | +echo date('H:i:s') . PHP_EOL; |
18 | 18 | echo 'Done!'; |
0 commit comments