public String findDomainIdForAccount(String accountName) { Set<Account> accounts = client.getAccountClient().listAccounts(ListAccountsOptions.Builder.name(accountName)); Account account = Iterables.getOnlyElement(accounts, null); if (account == null) { throw new IllegalStateException("No account found in "+loc+"} with name "+accountName); } return account.getDomainId(); }