全部产品
云市场

获取用户配额

更新时间:2018-11-19 20:59:40

接口

getQuotas

参数

无。

返回值

成功后返回一个 GetQuotasResponse 实例, 可以通过这个实例的 getQuotas 方法,拿到 Quotas 对象。如果失败,抛出异常:ClientExceptionQuotas 属性如下:

属性 类型 说明
availableClusterResourceType List<String> 可用的资源类型类型
availableClusterInstanceType List<String> 可用的实例类型
availableSpotInstanceType List<String> 可用的竞价实例类型
availableClusterInstanceSystemDiskType List<String> 可用的系统盘类型
availableClusterInstanceDataDiskType List<String> 可用的数据盘类型

例子

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 GetQuotas {
  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. GetQuotasResponse response = client.getQuotas();
  14. Quotas quotas = response.getQuotas();
  15. System.out.println("availableResourceType: {");
  16. List<String> availableResourceType = quotas.getAvailableClusterResourceType();
  17. for (int i = 0; i < availableResourceType.size(); i++){
  18. System.out.println("\tavailableResourceType: " + availableResourceType.get(i));
  19. }
  20. System.out.println("}");
  21. System.out.println("availableInstanceType: {");
  22. List<String> availableInstanceType = quotas.getAvailableClusterInstanceType();
  23. for (int i = 0; i < availableInstanceType.size(); i++){
  24. System.out.println("\tavailableInstanceType: " + availableInstanceType.get(i));
  25. }
  26. System.out.println("}");
  27. System.out.println("availableInstanceDataDiskType: {");
  28. List<String> availableInstanceDataDiskType = quotas.getAvailableClusterInstanceDataDiskType();
  29. for (int i = 0; i < availableInstanceDataDiskType.size(); i++){
  30. System.out.println("\tavailableInstanceDataDiskType: " + availableInstanceDataDiskType.get(i));
  31. }
  32. System.out.println("}");
  33. System.out.println("availableSpotInstanceType: {");
  34. List<String> availableSpotInstanceType = quotas.getAvailableSpotInstanceType();
  35. for (int i = 0; i < availableSpotInstanceType.size(); i++){
  36. System.out.println("\tavailableSpotInstanceType: " + availableSpotInstanceType.get(i));
  37. }
  38. System.out.println("}");
  39. System.out.println("availableInstanceSystemDiskType: {");
  40. List<String> availableInstanceSystemDiskType = quotas.getAvailableClusterInstanceSystemDiskType();
  41. for (int i = 0; i < availableInstanceSystemDiskType.size(); i++){
  42. System.out.println("\tavailableSpotInstanceType: " + availableInstanceSystemDiskType.get(i));
  43. }
  44. System.out.println("}");
  45. System.out.println("RequestId: " + response.getRequestId());
  46. System.out.println("StatusCode: " + response.getStatusCode());
  47. } catch (ClientException e) {
  48. e.printStackTrace();
  49. //创建失败
  50. }
  51. }
  52. }

执行结果:

  1. {
  2. availableResourceType: {
  3. availableResourceType: OnDemand,
  4. availableResourceType: PrePaid,
  5. availableResourceType: Spot,
  6. },
  7. availableInstanceType: {
  8. availableInstanceType: bcs.a2.3xlarge,
  9. availableInstanceType: bcs.a2.4xlarge,
  10. availableInstanceType: bcs.a2.large,
  11. availableInstanceType: bcs.a2.xlarge,
  12. },
  13. availableInstanceDataDiskType: {
  14. availableInstanceDataDiskType: cloud,
  15. availableInstanceDataDiskType: cloud_efficiency,
  16. availableInstanceDataDiskType: cloud_ssd,
  17. availableInstanceDataDiskType: ephemeral,
  18. availableInstanceDataDiskType: ephemeral_ssd
  19. },
  20. availableSpotInstanceType: {
  21. availableSpotInstanceType: ecs.c1.large,
  22. availableSpotInstanceType: ecs.c4.2xlarge,
  23. availableSpotInstanceType: ecs.c4.4xlarge,
  24. },
  25. availableInstanceSystemDiskType: {
  26. availableSpotInstanceType: cloud,
  27. availableSpotInstanceType: cloud_efficiency,
  28. availableSpotInstanceType: cloud_ssd,
  29. availableSpotInstanceType: ephemeral,
  30. availableSpotInstanceType: ephemeral_ssd
  31. },
  32. RequestId: null
  33. StatusCode: 200
  34. }