/** * 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."); } }
/** * Collect data for Glacier. * * @param stats * current statistics object. * @param account * currently used credentials object. * @param region * currently used aws region. */ public static void scanGlacier(AwsStats stats, AwsAccount account, Regions region) { LOG.debug("Scan for Glacier in region " + region.getName() + " in account " + account.getAccountId()); try { AmazonGlacier glacier = new AmazonGlacierClient(account.getCredentials()); glacier.setRegion(Region.getRegion(region)); // DescribeVaultRequest dvr = new DescribeVaultRequest(); ListVaultsRequest lvr = new ListVaultsRequest(); int totalItems = 0; for (DescribeVaultOutput dvo : glacier.listVaults(lvr).getVaultList()) { AwsResource res = new AwsResource(dvo.getVaultName(), account.getAccountId(), AwsResourceType.Glacier, region); res.addInfo("NumberOfArchives", dvo.getNumberOfArchives()); res.addInfo("VaultARN", dvo.getVaultARN()); res.addInfo(AwsTag.SizeInBytes, dvo.getSizeInBytes()); stats.add(res); totalItems++; } LOG.info(totalItems + " Glacier in region " + region.getName() + " in account " + account.getAccountId()); } catch (AmazonServiceException ase) { if (ase.getErrorCode().contains("AccessDenied")) { LOG.info("Access denied for Glacier in region " + region.getName() + " in account " + account.getAccountId()); } else { LOG.error("Exception of Glacier: " + ase.getMessage()); } } }
@Override public VaultCollection getVaults(ListVaultsRequest request) { ResourceCollectionImpl result = resource.getCollection("Vaults", request); if (result == null) return null; return new VaultCollectionImpl(result); }
@Override public VaultCollection getVaults(ListVaultsRequest request) { ResourceCollectionImpl result = service.getCollection("Vaults", request); if (result == null) return null; return new VaultCollectionImpl(result); }
@Override public VaultCollection getVaults() { return getVaults((ListVaultsRequest)null); }
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)); } }
/** * Retrieves the Vaults collection referenced by this resource. */ VaultCollection getVaults(ListVaultsRequest request);