mirror of
https://github.com/LamGC/Oracle-Sentry.git
synced 2025-04-29 14:17:34 +00:00
feat: 支持获取帐号区域订阅信息和直接获取主区域订阅信息.
增加 regions 和 mainRegion 方法, 可快速获取帐号所订阅的所有区域, 以及主区域的信息.
This commit is contained in:
parent
b8b2268d2e
commit
a128748b4f
@ -1,9 +1,13 @@
|
||||
package net.lamgc.oracle.sentry.oci.account;
|
||||
|
||||
import com.oracle.bmc.auth.AuthenticationDetailsProvider;
|
||||
import com.oracle.bmc.identity.model.RegionSubscription;
|
||||
import com.oracle.bmc.identity.model.User;
|
||||
import com.oracle.bmc.identity.requests.GetUserRequest;
|
||||
import com.oracle.bmc.identity.requests.ListRegionSubscriptionsRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -57,6 +61,30 @@ public final class OracleAccount {
|
||||
return this.user.getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户订阅的所有地区.
|
||||
* @return 返回已订阅地区列表.
|
||||
*/
|
||||
public List<RegionSubscription> regions() {
|
||||
return this.clients.identity().listRegionSubscriptions(ListRegionSubscriptionsRequest.builder()
|
||||
.tenancyId(this.id())
|
||||
.build()).getItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取帐号主区域.
|
||||
* @return 返回帐号主区域.
|
||||
* @throws NoSuchElementException 当主区域搜索失败时抛出.
|
||||
*/
|
||||
public RegionSubscription mainRegion() {
|
||||
for (RegionSubscription subscription : regions()) {
|
||||
if (subscription.getIsHomeRegion()) {
|
||||
return subscription;
|
||||
}
|
||||
}
|
||||
throw new NoSuchElementException("Primary region not found.");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该账户所属的 API 客户端集合.
|
||||
* @return 返回该账户所属的甲骨文 API 客户端集.
|
||||
|
Loading…
Reference in New Issue
Block a user