Example usage for com.amazonaws.services.glacier.model DescribeVaultOutput getLastInventoryDate

List of usage examples for com.amazonaws.services.glacier.model DescribeVaultOutput getLastInventoryDate

Introduction

In this page you can find the example usage for com.amazonaws.services.glacier.model DescribeVaultOutput getLastInventoryDate.

Prototype


public String getLastInventoryDate() 

Source Link

Document

The Universal Coordinated Time (UTC) date when Amazon S3 Glacier completed the last vault inventory.

Usage

From source file:englishcoffeedrinker.corpse.Vault.java

License:Open Source License

/**
 * Creates a Vault instance from the description returned as part
 * of a ListVault command. Note that this won't contain a breakdown
 * of the archives contained with the vault as this information
 * isn't returned as part of a vault listing; you need to request
 * a vault inventory if you need to find out the details of each
 * archive in the vault.//from   ww w  .j  a va 2  s .co m
 * @param vault
 */
public Vault(DescribeVaultOutput vault) {
    this.arn = vault.getVaultARN();
    this.name = vault.getVaultName();
    this.creationDate = vault.getCreationDate();
    this.inventoryDate = vault.getLastInventoryDate();
    this.numArchives = vault.getNumberOfArchives();
    this.sizeInBytes = vault.getSizeInBytes();

    //a simple vault description doesn't contain the list
    //of archives, you have to request a vault inventory
    //to get the full list, which is why you should be
    //maintaining a local index of your glacier vaults
    archives = new ArrayList<Archive>();
}

From source file:nl.nekoconeko.glaciercmd.Entry.java

License:Open Source License

