如何使用 SoftLayer API 以编程方式订购 EVault 插件?
How do I order an EVault Plugin programmatically using SoftLayer API?
我有一个虚拟服务器和一个与虚拟服务器关联的 EVault。
看起来很容易使用 EVault,我需要订购 EVault 插件之一,例如 EVault Plugin for Oracle。如何以编程方式订购这些 EVault 插件之一以及如何以编程方式取消它?
它是否有点像升级到 EVault,我在其中进行 SoftLayer_Network_Storage_Backup_Evault API 调用之一(例如 upgradeVolumeCapacity() 以升级磁盘大小?
或者更像是下一个全新的插件订单和订单
需要了解 EVault 实例和主机?
一些示例代码(php 首选)订购这些 EVault 插件之一并取消将不胜感激。谢谢。
PS。如果裸机服务器的 process/API/input 不同,请也包含该信息。
您需要使用此处的 placeOrder 方法订购插件代码:
<?php
require_once ('/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
// Create a SoftLayer API client object
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);
# Build a skeleton SoftLayer_Hardware object.
# The object contains the hardware ID of the
# Bare Metal server wich will contain the Evault
# If you want use a Virtual Server instead a
# Bare Metal server build a skeleton SoftLayer_Virtual_Guest object
$virtualGuests = new stdClass();
$virtualGuests->id = 9066729;
$orderVirtualGuest = array
(
$virtualGuests,
);
# The current location where the Evault is.
$location = "449494";
$packageId = 0;
// Build a skeleton SoftLayer_Product_Item_Price object.
// The object contains the price ID of the Evaul plugin
// you wish order.
// To get the list of prices call the Softlayer_Product_Package::getItems method
$prices = array
(
1146,
);
// Convert our item list into an array of skeleton
// SoftLayer_Product_Item_Price objects. These objects contain much more than
// ids, but SoftLayer's ordering system only needs the price's id to know what
// you want to order.
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
// Build a SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault object containing
// the order you wish to place.
$orderTemplate = new stdClass();
$orderTemplate->location = $location;
$orderTemplate->packageId = $packageId;
$orderTemplate->prices = $orderPrices;
$orderTemplate->virtualGuests = $orderVirtualGuest;
print_r($orderTemplate);
// Place the order.
try {
// Re-declare the order template as a SOAP variable, so the SoftLayer
// ordering system knows what type of order you're placing.
$orderTemplate = new SoapVar
(
$orderTemplate,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order',
'http://api.service.softlayer.com/soap/v3/'
);
// verifyOrder() will check your order for errors. Replace this with a call
// to placeOrder() when you're ready to order. Both calls return a receipt
// object that you can use for your records.
//
// Once your order is placed it'll go through SoftLayer's approval and
// provisioning process.
$receipt = $softLayer_product_order->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place server order: ' . $e->getMessage();
}
取消插件比较复杂,只能通过ticket取消。如果您尝试取消 billingItem,它将不起作用。您可以创建标准票证并要求取消插件。此处创建工单示例:
<?php
/**
* Create Standard Ticket
*
* This script creates a standard support ticket and It is assigned to master User.
* The ticket is created with the subject Id:1001 (Accounting Request)
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createStandardTicket
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Ticket
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Utility_File_Attachment
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/Php/SoftLayer/SoftLayer/SoapClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
/**
* Declare parameters for the ticket
* @var string $contents
* @var int $attachmentId
* @var string $rootPassword
* @var string $controlPanelPassword
* @var string $accessPort
* @var string $attachmentType
* @var int $subjectId
* @var string $title
*/
$contents = "This is for test";
$attachmentId = null;
$rootPassword = "";
$controlPanelPassword = "";
$accessPort = "";
$attachmentType = "";
$subjectId = 1001;
$title = "This is for test";
// Create a SoftLayer API client object for "SoftLayer_Account" and "SoftLayer_Ticket" services
$accountService = SoftLayer_SoapClient::getClient("SoftLayer_Account", null, $username, $apiKey);
$ticketService = SoftLayer_SoapClient::getClient("SoftLayer_Ticket", null, $username, $apiKey);
// Get Id for the Master User
$accountService -> setObjectMask("mask[masterUser]");
$account = $accountService -> getObject();
// Build a skeleton SoftLayer_Ticket object containing the data of the ticket to submit.
$templateObject = new stdClass();
$templateObject -> assignedUserId = $account -> masterUser -> id;
$templateObject -> subjectId = $subjectId;
$templateObject -> title = $title;
try {
$standardTicket = $ticketService -> createStandardTicket($templateObject, $contents, $attachmentId, $rootPassword, $controlPanelPassword, $accessPort, $attachmentType);
print_r($standardTicket);
} catch(Exception $e) {
echo "Unable to create standard ticket: " . $e -> getMessage();
}
您可以在工单中发送以下内容:
请开始取消 Evault 插件:
帐单 ID:000000
取消日期:立即
取消备注
要获取插件的计费项目,您可以使用此代码:
<?php
require_once ('/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
# The orderid of your evault plugin
$orderId = 6566891;
// Create a SoftLayer API client object
$accountClient = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $username, $key);
$cancelClient = SoftLayer_SoapClient::getClient('SoftLayer_Billing_Item', null, $username, $key);
// setting a filter to get the billling items which category code is evault_plugin
$filter = new stdClass();
$filter->allBillingItems = new stdClass();
$filter->allBillingItems->categoryCode = new stdClass();
$filter->allBillingItems->categoryCode->operation = 'evault_plugin';
$accountClient->setObjectFilter($filter);
# Declaring an object mask to get the order id
$objectMask = "mask[orderItem[order]]";
$accountClient->setObjectMask($objectMask);
# Getting the billing items
$billingItems = $accountClient->getAllBillingItems();
# looking for the billing item to cancel
$billingItemToCancel = null;
foreach ($billingItems as &$billingItem) {
if ($billingItem->orderItem->order->id == $orderId){
$billingItemToCancel = $billingItem;
break;
}
}
print_r($billingItemToCancel);
我有一个虚拟服务器和一个与虚拟服务器关联的 EVault。 看起来很容易使用 EVault,我需要订购 EVault 插件之一,例如 EVault Plugin for Oracle。如何以编程方式订购这些 EVault 插件之一以及如何以编程方式取消它?
它是否有点像升级到 EVault,我在其中进行 SoftLayer_Network_Storage_Backup_Evault API 调用之一(例如 upgradeVolumeCapacity() 以升级磁盘大小?
或者更像是下一个全新的插件订单和订单 需要了解 EVault 实例和主机?
一些示例代码(php 首选)订购这些 EVault 插件之一并取消将不胜感激。谢谢。
PS。如果裸机服务器的 process/API/input 不同,请也包含该信息。
您需要使用此处的 placeOrder 方法订购插件代码:
<?php
require_once ('/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
// Create a SoftLayer API client object
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);
# Build a skeleton SoftLayer_Hardware object.
# The object contains the hardware ID of the
# Bare Metal server wich will contain the Evault
# If you want use a Virtual Server instead a
# Bare Metal server build a skeleton SoftLayer_Virtual_Guest object
$virtualGuests = new stdClass();
$virtualGuests->id = 9066729;
$orderVirtualGuest = array
(
$virtualGuests,
);
# The current location where the Evault is.
$location = "449494";
$packageId = 0;
// Build a skeleton SoftLayer_Product_Item_Price object.
// The object contains the price ID of the Evaul plugin
// you wish order.
// To get the list of prices call the Softlayer_Product_Package::getItems method
$prices = array
(
1146,
);
// Convert our item list into an array of skeleton
// SoftLayer_Product_Item_Price objects. These objects contain much more than
// ids, but SoftLayer's ordering system only needs the price's id to know what
// you want to order.
$orderPrices = array();
foreach ($prices as $priceId){
$price = new stdClass();
$price->id = $priceId;
$orderPrices[] = $price;
}
// Build a SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault object containing
// the order you wish to place.
$orderTemplate = new stdClass();
$orderTemplate->location = $location;
$orderTemplate->packageId = $packageId;
$orderTemplate->prices = $orderPrices;
$orderTemplate->virtualGuests = $orderVirtualGuest;
print_r($orderTemplate);
// Place the order.
try {
// Re-declare the order template as a SOAP variable, so the SoftLayer
// ordering system knows what type of order you're placing.
$orderTemplate = new SoapVar
(
$orderTemplate,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order',
'http://api.service.softlayer.com/soap/v3/'
);
// verifyOrder() will check your order for errors. Replace this with a call
// to placeOrder() when you're ready to order. Both calls return a receipt
// object that you can use for your records.
//
// Once your order is placed it'll go through SoftLayer's approval and
// provisioning process.
$receipt = $softLayer_product_order->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place server order: ' . $e->getMessage();
}
取消插件比较复杂,只能通过ticket取消。如果您尝试取消 billingItem,它将不起作用。您可以创建标准票证并要求取消插件。此处创建工单示例:
<?php
/**
* Create Standard Ticket
*
* This script creates a standard support ticket and It is assigned to master User.
* The ticket is created with the subject Id:1001 (Accounting Request)
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createStandardTicket
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Ticket
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Utility_File_Attachment
*
* @license <http://sldn.softlayer.com/wiki/index.php/license>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
require_once "C:/Php/SoftLayer/SoftLayer/SoapClient.class.php";
/**
* Your SoftLayer API username
* @var string
*/
$username = "set me";
/**
* Your SoftLayer API key
* Generate one at: https://control.softlayer.com/account/users
* @var string
*/
$apiKey = "set me";
/**
* Declare parameters for the ticket
* @var string $contents
* @var int $attachmentId
* @var string $rootPassword
* @var string $controlPanelPassword
* @var string $accessPort
* @var string $attachmentType
* @var int $subjectId
* @var string $title
*/
$contents = "This is for test";
$attachmentId = null;
$rootPassword = "";
$controlPanelPassword = "";
$accessPort = "";
$attachmentType = "";
$subjectId = 1001;
$title = "This is for test";
// Create a SoftLayer API client object for "SoftLayer_Account" and "SoftLayer_Ticket" services
$accountService = SoftLayer_SoapClient::getClient("SoftLayer_Account", null, $username, $apiKey);
$ticketService = SoftLayer_SoapClient::getClient("SoftLayer_Ticket", null, $username, $apiKey);
// Get Id for the Master User
$accountService -> setObjectMask("mask[masterUser]");
$account = $accountService -> getObject();
// Build a skeleton SoftLayer_Ticket object containing the data of the ticket to submit.
$templateObject = new stdClass();
$templateObject -> assignedUserId = $account -> masterUser -> id;
$templateObject -> subjectId = $subjectId;
$templateObject -> title = $title;
try {
$standardTicket = $ticketService -> createStandardTicket($templateObject, $contents, $attachmentId, $rootPassword, $controlPanelPassword, $accessPort, $attachmentType);
print_r($standardTicket);
} catch(Exception $e) {
echo "Unable to create standard ticket: " . $e -> getMessage();
}
您可以在工单中发送以下内容: 请开始取消 Evault 插件:
帐单 ID:000000 取消日期:立即 取消备注
要获取插件的计费项目,您可以使用此代码:
<?php
require_once ('/SoftLayer/SoapClient.class.php');
$username = 'set me';
$key = 'set me';
# The orderid of your evault plugin
$orderId = 6566891;
// Create a SoftLayer API client object
$accountClient = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $username, $key);
$cancelClient = SoftLayer_SoapClient::getClient('SoftLayer_Billing_Item', null, $username, $key);
// setting a filter to get the billling items which category code is evault_plugin
$filter = new stdClass();
$filter->allBillingItems = new stdClass();
$filter->allBillingItems->categoryCode = new stdClass();
$filter->allBillingItems->categoryCode->operation = 'evault_plugin';
$accountClient->setObjectFilter($filter);
# Declaring an object mask to get the order id
$objectMask = "mask[orderItem[order]]";
$accountClient->setObjectMask($objectMask);
# Getting the billing items
$billingItems = $accountClient->getAllBillingItems();
# looking for the billing item to cancel
$billingItemToCancel = null;
foreach ($billingItems as &$billingItem) {
if ($billingItem->orderItem->order->id == $orderId){
$billingItemToCancel = $billingItem;
break;
}
}
print_r($billingItemToCancel);