接口
getQuotas
参数
无。
返回值
成功后返回一个 GetQuotasResponse
实例, 可以通过这个实例的 getQuotas
方法,拿到 Quotas 对象。如果失败,抛出异常:ClientException
。Quotas
属性如下:
属性 | 类型 | 说明 |
availableClusterResourceType | List<String> | 可用的资源类型 |
availableClusterInstanceType | List<String> | 可用的实例类型 |
availableSpotInstanceType | List<String> | 可用的竞价实例类型 |
availableClusterInstanceSystemDiskType | List<String> | 可用的系统盘类型 |
availableClusterInstanceDataDiskType | List<String> | 可用的数据盘类型 |
例子
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 GetQuotas {
static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
static String REGION_ID = "cn-xxx"; //这里填写 region
public static void main(String[] args) {
BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
try {
GetQuotasResponse response = client.getQuotas();
Quotas quotas = response.getQuotas();
System.out.println("availableResourceType: {");
List<String> availableResourceType = quotas.getAvailableClusterResourceType();
for (int i = 0; i < availableResourceType.size(); i++){
System.out.println("\tavailableResourceType: " + availableResourceType.get(i));
}
System.out.println("}");
System.out.println("availableInstanceType: {");
List<String> availableInstanceType = quotas.getAvailableClusterInstanceType();
for (int i = 0; i < availableInstanceType.size(); i++){
System.out.println("\tavailableInstanceType: " + availableInstanceType.get(i));
}
System.out.println("}");
System.out.println("availableInstanceDataDiskType: {");
List<String> availableInstanceDataDiskType = quotas.getAvailableClusterInstanceDataDiskType();
for (int i = 0; i < availableInstanceDataDiskType.size(); i++){
System.out.println("\tavailableInstanceDataDiskType: " + availableInstanceDataDiskType.get(i));
}
System.out.println("}");
System.out.println("availableSpotInstanceType: {");
List<String> availableSpotInstanceType = quotas.getAvailableSpotInstanceType();
for (int i = 0; i < availableSpotInstanceType.size(); i++){
System.out.println("\tavailableSpotInstanceType: " + availableSpotInstanceType.get(i));
}
System.out.println("}");
System.out.println("availableInstanceSystemDiskType: {");
List<String> availableInstanceSystemDiskType = quotas.getAvailableClusterInstanceSystemDiskType();
for (int i = 0; i < availableInstanceSystemDiskType.size(); i++){
System.out.println("\tavailableSpotInstanceType: " + availableInstanceSystemDiskType.get(i));
}
System.out.println("}");
System.out.println("RequestId: " + response.getRequestId());
System.out.println("StatusCode: " + response.getStatusCode());
} catch (ClientException e) {
e.printStackTrace();
//创建失败
}
}
}
执行结果:
{
availableResourceType: {
availableResourceType: OnDemand,
availableResourceType: PrePaid,
availableResourceType: Spot,
},
availableInstanceType: {
availableInstanceType: bcs.a2.3xlarge,
availableInstanceType: bcs.a2.4xlarge,
availableInstanceType: bcs.a2.large,
availableInstanceType: bcs.a2.xlarge,
},
availableInstanceDataDiskType: {
availableInstanceDataDiskType: cloud,
availableInstanceDataDiskType: cloud_efficiency,
availableInstanceDataDiskType: cloud_ssd,
availableInstanceDataDiskType: ephemeral,
availableInstanceDataDiskType: ephemeral_ssd
},
availableSpotInstanceType: {
availableSpotInstanceType: ecs.c1.large,
availableSpotInstanceType: ecs.c4.2xlarge,
availableSpotInstanceType: ecs.c4.4xlarge,
},
availableInstanceSystemDiskType: {
availableSpotInstanceType: cloud,
availableSpotInstanceType: cloud_efficiency,
availableSpotInstanceType: cloud_ssd,
availableSpotInstanceType: ephemeral,
availableSpotInstanceType: ephemeral_ssd
},
RequestId: null
StatusCode: 200
}
文档内容是否对您有帮助?