2015-12-21 40 views
0

我創建SSL安全證書,專用VLAN防火牆和先進的監測使用的SoftLayer API複雜類型:的SoftLayer API:如何取消Security_Certificate,Network_Firewall和Monitoring_agent對象

SoftLayer_Container_Product_Order_Security_Certificate 
SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated 
SoftLayer_Container_Product_Order_Monitoring_Package 

我試圖找到SoftLayer的API,它可以讓我一旦訂購,取消這些對象。

我可以得到:

SoftLayer_Security_Certificate, 
SoftLayer_Network_Firewall_Module_Context_Interface, 
SoftLayer_Monitoring_Agent object form SoftLayer_Account. 

但是是無​​數據類型:

SoftLayer_Security_Certificate, 
SoftLayer_Network_Firewall_Module_Context_Interface, 
SoftLayer_Monitoring_Agent. 

這不會允許我使用SoftLayer_Billing_Item-> cancelService()取消它們。

有人可以請我指出我可以如何取消使用SoftLayer API的SSL證書,防火牆和監視代理?我會很感激,如果你可以提供PHP示例代碼。

+0

我撥通了另外一個問題的答案見 http://stackoverflow.com/questions/34388803/softlayer-api-how-to-get-advanced-monitoring-and-防火牆在帳戶從o/34396502#34396502 – mnnmountain

回答

0
  1. 對於SoftLayer_Security_Certificate,你只需要從這個標識符,你可以用下面的方法來獲取安全證書標識:

方法:SoftLayer_Account :: getSecurityCertificates 鏈接:http://sldn.softlayer.com/reference/services/SoftLayer_Account/getSecurityCertificates

然後你可以刪除這個,使用Sof tLayer_Security_Certificate:deleteObject方法。

下面的例子:

<?php 
/** 
* Delete Security Certificate 
* 
* This script deletes a security certificate 
* 
* Important manual pages: 
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Security_Certificate/deleteObject 
* 
* @license <http://sldn.softlayer.com/wiki/index.php/license> 
* @author SoftLayer Technologies, Inc. <[email protected]> 
*/ 
require_once '\vendor\autoload.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"; 

/** 
* Define the security certificate identifier. You can retrieve the identifiers from them using 
* SoftLayer_Account::getSecurityCertificates 
* @var int 
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Account/getSecurityCertificates 
*/ 
$securityCertificateId = 14584; 

// Create a SoftLayer API client object for "SoftLayer_Security_Certificate" service 
$client = \SoftLayer\SoapClient::getClient('SoftLayer_Security_Certificate', null, $username, $apiKey); 

// Set init parameters 
$client -> setInitParameter($securityCertificateId); 

try { 
    $result = $client -> deleteObject(); 
    print_r($result); 
} catch(Exception $e) { 
    echo "Unable to delete Security Certificate " . $e -> getMessage(); 
} 

?> 
  • 關於到SoftLayer_Container_Product_Order_Network_Protection_Firewall_Dedicated您的帳戶中有對象,你可以得到所有的人都與他們有以下billingItems REST請求:

    https://$user:[email protected]/rest/v3.1/SoftLayer_Search/advancedSearch?objectMask=mask[resource(SoftLayer_Network_Vlan_Firewall)[billingItem]] 
    
    Method: Post 
    
    { 
        "parameters":[ 
         "_objectType:SoftLayer_Network_Vlan_Firewall _sort:[fullyQualifiedDomainName:asc]" 
        ] 
    } 
    
  • 一旦你得到了billingItem從防火牆專用的,你可以用下面的PHP腳本刪除:

    <?php 
    /** 
    * This script cancels the resource or service for a billing item 
    * 
    * Important manual pages: 
    * @see http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService 
    * 
    * @license <http://sldn.softlayer.com/wiki/index.php/license> 
    * @author SoftLayer Technologies, Inc. <[email protected]> 
    */ 
    require_once '\vendor\autoload.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"; 
    $endPoint = "http://stable.application.qadal0501.softlayer.local/v3.1/sldn/soap/"; 
    /** 
    * Declare the billing item identifier from Network Protection Firewall Dedicated 
    * @var int 
    */ 
    $billingItemId = 26382998; 
    
    // Create a SoftLayer API client object for "SoftLayer_Billing_Item" service 
    $client = \SoftLayer\SoapClient::getClient('SoftLayer_Billing_Item', null, $username, $apiKey, $endPoint); 
    
    // Set init parameters 
    $client -> setInitParameter($billingItemId); 
    
    try { 
        $result = $client -> cancelService(); 
        print_r($result); 
    } catch(Exception $e) { 
        echo "Unable to Cancel Service: " . $e -> getMessage(); 
    } 
    
    ?> 
    

    對於監控包對象,下面的腳本將有助於讓監控包虛擬客戶及其結算項目:

    <?php 
    /** 
    * This script retrieves a billing item of "monitoring_package" category code from a virtual guest 
    * 
    * Important manual pages: 
    * @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Billing_Item 
    * @see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getBillingItem 
    * 
    * @license <http://sldn.softlayer.com/wiki/index.php/license> 
    * @author SoftLayer Technologies, Inc. <[email protected]> 
    */ 
    require_once '\vendor\autoload.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 the server identifier 
    $serverId = 14463961; 
    
    // Create a SoftLayer API client object for "SoftLayer_Account" service 
    $guestService = \SoftLayer\SoapClient::getClient('SoftLayer_Virtual_Guest', $serverId, $username, $apiKey); 
    
    // Declare an object mask to relational properties 
    $objectMask = "mask[activeAssociatedChildren]"; 
    $guestService -> setObjectMask($objectMask); 
    
    try { 
        $billingItems = $guestService -> getBillingItem(); 
        foreach($billingItems -> activeAssociatedChildren as $billingItem) 
        { 
         if($billingItem -> categoryCode == "monitoring_package") 
         { 
          print_r($billingItem); 
         } 
        } 
    } catch(Exception $e) { 
        echo "Unable to get billing item: " . $e -> getMessage(); 
    } 
    
    ?> 
    

    一旦從監控得到billingItem ing包,你可以取消這個SoftLayer_Billing_Item :: cancelService

    腓SoftLayer的客戶: https://github.com/softlayer/softlayer-api-php-client

    +0

    謝謝Ruber。另一個問題,我使用複雜類型SoftLayer_Container_Product_Order_Network_Protection_Firewall在設備(虛擬來賓或裸機服務器)上訂購「100Mbps硬件防火牆」,而不是在vlan上。如何獲得設備上的防火牆列表,我可以使用相同的「Network_Vlan_Firewall」對象嗎? – mnnmountain

    +0

    你好,請登錄: 請嘗試以下方法: ** 1。對於虛擬來賓:** [SoftLayer_Virtual_Guest :: getFirewallServiceComponent](http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getFirewallServiceComponent) ** 2。對於裸機:** [SoftLayer_Hardware :: getFirewallServiceComponent](http://sldn.softlayer.com/reference/services/SoftLayer_Hardware/getFirewallServiceComponent) –

    相關問題