In adding public image options for Auto Scale, I used API below, but it returns no Public image template. Can you check I've used the correct API ? Private Image works fine with privateBlockDeviceTemplateGroups().
Account.Service service = Account.service(client);
service.withMask().blockDeviceTemplateGroups();
Account account = service.getObject();
for (com.softlayer.api.service.virtual.guest.block.device.template.Group group : account.getBlockDeviceTemplateGroups()){
System.out.println("group name : " + group.getName() ); }
In order to retrieve the public image templates you could use the next method:
SoftLayer_Virtual_Guest_Block_Device_Template_Group::getPublicImages
You can use this method using a REST request in this way:
https://$username:$apiKey@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getPublicImages.json
And, this would be using java client.
/**
* This method gets all public image templates that the user is allowed to see.
*
* Important manual pages:
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getPublicImages
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device_Template_Group
*
* @license <http://sldn.softlayer.com/wiki/index.php/License>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
*/
package SoftLayer_Java_Scripts.Examples;
import com.softlayer.api.*;
import com.softlayer.api.service.virtual.guest.block.device.template.Group;
import java.util.List;
import com.google.gson.Gson;
public class GetPublicImages
{
public static void main( String[] args )
{
String user = "set me";
String apiKey = "set me";
ApiClient client = new RestApiClient().withCredentials(user, apiKey);
Group.Service service = Group.service(client);
try
{
List<Group> publicImages = service.getPublicImages();
Gson gson = new Gson();
for(Group image : publicImages) {
System.out.println(gson.toJson(image));
}
}
catch(Exception e)
{
System.out.println("Script failed, review the next message for further details: " + e);
}
}
}
The following links provide further information: http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest_Block_Device_Template_Group/getPublicImages
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest_Block_Device_Template_Group