0

对于 N/W 部分,当我们尝试“添加”新带宽池时,安装费用为 25 美元。但我没有找到 API 来调用该费用。甚至没有需要 25 美元安装费的 ID。

我必须使用什么来调整安装费?

请我想知道如何在 java 中编写“添加带宽池”。

谢谢。

4

1 回答 1

0

查看以下 Java 脚本:

1.要获得带宽池的添加 Vdr 成员/安装费用:

package SoftLayer.api_java;
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.account.Attribute;
import com.softlayer.api.service.Account;

/** 
 * This script retrieves a Vdr Member Price
 * 
 * Important pages:
 * http://sldn.softlayer.com/reference/services/SoftLayer_Account/getAttributeByType
 * http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account_Attribute
 */
public class GetVdrMemberPrice {

    public GetVdrMemberPrice() {
        // Declare your SoftLayer username and apiKey
        String user = "set me";
        String apikey = "set me";
        // Declare API Client
        ApiClient client = new RestApiClient().withCredentials(user, apikey);
        // Declare the type of account attribute you wish to retrieve
        String attributeType = "VDR_MEMBER_PRICE";
        try {
            Attribute result = Account.service(client).getAttributeByType(attributeType);
            System.out.println("Value: " + result.getValue());
        } catch (Exception e) {
            System.out.println("Error: " + e);
        }
    }

    public static void main(String[] args) {
        new GetVdrMemberPrice();
    }
}

2.添加带宽池

package SoftLayer.api_java;
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.network.bandwidth.version1.Allotment;

/**
 * Add a Bandwidth Pool
 * 
 * Important pages:
 * http://sldn.softlayer.com/reference/services/SoftLayer_Network_Bandwidth_Version1_Allotment
 * http://sldn.softlayer.com/reference/services/SoftLayer_Network_Bandwidth_Version1_Allotment/createObject
 */
public class AddingBandwidthPool {

    public AddingBandwidthPool() {
        // Declare your SoftLayer username and apiKey
        String user = "set me";
        String apikey = "set me";
        // Define your account Id (set me)
        Long accountId = new Long(123456);
        // Define an identifier marking this allotment as a virtual private rack (1) or a bandwidth pooling(2).
        Long bandwidthAllotmentTypeId = new Long(2);
        // Define the region. You can get available regions using SoftLayer_Location_Group::getAllObjects method
        // http://sldn.softlayer.com/reference/services/SoftLayer_Location_Group/getAllObjects
        Long locationGroupId = new Long(1); 
        // Define text a virtual rack's name.
        String name = "set me";
        // Declare API Client
        ApiClient client = new RestApiClient().withCredentials(user, apikey);
        // Build a SoftLayer_Network_Bandwidth_Version1_Allotment object that you wish to create
        Allotment templateObject = new Allotment();
        templateObject.setAccountId(accountId);
        templateObject.setBandwidthAllotmentTypeId(bandwidthAllotmentTypeId);
        templateObject.setLocationGroupId(locationGroupId);;
        templateObject.setName(name);

        try {
            boolean result = Allotment.service(client).createObject(templateObject);
            System.out.println(result);
        } catch (Exception e) {
            System.out.println("Error: " + e);
        }
    }

    public static void main(String[] args) {
        new AddingBandwidthPool();
    }
}

注意: SoftLayer_Network_Bandwidth_Version1_Allotment::createObject 的返回值存在问题,因为根据wsdl,它返回一个布尔值,但它返回一个 SoftLayer_Network_Bandwidth_Version1_Allotment 对象。但是,带宽池添加成功。

参考: GetVdrMemberPrice CreateBandwidthPool

于 2016-02-01T20:07:23.143 回答