EIPGroup实例
更新时间:2020-07-21
EIPGroup实例是百度智能云上的创建一个EIP共享带宽。 创建EIP共享带宽需要实名认证,若未通过实名认证可以前往百度开放云官网控制台中的安全认证下的实名认证中进行认证,目前仅支持预付费EIP共享带宽的创建
创建实例
Billing类可以参照Billing
使用以下代码可以创建EIPGroup实例
public void createEipGroup(EipGroupClient eipGroupClient, String name, Integer eipCount, Integer bandwidthInMbps, Billing billing) {
CreateEipGroupRequest createEipGroupRequest = new CreateEipGroupRequest();
// 设置创建EipGroup的名称
createEipGroupRequest.setName(name);
// 设置EIP共享带宽中EIP的个数
createEipGroupRequest.setEipCount(eipCount);
// 设置公网带宽,单位为Mbps
createEipGroupRequest.setBandwidthInMbps(bandwidthInMbps);
// 设置订单信息
createEipGroupRequest.setBilling(billing);
IdResponse idResponse = eipGroupClient.createEipGroup(createEipGroupRequest);
System.out.println(idResponse.getId());
}
EIP共享带宽的带宽扩容
指定EIP共享带宽的带宽扩容
public void resizeBandwidth(EipGroupClient eipGroupClient, Integer bandwidthInMbps) {
BandwidthInMbpsRequest bandwidthInMbpsRequest = new BandwidthInMbpsRequest();
// 设置带宽大小
bandwidthInMbpsRequest.setBandwidthInMbps(bandwidthInMbps);
// 执行扩缩容
eipGroupClient.resizeBandwidth(bandwidthInMbpsRequest);
}
EIP共享带宽EIP数量扩容
用于指定EIP共享带宽EIP数量扩容
public void addCount(EipGroupClient eipGroupClient, Integer eipAddCount) {
EipCountRequest eipCountRequest = new EipCountRequest();
// 设置EIP数量
eipCountRequest.setEipAddCount(eipAddCount);
// 执行EIP数量扩容
eipGroupClient.addCount(eipCountRequest);
}
EIP共享带宽更新
EIP共享带宽更新
public void update(EipGroupClient eipGroupClient, String name) {
EipNameRequest eipNameRequest = new EipNameRequest();
// 设置新name
eipNameRequest.setName(name);
// 执行更新
eipGroupClient.update(eipNameRequest);
}
查询EIP共享带宽列表
- 可根据多重条件查询EIP共享带宽列表。
- 若不提供查询条件,则默认查询覆盖所有EIP。
- 返回结果为多重条件交集的查询结果,即提供多重条件的情况下,返回同时满足所有条件的EIP共享带宽。
- 以上查询结果支持marker分页,分页大小默认为1000,可通过maxKeys参数指定。
public void listEipInstance(EipGroupClient eipGroupClient, String marker, Integer maxKeys, String name) {
ListEipGroupRequest listEipGroupRequest = new ListEipGroupRequest();
// 设置分页标志
listEipGroupRequest.setMarker(marker);
// 设置分页返回数据大小
listEipGroupRequest.setMaxKeys(maxKeys);
// 设置name
listEipGroupRequest.setName(name);
// 执行查询列表操作
ListEipGroupResponse listEipGroupResponse = eipGroupClient.listEipGroup(listEipGroupRequest);
for (EipGroup eipGroup : listEipGroupResponse.getEipgroups()) {
System.out.println(eipGroup.getId());
}
}
查询EIP共享带宽详情
查询EIP共享带宽详情。
public void getEipGroup(EipGroupClient eipGroupClient, Integer id) {
GetEipGroupRequest getEipGroupRequest = new GetEipGroupRequest();
// 查询EIP共享带宽详情。
GetEipGroupResponse getEipGroupResponse = eipGroupClient.getEipGroup(getEipGroupRequest.setId(id));
System.out.println(getEipGroupResponse.getBandwidthInMbps());
List<Eip> eips = getEipGroupResponse.getEips();
}
EIP共享带宽续费
- 针对指定EIP共享带宽的续费操作,延长过期时长
- EIP共享带宽扩缩容期间不能进行续费操作。
public void purchaseReservedEipGroup(EipGroupClient eipGroupClient, Integer id, Billing billing) {
PurchaseReservedEipGroupRequest purchaseReservedEipGroupRequest = new PurchaseReservedEipGroupRequest();
// 设置id
purchaseReservedEipGroupRequest.setId(id);
// 设置billing信息
purchaseReservedEipGroupRequest.setBilling(billing);
// 执行续费
eipGroupClient.purchaseReservedEipGroup(purchaseReservedEipGroupRequest);
}