-
Notifications
You must be signed in to change notification settings - Fork 8
Resources: Servers
Danny Li edited this page Apr 3, 2018
·
3 revisions
-
::findAction
- Retrieve a specific action object for a Server. -
::create
- Create a new server. -
::getMetrics
- Retrieve metrics for this server. -
::rename
- Rename a server. -
::start
- Start a server. -
::powerOn
- Start a server (alias). -
::reboot
- Reboot a server. -
::restart
- Reboot a server (alias). -
::reset
- Reset a server. -
::shutdown
- Shutdown a server. -
::stop
- Stop a server. -
::powerOff
- Power off a server. -
::resetPassword
- Reset the root password of a server. -
::enableRescue
- Enable the Hetzner Rescue System for a server. -
::disableRescue
- Disable the Hetzner Rescue System for a server. -
::createImage
- Create an image (snapshot) from a server by copying the contents of its disks. -
::rebuild
- Rebuild a server, overwriting its disk with the content of an image, thereby destroying all data on the target server. -
::changeType
- Change the type (Cores, RAM and disk sizes) of a server. -
::enableBackups
- Enable automatic backups. -
::disableBackups
- Disable automatic backups. -
::attachIso
- Attach an ISO. -
::detachIso
- Detach an ISO. -
::changeDnsPtr
- Changes the hostname that will appear when getting the hostname belonging to the primary IPs (ipv4 and ipv6) of this server. -
::changeProtection
- Changes the protection configuration of the server. -
::requestConsole
- Requests credentials for remote access. -
::delete
- Delete a server.
The Server
object has the following methods:
<?php
use Exploriment\HetznerCloud;
// retrieve the server
$server = HetznerCloud\Servers::find(1);
// returns the server ID (int)
$server->getId();
// returns the server name (string)
$server->getName();
// returns the server status (string)
$server->getStatus();
// status = running? (boolean)
$server->isRunning();
// status = initializing? (boolean)
$server->isInitializing();
// status = starting? (boolean)
$server->isStarting();
// status = stopping? (boolean)
$server->isStopping();
// status = off? (boolean)
$server->isOff();
// status = deleting? (boolean)
$server->isDeleting();
// status = migrating? (boolean)
$server->isMigrating();
// status = rebuilding? (boolean)
$server->isRebuilding();
// status = unknown? (boolean)
$server->isUnknown();
// returns the time when the server was created (string)
$server->getCreated();
// returns public network information (object)
$net = $server->getPublicNet();
// returns ipv4 information (object)
$ipv4 = $net->getIpv4();
$ipv4->ip; // string
$ipv4->blocked; // boolean
$ipv4->dns_ptr; // string
// returns ipv6 information (object)
$ipv6 = $net->getIpv6();
$ipv6->ip; // string
$ipv6->blocked; // boolean
$ipv6->dns_ptr; // array
// returns assigned floating ips ids (array)
$net->getFloatingIps();
/**
* returns the server type
* @return https://github.com/Exploriment/hcloud-php/wiki/resources:-servertypes#servertype-object
*/
$server->getServerType();
/**
* returns the datacenter the server is located at
* @return https://github.com/Exploriment/hcloud-php/wiki/resources:-datacenters#datacenter-object
*/
$server->getDatacenter();
/**
* returns the image the server was created from
* @return null or https://github.com/Exploriment/hcloud-php/wiki/resources:-images#image-object
*/
$server->getImage();
/**
* returns the ISO image that is attached to this server
* @return null or https://github.com/Exploriment/hcloud-php/wiki/resources:-locations#location-object
*/
$server->getIso();
// is rescue mode enabled? (boolean)
$server->isRescueEnabled();
// is the server locked and unavailable to the user?
$server->isLocked();
// retrieve the backup window hours (UTC) (null or string)
$server->getBackupWindow();
// retrieve the outgoing traffic in bytes (int or null)
$server->getOutgoingTraffic();
// retrieve the ingoing traffic in bytes (int or null)
$server->getIngoingTraffic();
// calculate the remaining free traffic in byetes (int)
// 0 outgoing traffic is assumed if $server->getOutgoingTraffic() returns null
$server->getRemainingTraffic();
/**
* All the special methods mentioned above are available in the server object
* too. The method names are exactly the same, so are the parameters, except
* for the server ID, which can be omitted. A few examples below:
*
* @example $server->findAction($action_id);
* @example $server->start();
* @example $server->changePtr($ip, $dns_ptr);
*/
by Exploriment.io
- README.md
-
Resources introduction
- Actions
-
Servers
::findAction
::create
::getMetrics
::rename
::start
-
::powerOn
(alias) ::reboot
-
::restart
(alias) ::reset
::shutdown
-
::stop
(alias) ::powerOff
::resetPassword
::enableRescue
::disableRescue
::createImage
::rebuild
::changeType
::enableBackups
::disableBackups
::attachIso
::detachIso
::changeDnsPtr
::changeProtection
::requestConsole
::delete
- FloatingIps
- SshKeys
- ServerTypes
- Locations
- Datacenters
- Images
- ISOs