/** * Returns a list of <b>DescribeVaultOutput</b> for the AWS account. * This always make a call to AWS. * * @return list of <code>DescribeVaultOutput> * @throws Exception */ public List<DescribeVaultOutput> list() throws Exception{ String marker = null; ListVaultsResult listVaultsResult = null; do { LGR.fine("getting vaults up to 100"); ListVaultsRequest listVaultsRequest = new ListVaultsRequest() .withLimit("100").withMarker(marker); listVaultsResult = GlacierFrame.getClient().listVaults(listVaultsRequest); LGR.fine("got list"); List<DescribeVaultOutput> vaultList = listVaultsResult.getVaultList(); marker = listVaultsResult.getMarker(); if (allVaults == null) { allVaults = vaultList; continue; } allVaults.addAll(vaultList); } while (marker !=null); return allVaults; }
public static void main(String[] args) { final AmazonGlacier glacier = AmazonGlacierClientBuilder.defaultClient(); ListVaultsRequest request = new ListVaultsRequest(); boolean list_complete = false; int total_vaults = 0; System.out.println("Your Amazon Glacier vaults:"); while (!list_complete) { ListVaultsResult result = glacier.listVaults(request); List<DescribeVaultOutput> vault_list = result.getVaultList(); for (DescribeVaultOutput v: vault_list) { total_vaults += 1; System.out.println("* " + v.getVaultName()); } // check for further results. String marker = result.getMarker(); if (marker != null) { request.setMarker(marker); } else { list_complete = true; } } if (total_vaults == 0) { System.out.println(" no vaults found."); } }
public void inspectVaults(AWSCredentials creds, String endPointUrl){ AmazonGlacierClient client = new AmazonGlacierClient(creds); client.setEndpoint(endPointUrl); ListVaultsResult listVaultsResult = client.listVaults(new ListVaultsRequest()); for(DescribeVaultOutput dvo : listVaultsResult.getVaultList() ){ System.out.println(describeVault(dvo)); } }