获取镜像信息

接口

getImage

参数

参数 类型 是否必需 说明
imageId String 镜像ID

返回值

成功后返回一个 GetImageResponse 实例,可以通过这个实例的 getImage() 方法拿到 Image 对象。如果失败,抛出异常: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. public class GetImage {
  6. static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
  7. static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
  8. static String REGION_ID = "cn-xxx"; //这里填写 region
  9. public static void main(String[] args) {
  10. BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
  11. try{
  12. GetImageResponse response = client.getImage("img-6kie8e832lnov8gg50k00b");
  13. //成功
  14. Image image = response.getImage();
  15. System.out.println("GotImageName: " + image.getName());
  16. System.out.println("GotImageId: " + image.getId());
  17. System.out.println("GotImagePlatform: " + image.getPlatform());
  18. }catch(ClientException e){
  19. e.printStackTrace();
  20. //失败
  21. }
  22. }
  23. }

执行结果:

  1. {
  2. GotImageName: JavaSdkImage
  3. GotImageId: img-6kie8e832lnov8gg50k00b
  4. GotImagePlatform: Linux
  5. }