public static void main(String[] args) {
    CommandLine cli = Configuration.parseCli(ModeType.ROOT, args);

    if (cli.hasOption("config")) {
        Configuration.loadFile(cli.getOptionValue("config"));
    }//from ww  w.ja v a 2  s  . c om

    Configuration.load(cli);

    if (Configuration.getMode() == ModeType.HELP) {
        if (Configuration.hasHelpType()) {
            ConfigModes.printConfigModeHelp(Configuration.getHelpType());
        } else {
            ConfigModes.printConfigModeHelp(ModeType.ROOT);
        }
        System.exit(0);
    }

    if (Configuration.getMode() == ModeType.VERSION) {
        Formatter.printHeader();
        System.exit(0);
    }

    if (!Configuration.hasKey() || !Configuration.hasSecret() || !Configuration.hasRegion()) {
        Formatter.printErrorLine("Make sure key, secret and region are set!");
        System.exit(-1);
    }

    GlacierClient gc = new GlacierClient(Configuration.getKey(), Configuration.getSecret());
    gc.setEndpoint(Configuration.getRegion().getEndpoint());

    if (Configuration.getMode() == ModeType.LIST) {
        Configuration.load(ModeType.LIST, args);
        if (!Configuration.hasListType()) {
            Formatter.printErrorLine("Make sure you specify a list type!");
            System.exit(-1);
        }

        switch (Configuration.getListType()) {
        case VAULT:
            List<DescribeVaultOutput> vaults = gc.getVaults();
            for (DescribeVaultOutput vault : vaults) {
                Formatter.printInfoLine(String.format("[%s] %d items, %d bytes, %s last checked",
                        vault.getVaultName(), vault.getNumberOfArchives(), vault.getSizeInBytes(),
                        vault.getLastInventoryDate()));
            }
            break;
        case ARCHIVE:
            if (!Configuration.hasVault()) {
                Formatter.printErrorLine("A vault has to be specified to list archives");
                System.exit(-1);
            }
            DescribeVaultResult vault = gc.describeVault(Configuration.getVault());
            Formatter.printInfoLine(
                    String.format("[%s] %d items, %d bytes, %s last checked", vault.getVaultName(),
                            vault.getNumberOfArchives(), vault.getSizeInBytes(), vault.getLastInventoryDate()));
            break;
        default:
            Formatter.printErrorLine("Invalid list type selected");
            System.exit(-1);
        }
    } else if (Configuration.getMode() == ModeType.INITIATEINVENTORY) {
        Configuration.load(ModeType.INITIATEINVENTORY, args);

        Formatter.printInfoLine("Requesting an inventory from AWS Glacier...");
        Formatter.printInfoLine(String.format("Job has been created with id: %s",
                gc.initiateRetrieveVaultInventory(Configuration.getVault())));
    } else if (Configuration.getMode() == ModeType.GETINVENTORY) {
        Configuration.load(ModeType.GETINVENTORY, args);

        Formatter.printInfoLine(
                String.format("Retrieving inventory with id %s from AWS Glacier...", Configuration.getJobId()));
        VaultInventory inv = null;
        try {
            inv = gc.retrieveVaultInventoryJob(Configuration.getVault(), Configuration.getJobId());
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        Formatter.printInfoLine(String.format("Vault ARN: %s", inv.VaultARN));
        Formatter.printInfoLine(String.format("Last Inventory Date: %s", inv.InventoryDate.toString()));
        Formatter.printInfoLine(String.format("Vault contains %d archives:", inv.ArchiveList.size()));
        for (Archive arch : inv.ArchiveList) {
            StringBuilder a = new StringBuilder();
            a.append(String.format("Archive ID: %s\n", arch.ArchiveId));
            a.append(String.format("Archive Description: %s\n", arch.ArchiveDescription));
            a.append(String.format("Archive Size: %d bytes\n", arch.Size));
            a.append(String.format("Creation Date: %s\n", arch.CreationDate.toString()));
            a.append(String.format("SHA256 Hash: %s\n", arch.SHA256TreeHash));
            Formatter.printBorderedInfo(a.toString());
        }

    } else if (Configuration.getMode() == ModeType.UPLOAD) {
        Configuration.load(ModeType.UPLOAD, args);

        Formatter.printInfoLine(String.format("Uploading '%s' to vault '%s'", Configuration.getInputFile(),
                Configuration.getVault()));
        UploadResult res = gc.uploadFile(Configuration.getVault(), Configuration.getInputFile(),
                Configuration.getDescription());
        Formatter.printInfoLine(String.format("Upload completed, archive has ID: %s", res.getArchiveId()));
    } else if (Configuration.getMode() == ModeType.DOWNLOAD) {
        Configuration.load(ModeType.DOWNLOAD, args);

        Formatter.printInfoLine(String.format("Download '%s' from vault '%s', saving as '%s'",
                Configuration.getArchive(), Configuration.getVault(), Configuration.getOutputFile()));
        Formatter.printInfoLine("Note that this will take several hours, please be patient...");
        gc.downloadFile(Configuration.getVault(), Configuration.getArchive(), Configuration.getOutputFile());
        Formatter.printInfoLine("Download completed");

    } else if (Configuration.getMode() == ModeType.INITIATEDOWNLOAD) {
        Configuration.load(ModeType.INITIATEDOWNLOAD, args);
        Formatter.printInfoLine(String.format("Requesting download of archive '%s' from vault '%s'...",
                Configuration.getArchive(), Configuration.getVault()));
        Formatter.printInfoLine(String.format("Job has been created with id: %s",
                gc.initiateDownload(Configuration.getVault(), Configuration.getArchive())));
    } else if (Configuration.getMode() == ModeType.GETDOWNLOAD) {
        Configuration.load(ModeType.GETDOWNLOAD, args);
        Formatter.printInfoLine(
                String.format("Retrieving download with '%s' from AWS Glacier, and saving it to '%s'...",
                        Configuration.getJobId(), Configuration.getOutputFile()));
        try {
            gc.retrieveDownloadJob(Configuration.getVault(), Configuration.getJobId(),
                    Configuration.getOutputFile());
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        Formatter.printInfoLine("Download completed");
    } else if (Configuration.getMode() == ModeType.DELETEARCHIVE) {
        Configuration.load(ModeType.DELETEARCHIVE, args);
        Formatter.printInfoLine(String.format("Deleting archive with id '%s' from vault '%s'",
                Configuration.getArchive(), Configuration.getVault()));
        gc.deleteArchive(Configuration.getVault(), Configuration.getArchive());
    } else {
        Formatter.printErrorLine("WHA-HUH!?");
        System.exit(-1);
    }
}

From source file:opendap.aws.glacier.NoaaResourceIngester.java

License:Open Source License

public String describeVault(DescribeVaultOutput dvo) {
    StringBuilder sb = new StringBuilder();
    sb.append("================================================================================\n");
    sb.append("Found Vault: ").append(dvo.getVaultName()).append("\n");
    sb.append("    getCreationDateString(): ").append(dvo.getCreationDate()).append("\n");
    sb.append("    getLastInventoryDate(): ").append(dvo.getLastInventoryDate()).append("\n");
    sb.append("    getNumberOfArchives(): ").append(dvo.getNumberOfArchives()).append("\n");
    sb.append("    getSizeInBytes(): ").append(dvo.getSizeInBytes()).append("\n");
    sb.append("    getVaultARN(): ").append(dvo.getVaultARN()).append("\n");
    sb.append("    toString(): ").append(dvo.toString()).append("\n");
    sb.append("    toString(): ").append(dvo.getVaultName()).append("\n");
    return sb.toString();
}