获取镜像列表
更新时间:
接口
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 源码:
import com.aliyuncs.batchcompute.main.v20151111.*;import com.aliyuncs.batchcompute.model.v20151111.*;import com.aliyuncs.batchcompute.pojo.v20151111.*;import com.aliyuncs.exceptions.ClientException;import java.util.List;public class ListImages {static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyIdstatic String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecretstatic String REGION_ID = "cn-xxx"; //这里填写 regionpublic static void main(String[] args) {BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);try{ListImagesResponse response = client.listImages();//成功List<Image> list = response.getItems();for (int i = 0; i < list.size(); i++){Image image = list.get(i);String Id = image.getId();String name = image.getName();String plat = image.getPlatform();System.out.println("{");System.out.println("\tId: " + Id);System.out.println("\tName: " + name);System.out.println("\tPlat: " + plat);System.out.println("},");}}catch(ClientException e){e.printStackTrace();//失败}}}
执行结果
{{Id: img-6ki7te6grlhbv42kn8a002Name: miliPlat: Windows},{Id: img-6ki7te6grlhbv42kn8a003Name: bc-stg-windows-1Plat: Windows},{Id: img-6kie8e832lnov8gg50k00bName: JavaSdkImagePlat: Linux}}
该文章对您有帮助吗?