获取镜像信息
更新时间:
接口
getImage
参数
| 参数 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
| imageId | String | 是 | 镜像ID |
返回值
成功后返回一个 GetImageResponse 实例,可以通过这个实例的 getImage() 方法拿到 Image 对象。如果失败,抛出异常: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;public class GetImage {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{GetImageResponse response = client.getImage("img-6kie8e832lnov8gg50k00b");//成功Image image = response.getImage();System.out.println("GotImageName: " + image.getName());System.out.println("GotImageId: " + image.getId());System.out.println("GotImagePlatform: " + image.getPlatform());}catch(ClientException e){e.printStackTrace();//失败}}}
执行结果:
{GotImageName: JavaSdkImageGotImageId: img-6kie8e832lnov8gg50k00bGotImagePlatform: Linux}
该文章对您有帮助吗?