thg / thg-client
THG 开放API客户端
Requires
- php: ^7.2 || ^8.0
- ext-curl: *
- ext-fileinfo: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.5
- dev-main
- 1.3.6
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- dev-Andy/HCE-1825-Create-dependabot-yml
- dev-garvit/HCE-428/add-endpoints-for-creating-new-bare-metal-server-order
- dev-andy/hce-1609-support-OS-reload
- dev-billy/remove-snyk
- dev-garvit/HCE-425/adding-server-inventory-endpoint
- dev-dev
This package is auto-updated.
Last update: 2024-09-24 16:33:35 UTC
README
PHP客户端,便于使用开放API
$thgHostingClient = new ThgHosting\ThgHostingClient($_ENV['X-Api-Token']);
安装
composer require thg/thg-client
方法
请求
创建到所选端点的自定义请求。
$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 ] );
获取SSD VPS计划
返回以美元计算的SSD VPS计划净价。
$thgHostingClient->getSsdVpsPlans();
获取SSD VPS位置
返回SSD VPS位置。
$thgHostingClient->getSsdVpsLocations();
获取SSD VPS的定制操作系统
返回SSD VPS的定制操作系统。
$thgHostingClient->getSsdVpsCustomTemplates( int $locationId // ID of the SSD VPS Location (see “Get SSD VPS Locations”) );
创建SSD VPS服务器
创建SSD VPS服务器。
$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) );
获取SSD VPS操作系统
返回SSD VPS操作系统。
$thgHostingClient->getSsdVpsOses( int $locationId // ID of the SSD VPS Location (see “Get SSD VPS Locations”) );
获取SSD VPS服务器
返回SSD VPS服务器。
$thgHostingClient->getSsdVpsServers( ?int $locationId = null // ID of the SSD VPS Location (see “Get SSD VPS Locations”) );
获取SSD VPS服务器详细信息
返回SSD VPS服务器的详细信息。
$thgHostingClient->getSsdVpsServerDetails( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
删除SSD VPS服务器
删除SSD VPS服务器。
$thgHostingClient->deleteSsdVpsServer( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server. );
获取SSD VPS服务器状态
返回SSD VPS服务器的状态。
$thgHostingClient->getSsdVpsServerStatus( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
开启SSD VPS服务器
启动SSD VPS服务器。
$thgHostingClient->powerOnSsdVpsServer( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
关闭SSD VPS服务器
关闭SSD VPS服务器。
$thgHostingClient->powerOffSsdVpsServer( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
重启SSD VPS服务器
重启SSD VPS服务器。
$thgHostingClient->rebootSsdVpsServer( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
在恢复模式下重启SSD VPS服务器
在恢复模式下重启SSD VPS。
$thgHostingClient->rebootSsdVpsServerInRecoveryMode( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
重置SSD VPS服务器密码
更改虚拟机的root密码,以便在root访问丢失或忘记时重新获得对机器的控制。
$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. );
获取SSD VPS服务器备份
返回SSD VPS服务器的备份。
$thgHostingClient->getSsdVpsServerBackups( int $locationId, // ID of the SSD VPS Location (see “Get SSD VPS Locations”) int $serverId // ID of the SSD VPS Server );
向SSD VPS服务器备份添加备注
向SSD VPS服务器的备份添加备注。
$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 );
删除SSD VPS服务器备份
删除SSD VPS服务器的备份。
$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”) );
使用备份恢复SSD VPS服务器
恢复SSD VPS备份。(使用备份的映像覆盖现有的SSD VPS)。
$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”) );
获取服务详情
获取以美元计算的服务的详细信息。
$thgHostingClient->getServiceDetails( int $serviceId // ID of the Service );
获取DNS区域
获取所有DNS区域。
$thgHostingClient->getDnsZones();
创建DNS区域
创建DNS区域。
$thgHostingClient->createDnsZone( string $domainName, // Name of the domain string $ip // IP address );
获取DNS区域详情
获取DNS区域信息。
$thgHostingClient->getDnsZoneDetails( int $zoneId // ID of the DNS Zone (see “Get DNS Zones”) );
删除DNS区域
删除DNS区域。
$thgHostingClient->deleteDnsZone( int $zoneId // ID of the DNS Zone (see “Get DNS Zones”) );
向DNS区域添加记录
将DNS记录添加到指定区域。
$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) );
更新DNS区域记录
更新现有的DNS区域记录。
$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) );
删除DNS区域记录
删除DNS记录。
$thgHostingClient->deleteDnsZoneRecord( int $zoneId, // ID of the DNS Zone (see “Get DNS Zones”) int $recordId // ID of the DNS Zone record );
获取服务器
获取分配给帐户的所有服务器的列表。
$thgHostingClient->getServers();
获取服务器详情
获取完整的服务器配置文件。
$thgHostingClient->getServerDetails( string $serverId // ID of the Server (see “Get Servers”) );
获取服务器电源状态
检索指定专用服务器的当前电源状态。
$thgHostingClient->getServerPowerStatus( string $serverId // ID of the Server (see “Get Servers”) );
开启服务器
请求指定的专用服务器开启。
$thgHostingClient->powerOnServer( string $serverId // ID of the Server (see “Get Servers”) );
关闭服务器
请求指定的专用服务器关闭。
$thgHostingClient->powerOffServer( string $serverId // ID of the Server (see “Get Servers”) );
重启服务器
请求指定的专用服务器重启。
$thgHostingClient->rebootServer( string $serverId // ID of the Server (see “Get Servers”) );
更改服务器友好名称
请求更改指定的专用服务器的友好名称。
$thgHostingClient->changeServerFriendlyName( string $serverId, // ID of the Server (see “Get Servers”) $body );
为IP地址设置rDNS条目
为指定专用服务器的IP地址设置rDNS条目。
$thgHostingClient->changeServerFriendlyName( string $serverId, // ID of the Server (see “Get Servers”) string $ipAddress, //IP address the domain name should be associated with $body );
获取服务器带宽图
获取特定服务器在给定时间段内的带宽使用情况的图形表示。
$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 );
获取服务器操作系统列表
获取为特定服务器提供程序提供的操作系统列表。
$thgHostingClient->getServerOsList( int $serverId // ID of the Server (see “Get Servers”) );
重置服务器镜像
使用新操作系统重置服务器。
$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 );
获取服务器的IPMI详情
获取服务器的IPMI详情。
$thgHostingClient-getServerIPMIDetails( int $serverId // ID of the Server (see “Get Servers”) );
创建VPN用户以访问IPMI界面
创建VPN用户以访问IPMI界面。
$thgHostingClient-createServerIPMICredentials( int $serverId // ID of the Server (see “Get Servers”) );
删除对IPMI界面的VPN访问
删除对IPMI界面的VPN访问。
$thgHostingClient-deleteServerIPMICredentials( int $serverId // ID of the Server (see “Get Servers”) );
获取工单
获取活跃支持工单的列表。
$thgHostingClient->getTickets();
创建工单
创建一个新的支持工单。
$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 );
获取部门列表
按部门获取工单队列列表。
$thgHostingClient->getTicketDepartments();
获取工单详情
获取指定支持工单的详情。
$thgHostingClient->getTicketDetails( int $ticketId // ID of the ticket (see “Get Tickets”) );
更新工单
更新现有支持工单的状态。
$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 );
添加工单回复
向特定支持工单添加回复。
$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 );
获取状态更新
获取活动状态更新的列表。
$thgHostingClient->getStatusUpdates();
获取数据中心
返回所有数据中心。
$thgHostingClient->getDatacenters();
获取产品类别
返回产品类别。
$thgHostingClient->getProductCategory();
获取产品
返回类别和位置中的所有产品。
$thgHostingClient->getProductsInCategory( int $locationId, // ID of the location (see “Get All Locations”) int $categoryId // ID of the category (see “Get All Categories”) );
获取产品详情
返回产品详情。
$thgHostingClient->getProductDetails( int $locationId, // ID of the location (see “Get All Locations”) int $categoryId // ID of the category (see “Get All Categories”) int $productId // ID of the product (see “Get Products”) );
获取含税计算价格
返回订单的含税计算价格。
$body = [ [ "product_id" => 265, "quantity" => 1, "price" => 354.9, "datacenter_id" => 12, "duration_id" => 2, "addons" => [ [ "addon_id" => 4, "selected_option" => 2, "price" => 10 ] ] ] ]; $thgHostingClient->getCalculatedPriceWithTax( array $body );
获取支付方式
返回支付方式。
$thgHostingClient->getPaymentMethods();
获取计费服务
返回客户服务。
$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 );
获取计费发票
返回客户发票。
$thgHostingClient->getBillingInvoices( ?int $offset, //If set, returns records starting from this offset ?int $limit //If set, limits the number of records );
获取SSL证书
返回SSL证书。
$thgHostingClient->getSSLCertificates( ?int $offset, //If set, returns records starting from this offset ?int $limit //If set, limits the number of records bool $collected = false //If true, returns only collected certificates );
创建SSL证书
此方法有两个作用;它验证CSR和其他所需字段,同时返回可能的域名控制验证(DCV)电子邮件地址,这些地址用于验证域名所有权。这些电子邮件在成功的调用中返回到'text'数组。
$thgHostingClient->createSSLCertificate( string $domain, //FQDN for which the SSL is being requested for string $csr //CSR generated for the request );
应用SSL证书
此方法有两个作用;它验证CSR和其他所需字段,同时返回可能的域名控制验证(DCV)电子邮件地址,这些地址用于验证域名所有权。这些电子邮件在成功的调用中返回到'text'数组。
$thgHostingClient->applySSLCertificate( string $domain, //FQDN for which the SSL is being requested for string $csr, //CSR generated for the request string $email, //Verification email address provided by createSSLCertificate() int $serverSoftware //Type of server //2 - Apache //10 - Java-based servers //14 - Microsoft IIS 5.x to 6.x //35 - Microsoft IIS 7.x and later //36 - nginx //18 - Oracle //30 - Plesk //31 - WHM/cPanel //-1 - OTHER );
下载SSL证书
下载SSL证书
$thgHostingClient->downloadSSLCertificate( int $certificateId //ID of the SSL certificate );
提交订单以处理
提交订单以处理。
$body = [ "order" => [ [ "category_id" => 2, "product_id" => 265, "quantity" => 1, "price" => 354.9, "datacenter_id" => 12, "duration_id" => 2, "addons" => [], "sales_tax" => 0 ] ], "paymentMethodId" => 21, "contact_data" => [ "address" => "816 Address", "city" => "city", "company" => "Company", "country" => "US", "county" => "County 1", "email" => "mail@mail.com", "first_name" => "John", "last_name" => "Doe", "phone" => "+44 11 2222 3333", "postcode" => "12345" ] ]; $thgHostingClient->submitOrderForProcessing( array $body );
获取服务升级
返回所选服务的可用升级列表。
$thgHostingClient->getBillingServiceUpgrades( int $service_id // ID of the Service (see “Get Services”) );
升级服务
升级服务。
// 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. );
获取微软许可证
返回微软许可证。
$thgHostingClient->getMicrosoftLicenses( int $serviceId, // Server service ID to get a list of licenses );
获取微软许可证详情
返回微软许可证详情。
$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 );
删除微软许可证
删除微软许可证。
$thgHostingClient->deleteMicrosoftLicense( int $serviceId, // Server service ID for deleting of an MS license which belongs to int $licenseId, // License ID to delete );
获取可用的微软许可证产品
返回微软许可证产品列表。
$thgHostingClient->getMicrosoftLicenseProducts( int $serviceId, // Server service ID to get a list of license products );
列出SSH密钥数据
返回SSH密钥列表。
$thgHostingClient->listSshKeys();
添加SSH密钥
创建新的SSH密钥记录
$thgHostingClient->createSshKey( string $key, // Public RSA Key to be stored string $label, // Label for SSH Key );
更新现有SSH密钥的标签
更新给定ID的SSH密钥的标签
$thgHostingClient->updateSshKeyLabel( int $sshId, // The ID for the SSH Key to be updated string $label, // The new label for the SSH Key );
删除SSH密钥
删除给定ID的SSH密钥
$thgHostingClient->deleteSshKey( int $sshId, // The ID of the SSH Key to be deleted ); );
获取ID为的SSH密钥
返回给定ID的SSH密钥。
$thgHostingClient->getSshKeyById( int $sshId, // The ID of the SSH Key to be fetched );
获取服务器清单列表
返回服务器清单列表。
$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 );
创建新的裸金属服务器订单
创建新的裸金属服务器订单。
$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 );
列出裸金属服务器订单的可用附加组件
返回裸金属服务器的所有可用附加组件列表。
$thgHostingClient->listAvailableBareMetalAddons( string $skuProductName, string $locationCode );