Как получить идентификатор softlayer_ticket после вызова SoftLayer_billing_Item.cancelItem()

Я использую PHP-библиотеку SoftLayer API для вызова SoftLayer_billing_Item.cancelItem(...) или SoftLayer_billing_Item.cancelService() для отмены элемента. Я заметил, что на клиентском портале SoftLayer будет создан билет SoftLayer после вызова SoftLayer_billing_Item.cancelItem(...) или SoftLayer_billing_Item.cancelService().

Возвращаемый API результат SoftLayer_billing_Item.cancelItem(...) или SoftLayer_billing_Item.cancelService() не содержит информации о результате SoftLayer_Ticket.

Как я могу использовать API для получения значения идентификатора SoftLayer_Ticket, связанного с SoftLayer_billing_Item.cancelItem(...) или SoftLayer_billing_Item.cancelService() .

Есть ли такой же файл php, который я могу использовать?


person mnnmountain    schedule 02.06.2016    source источник


Ответы (1)


Вы можете использовать следующую objectMask в своем коде:

<?php
// Reference to the SL API client (It depends on your path installation) 
require_once ('C:\softlayer-api-php-client-master\src\SoapClient.php');
require_once ('C:\softlayer-api-php-client-master\src\Common\ObjectMask.php');

// Set these values with your valid information.
$username = 'set me';
$apiKey = 'set me';

$service = 'SoftLayer_Billing_Item';

// Set your billing item Id.
$billingItemId = 7883593;

// The client instantiation.
$client = \SoftLayer\SoapClient::getClient($service, $billingItemId, $username, $apiKey);

// The next lines belong to the creation of an object mask that retrieves aditional data
// contained in the objects retrieved.
$objectMask = new \SoftLayer\Common\ObjectMask();
$objectMask->cancellationRequests->ticket;
$client->setObjectMask($objectMask);

try 
{
    // Retrieving the configuration options for a SoftLayer_Hardware object.
    $cancellation_request = $client->getCancellationRequests();
    print_r($cancellation_request);
} 
catch (\Exception $e) 
{
    // Displaying if an error happened.
    die('Script failed, review the next message for further details: ' . $e->getMessage());
}

Вы можете использовать одну и ту же маску объекта таким же образом для таких методов, как SoftLayer_Account::getLastCanceledBillingItem или SoftLayer::getLastCancelledServerBillingItem.

person Marcelo Guzman    schedule 02.06.2016
comment
Спасибо, Марсело. Как использовать фильтр объектов, чтобы получить только последний запрос на отмену, если в элементе выставления счета есть несколько запросов на отмену? - person mnnmountain; 03.06.2016
comment
Я создал свою собственную функцию сортировки и решил проблему. Спасибо. - person mnnmountain; 03.06.2016