PHP Client for easier use of Open API
$thgHostingClient = new ThgHosting\ThgHostingClient($_ENV['X-Api-Token']);
composer require thg/thg-client
Creates custom request to chosen EP.
$thgHostingClient->request(
string $method, // Allowed methods: GET, POST, DELETE, PUT, PATCH
string $endpoint, // Path to chosen EP for example: "ssd-vps/plans"
array $arguments = [], // Body of request
array $files = [ // Files to send with request
[
// Mime type of file
"mime" => "image/png",
// Name of file
"name" => "file.png",
// Base64 encoded file
"file" => "iVBORw0KGgoAAAANSUhEUgAAAIIAAABzCAYAAABUzdpBAAAIj0lEQVR4Xu2deVRVVRTGP0IN0QRRc8JQ0yy1XI7ZynRlTmmmYCUSKFm4HFFzKUY4g6VMag6..."
],
"/path/to/file.pdf" // Absolute path to file
]
);
Returns SSD VPS Plans with net price in USD.
$thgHostingClient->getSsdVpsPlans();
Returns SSD VPS Locations.
$thgHostingClient->getSsdVpsLocations();
Returns Custom OSes for SSD VPS.
$thgHostingClient->getSsdVpsCustomTemplates(
int $locationId // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
);
Creates an SSD VPS Server.
$thgHostingClient->createSsdVpsServer(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
string $label, // Label for the new SSD VPS Server
string $hostname, // Hostname for the new SSD VPS Server
string $productName, // name of the chosen SSD VPS plan (see “Get SSD VPS Plans”)
?string $osComponentCode = null, // Optional; Component code of the SSD VPS operating system (see “Get SSD VPS Operating Systems”) (you have to pass either os_component_code or custom_template_id)
?bool $backups = null, // Optional; If set to true, server will be created with Backup Protection
?bool $billHourly = null, // Optional; If set to true, billing will be set hourly, otherwise monthly billing will be used
?int $customTemplateId = null // Optional; Pass here the Template ID of Custom OS (see “Get Custom OSes for SSD VPS”) (you have to pass either os_component_code or custom_template_id)
);
Returns SSD VPS Operating Systems.
$thgHostingClient->getSsdVpsOses(
int $locationId // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
);
Returns SSD VPS Servers.
$thgHostingClient->getSsdVpsServers(
?int $locationId = null // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
);
Returns an SSD VPS Server’s details.
$thgHostingClient->getSsdVpsServerDetails(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Deletes an SSD VPS Server.
$thgHostingClient->deleteSsdVpsServer(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server.
);
Returns an SSD VPS Server’s status.
$thgHostingClient->getSsdVpsServerStatus(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Startup an SSD VPS Server.
$thgHostingClient->powerOnSsdVpsServer(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Shutdown an SSD VPS Server.
$thgHostingClient->powerOffSsdVpsServer(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Reboot an SSD VPS Server.
$thgHostingClient->rebootSsdVpsServer(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Reboot an SSD VPS in Recovery Mode.
$thgHostingClient->rebootSsdVpsServerInRecoveryMode(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Change the virtual machine’s root password to regain control of a machine should root access be lost or forgotten.
$thgHostingClient->resetSsdVpsServerPassword(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId, // ID of the SSD VPS Server
?string $newPassword = null // Root password to set. Must be between 6 and 32 characters and valid for the OS of the target virtual machine.
);
Returns an SSD VPS Server’s Backups.
$thgHostingClient->getSsdVpsServerBackups(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId // ID of the SSD VPS Server
);
Add note to an SSD VPS Server’s backup.
$thgHostingClient->addSsdVpsBackupNote(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId, // ID of the SSD VPS Server
int $backupId, // ID of the SSD VPS Backup (see “Get SSD VPS Server Backups”)
string $note // Note
);
Deletes an SSD VPS Server’s Backup.
$thgHostingClient->deleteSsdVpsBackup(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId, // ID of the SSD VPS Server
int $backupId // ID of the SSD VPS Backup (see “Get SSD VPS Server Backups”)
);
Restore an SSD VPS Backup. (Overwrites existing SSD VPS with backed up image).
$thgHostingClient->restoreSsdVpsBackup(
int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”)
int $serverId, // ID of the SSD VPS Server
int $backupId // ID of the SSD VPS Backup (see “Get SSD VPS Server Backups”)
);
Get details for a service with net price in USD.
$thgHostingClient->getServiceDetails(
int $serviceId // ID of the Service
);
Get all DNS zones.
$thgHostingClient->getDnsZones();
Create a DNS zone.
$thgHostingClient->createDnsZone(
string $domainName, // Name of the domain
string $ip // IP address
);
Get DNS zone information.
$thgHostingClient->getDnsZoneDetails(
int $zoneId // ID of the DNS Zone (see “Get DNS Zones”)
);
Remove a DNS zone.
$thgHostingClient->deleteDnsZone(
int $zoneId // ID of the DNS Zone (see “Get DNS Zones”)
);
Adds a DNS record to the specified zone.
$thgHostingClient->addRecordToDnsZone(
int $zoneId // ID of the DNS Zone (see “Get DNS Zones”)
string $type, // Zone type (A / AAAA etc.)
string $host, // Host name or IP address
string $content, // Content depending on the zone type, example: mail.hostname.com
int $ttl, // Time to live - the added record or time to ping/fetch the updated records
?string $service = null, // The symbolic name of the desired service. (only when record type SRV)
?string $protocol = null, // The transport protocol of the desired service. (only when record type SRV)
?int $port = null, // The TCP or UDP port on which the service is to be found. (only when record type SRV)
?int $weight = null, // A relative weight for records with the same priority, higher value means higher chance of getting picked. (only when record type SRV)
?int $mxPriority = null // The priority of the target host, lower value means more preferred. (only when record type SRV or MX)
);
Update an existing DNS zone record.
$thgHostingClient->updateDnsZoneRecord(
int $zoneId, // ID of the DNS Zone (see “Get DNS Zones”)
int $recordId, // ID of the DNS Zone record (see “Get DNS Zone Details”)
string $host, // Host name or IP address
string $content, // Content depending on the zone type, example: mail.hostname.com
int $ttl, // Time to live - the added record or time to ping/fetch the updated records
?string $service = null, // The symbolic name of the desired service. (only when record type SRV)
?string $protocol = null, // The transport protocol of the desired service. (only when record type SRV)
?int $port = null, // The TCP or UDP port on which the service is to be found. (only when record type SRV)
?int $weight = null, // A relative weight for records with the same priority, higher value means higher chance of getting picked. (only when record type SRV)
?int $mxPriority = null // The priority of the target host, lower value means more preferred. (only when record type SRV or MX)
);
Remove a DNS record.
$thgHostingClient->deleteDnsZoneRecord(
int $zoneId, // ID of the DNS Zone (see “Get DNS Zones”)
int $recordId // ID of the DNS Zone record
);
Get a list of all servers assigned to an account.
$thgHostingClient->getServers();
Get full server profile.
$thgHostingClient->getServerDetails(
string $serverId // ID of the Server (see “Get Servers”)
);
Retrieve the current power state of the given dedicated server.
$thgHostingClient->getServerPowerStatus(
string $serverId // ID of the Server (see “Get Servers”)
);
Request the specified dedicated server to be turned on.
$thgHostingClient->powerOnServer(
string $serverId // ID of the Server (see “Get Servers”)
);
Request the specified dedicated server to be turned off.
$thgHostingClient->powerOffServer(
string $serverId // ID of the Server (see “Get Servers”)
);
Request the specified dedicated server to be rebooted.
$thgHostingClient->rebootServer(
string $serverId // ID of the Server (see “Get Servers”)
);
Request friendly name change of specified dedicated server.
$thgHostingClient->changeServerFriendlyName(
string $serverId, // ID of the Server (see “Get Servers”)
$body
);
Set rDNS entry for IP address of specified dedicated server.
$thgHostingClient->changeServerFriendlyName(
string $serverId, // ID of the Server (see “Get Servers”)
string $ipAddress, //IP address the domain name should be associated with
$body
);
Get list of SSH keys currently assigned to given server.
$thgHostingClient->getServerSshKeys(
string $serverId // ID of the Server (see “Get Servers”)
);
Assign one or more SSH keys to given server.
$thgHostingClient->assignServerSshKeys(
string $serverId, // ID of the Server (see “Get Servers”)
array $sshKeyIds // array of SSH key ids to be assigned to the server
);
Un-assign one or more SSH keys from given server.
$thgHostingClient->unAssignServerSshKeys(
string $serverId, // ID of the Server (see “Get Servers”)
array $sshKeyIds // array of SSH key ids to be un-assigned to the server
);
Get a graphical representation of the bandwidth usage for a specific server over the given period.
$thgHostingClient->getServerBandwidthGraph(
int $serverId, // ID of the Server (see “Get Servers”)
string $periodStart = null, // Optional. And RFC3339/ISO8601 date-time string representing the start of period of the dataset. Defaults to the start of today.
string $periodEnd = null // Optional. And RFC3339/ISO8601 date-time string representing the end of period of the dataset. Defaults to one month before the start of today
);
Get a list of available operating systems for provisioning a specific server.
$thgHostingClient->getServerOsList(
int $serverId // ID of the Server (see “Get Servers”)
);
Reimage a server with a new operating system.
$thgHostingClient->reimageServer(
int $serverId, // ID of the Server (see “Get Servers”)
string $osCode, // Code of the OS to reimage the server with (see “Get Server OS List”)
string $reason = null // Optional. Reason for reimage
);
Get IPMI details for server.
$thgHostingClient-getServerIPMIDetails(
int $serverId // ID of the Server (see “Get Servers”)
);
Create VPN user to access IPMI interface.
$thgHostingClient-createServerIPMICredentials(
int $serverId // ID of the Server (see “Get Servers”)
);
Delete VPN access to IPMI interface.
$thgHostingClient-deleteServerIPMICredentials(
int $serverId // ID of the Server (see “Get Servers”)
);
Get a list of active support tickets.
$thgHostingClient->getTickets();
Create a new support ticket.
$thgHostingClient->createTicket(
string $body, // Ticket body
string $subject, // Subject
int $department = 0, // Ticket Department - Default: 0 (General)
int $priority = 0, // Priority of a Ticket (Default: 0 = Low, 1= Normal, 2 = High, 3 = Urgent)
array $attachments = [] // How to attach files you can find described in `request` method
);
Get a list of ticket queues by department.
$thgHostingClient->getTicketDepartments();
Get the details of a specified support ticket.
$thgHostingClient->getTicketDetails(
int $ticketId // ID of the ticket (see “Get Tickets”)
);
Update status of existing support ticket.
$thgHostingClient->updateTicket(
int $ticketId, // ID of the ticket (see “Get Tickets”)
int $priority = 0, // Priority of a Ticket (Default: 0 = Low, 1= Normal, 2 = High, 3 = Urgent)
bool $closeTicket = false // Set to true will close the ticket
);
Add reply to a specific support ticket.
$thgHostingClient->addReplyToTicket(
int $ticketId, // ID of the ticket (see “Get Tickets”)
string $body, // Ticket body
array $attachments = [] // How to attach files you can find described in `request` method
);
Get a list of active status updates.
$thgHostingClient->getStatusUpdates();
Returns customer services.
$thgHostingClient->getBillingServices(
?bool $showAddOns, //Show the add-ons belonging to each service
?string $sortBy, //Sort by column (service_id/createdon)
?string $direction, //Sort direction (default asc)
?int $offset, //If set, returns records starting from this offset
?int $limit //If set, limits the number of records
);
Returns customer invoices.
$thgHostingClient->getBillingInvoices(
?int $offset, //If set, returns records starting from this offset
?int $limit //If set, limits the number of records
);
Returns a list of available upgrades for chosen service.
$thgHostingClient->getBillingServiceUpgrades(
int $service_id // ID of the Service (see “Get Services”)
);
Upgrades service.
// Example of IP Count with all possible options, you can send only those that have value over 0
$ipCount = [
"vpn" => 0,
"sqldb" => 0,
"ssl_cert" => 0,
"terminal" => 0,
"application" => 0,
"voice" => 0,
"media" => 0,
"mailing" => 0,
"other" => 0,
];
$thgHostingClient->upgradesService(
int $serviceId, // To which server add chosen Upgrade (see “Get Services”)
string $addonCode, // Upgrade category code (see “Get Upgrades”)
string $optionCode, // Upgrade Code (see “Get Upgrades”)
string $details = '', // Reason explaining the need for upgrade (Required for IP Request)
int $quantity = 1 // The amount of Upgrades (Ignore when sending requuest for more IPs)
?array $ipCount = null // Required only when sending request for new IP. Describes the amount and type of needed IPs.
);
Returns Microsoft Licenses
$thgHostingClient->getMicrosoftLicenses(
int $serviceId, // Server service ID to get a list of licenses
);
Returns Microsoft License Details
$thgHostingClient->getMicrosoftLicenseDetails(
int $serviceId, // Server service ID for retrieving of an MS license details which belongs to
int $licenseId, // License ID to get an MS license details
);
Deletes a Microsoft License
$thgHostingClient->deleteMicrosoftLicense(
int $serviceId, // Server service ID for deleting of an MS license which belongs to
int $licenseId, // License ID to delete
);
Returns A List Of Microsoft License Products
$thgHostingClient->getMicrosoftLicenseProducts(
int $serviceId, // Server service ID to get a list of license products
);
Returns A List Of SSH Keys
$thgHostingClient->listSshKeys();
Creates New SSH Key Record
$thgHostingClient->createSshKey(
string $key, // Public RSA Key to be stored
string $label, // Label for SSH Key
);
Updates Label For SSH Key Given Id
$thgHostingClient->updateSshKeyLabel(
int $sshId, // The ID for the SSH Key to be updated
string $label, // The new label for the SSH Key
);
Delete An SSH Key Of The Given Id
$thgHostingClient->deleteSshKey(
int $sshId, // The ID of the SSH Key to be deleted
);
);
Returns An SSH Key Given Id
$thgHostingClient->getSshKeyById(
int $sshId, // The ID of the SSH Key to be fetched
);
Returns server inventory list
$thgHostingClient->getServerInventory(
?int $datacenterId = null,
?string $cpuBrand = null,
?int $minCpuCores = null,
?int $maxCpuCores = null,
?float $minCpuSpeed = null,
?float $maxCpuSpeed = null,
?int $minRam = null,
?int $maxRam = null,
?string $storageType = null,
?int $minStorage = null,
?int $maxStorage = null,
?int $minNic = null,
?int $maxNic = null,
?float $minPrice = null,
?float $maxPrice = null,
?bool $raidEnabled = null,
?string $sortBy = null,
?string $direction = null
);
Creates new bare metal server order
$thgHostingClient->createBareMetalServerOrder(
string $skuProductName,
int $quantity,
string $locationCode,
string $operatingSystemProductCode, //Find available OS product codes by calling the list addons endpoint
?string $licenseProductCode = null, //Find available license product codes by calling the list addons endpoint
?int $additionalBandwidthTb = null,
?string $supportLevelProductCode = null, //Find available managed support product codes by calling the list addons endpoint
?array $sshKeyIds = null //Add ssh keys to the server.
);
Returns list of all available addons for a bare metal server
$thgHostingClient->listAvailableBareMetalAddons(
string $skuProductName,
string $locationCode
);