文档

获取镜像列表

更新时间:

接口

listImages

参数

参数 类型 是否必选 说明
type String 重载方法中有这个参数, type= ListImagesRequest.SYSTEM 则返回系统提供的镜像列表。
marker String 本页起始资源标识符。默认为空字符串。
maxItemCount int 返回条数,最大取值200,默认200

返回值

成功后返回一个 ListImagesResponse 实例, 可以通过这个实例的 getItems 方法,拿到 List<Image> 对象;请参阅 Image 类的描述,了解 Image 对象的属性。

属性 类型 说明
id String 镜像ID
name String 镜像名称
ownerId long 所有者ID
description String 简短描述
type String 类型,”System” 或则 “Self”
ecsImageId String ECS镜像ID
creationTime Date 创建时间
platform String 操作系统, Image.LINUX 或者 Image.WINDOWS

如果失败,抛出异常:ClientException

例子

Java 源码:

  1. import com.aliyuncs.batchcompute.main.v20151111.*;
  2. import com.aliyuncs.batchcompute.model.v20151111.*;
  3. import com.aliyuncs.batchcompute.pojo.v20151111.*;
  4. import com.aliyuncs.exceptions.ClientException;
  5. import java.util.List;
  6. public class ListImages {
  7. static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
  8. static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
  9. static String REGION_ID = "cn-xxx"; //这里填写 region
  10. public static void main(String[] args) {
  11. BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
  12. try{
  13. ListImagesResponse response = client.listImages();
  14. //成功
  15. List<Image> list = response.getItems();
  16. for (int i = 0; i < list.size(); i++){
  17. Image image = list.get(i);
  18. String Id = image.getId();
  19. String name = image.getName();
  20. String plat = image.getPlatform();
  21. System.out.println("{");
  22. System.out.println("\tId: " + Id);
  23. System.out.println("\tName: " + name);
  24. System.out.println("\tPlat: " + plat);
  25. System.out.println("},");
  26. }
  27. }catch(ClientException e){
  28. e.printStackTrace();
  29. //失败
  30. }
  31. }
  32. }

执行结果

  1. {
  2. {
  3. Id: img-6ki7te6grlhbv42kn8a002
  4. Name: mili
  5. Plat: Windows
  6. },
  7. {
  8. Id: img-6ki7te6grlhbv42kn8a003
  9. Name: bc-stg-windows-1
  10. Plat: Windows
  11. },
  12. {
  13. Id: img-6kie8e832lnov8gg50k00b
  14. Name: JavaSdkImage
  15. Plat: Linux
  16. }
  17. }
  • 本页导读 (0)
文档反馈