November 23, 2017
package DedicatedHost;

import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.Location;
import com.softlayer.api.service.virtual.DedicatedHost;

import java.util.List;

 * Get all available routers that can be used to order a Dedicated Host.
 * This example shows how to build an skeleton of get a list of SoftLayer_Virtual_DedicatedHost
 * and pass it to SoftLayer_Virtual_DedicatedHost::getAvailableRouters method to get a list of
 * available backend routers to order Dedicated Hosts.
 * Important manual pages:
 * @license <>
 * @author SoftLayer Technologies, Inc. <>
 * @version 1.0
public class GetAvailableRouters {

    public static void main(String args[]){
        // Declare username and api key
        String username = "set me";
        String apiKey = "set me";

        // Use the method SoftLayer_Location::getDatacenters in order to get location ids.
        Location location = new Location();

        // Skeleton of the dedicated host to specify the data center and configuration sizes
        // 56 Cores X 242 RAM X 1.2 TB
        DedicatedHost template = new DedicatedHost();

        // Get Api Client and service
        ApiClient client = new RestApiClient().withCredentials(username, apiKey);
        DedicatedHost.Service service = DedicatedHost.service(client);

            // Get list of available routers by calling to getAvailableRouters method.
            List<Hardware> routers = service.getAvailableRouters(template);

            // Print response in JSON format
            Gson gson = new GsonBuilder().setPrettyPrinting().create();

        } catch (Exception e)
            System.out.println("Unable to get the backend routers: " + e);


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue