配额查询
初始化客户端
参数获取可参照准备工作中token认证方式。
Copied!
String user = "replace-with-your-username";
String password = "replace-with-your-password";
String projectId = "replace-with-your-projectId";
String userDomainId = "replace-with-your-domainId";
String authUrl = "https://iam.example.com/v3"; // endpointUrl
OSClientV3 osclient = OSFactory.builderV3().endpoint(authUrl)
.credentials(user, password, Identifier.byId(userDomainId))
.scopeToProject(Identifier.byId(projectId)).authenticate();
查询配额
查询指定租户下的弹性伸缩组、伸缩配置、伸缩带宽策略、伸缩策略和伸缩实例的配额总数及已使用配额数
Copied!
// query the total quotas and used quotas of AS groups, configurations, policies, and instances for a specified tenant.
public void queryQuota() {
List< ? extends Quota> list0 = osclient.autoScaling().quotas().list();
if (null != list0) {
System.out.println("get quotas success:" + list0.toString());
} else {
System.out.println("get quotas failed");
}
}
响应样例
Copied!
{
"quotas": {
"resources": [
{
"type": "scaling_Group",
"used": 2,
"quota": 25,
"max": 50
},
{
"type": "scaling_Config",
"used": 3,
"quota": 100,
"max": 200
},
{
"type": "scaling_Policy",
"used": -1,
"quota": 50,
"max": 50
},
{
"type": "scaling_Instance",
"used": -1,
"quota": 200,
"max": 1000
},
{
"type": "bandwidth_scaling_policy",
"used": 1,
"quota": 10,
"max": 100
}
]
}
}
说明
:更多信息请参考API Explorer。
查询弹性伸缩组下的伸缩策略和伸缩实例的配额
根据伸缩组ID查询指定弹性伸缩组下的伸缩策略和伸缩实例的配额总数及已使用配额数
Copied!
// query the total quotas and used quotas of AS policies and instances of a specified AS group by groupId.
public void queryQuota(String groupId) {
List< ? extends Quota> list = osclient.autoScaling().quotas().list(groupId);
if (null != list) {
System.out.println("get quotas success:" + list.toString());
} else {
System.out.println("get quotas failed");
}
}
响应样例
Copied!
{
"quotas": {
"resources": [
{
"type": "scaling_Policy",
"used": 2,
"quota": 50,
"max": 50
},
{
"type": "scaling_Instance",
"used": 0,
"quota": 200,
"max": 1000
}
]
}
}
说明
:具体参数请参考API Explorer。
版本说明
本示例基于华为云SDK V1.0版本开发,高版本示例正在开发中。
功能介绍
为防止资源滥用,平台限定了各服务资源的配额,对用户的资源数量和容量做了限制。如您最多可以创建多少个伸缩组。通过查询配额,您可以了解具体的资源数量和容量。
准备工作
配额查询
初始化客户端
参数获取可参照准备工作中token认证方式。
查询配额
查询指定租户下的弹性伸缩组、伸缩配置、伸缩带宽策略、伸缩策略和伸缩实例的配额总数及已使用配额数
响应样例
说明
:更多信息请参考API Explorer。查询弹性伸缩组下的伸缩策略和伸缩实例的配额
根据伸缩组ID查询指定弹性伸缩组下的伸缩策略和伸缩实例的配额总数及已使用配额数
响应样例
说明
:具体参数请参考API Explorer。参考
更多信息请参考弹性伸缩 AS。