diff --git a/apis/glacier/pom.xml b/apis/glacier/pom.xml
index 5ac9979aeb..73f7804a79 100644
--- a/apis/glacier/pom.xml
+++ b/apis/glacier/pom.xml
@@ -32,7 +32,7 @@
bundle
- https://glacier.eu-west-1.amazonaws.com
+ https://glacier.us-east-1.amazonaws.com
2012-06-01
${test.aws.identity}
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierApiMetadata.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierApiMetadata.java
index c547e21046..b27dd58654 100644
--- a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierApiMetadata.java
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierApiMetadata.java
@@ -23,6 +23,7 @@ import java.net.URI;
import java.util.Properties;
import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.glacier.config.GlacierParserModule;
import org.jclouds.glacier.config.GlacierRestClientModule;
import org.jclouds.glacier.reference.GlacierHeaders;
import org.jclouds.rest.internal.BaseRestApiMetadata;
@@ -82,7 +83,7 @@ public class GlacierApiMetadata extends BaseRestApiMetadata {
.defaultProperties(GlacierApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.view(typeToken(BlobStoreContext.class))
- .defaultModules(ImmutableSet.> of(GlacierRestClientModule.class));
+ .defaultModules(ImmutableSet.> of(GlacierRestClientModule.class, GlacierParserModule.class));
}
@Override
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java
index 7f66811eda..95543433dc 100644
--- a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierAsyncClient.java
@@ -22,25 +22,87 @@ import java.io.Closeable;
import java.net.URI;
import javax.inject.Named;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.blobstore.attr.BlobScope;
+import org.jclouds.glacier.domain.PaginatedVaultCollection;
+import org.jclouds.glacier.domain.VaultMetadata;
+import org.jclouds.glacier.fallbacks.FalseIfVaultNotEmpty;
import org.jclouds.glacier.filters.RequestAuthorizeSignature;
+import org.jclouds.glacier.functions.ParseVaultMetadataFromHttpContent;
+import org.jclouds.glacier.functions.ParseVaultMetadataListFromHttpContent;
+import org.jclouds.glacier.options.PaginationOptions;
+import org.jclouds.glacier.predicates.validators.VaultNameValidator;
import org.jclouds.glacier.reference.GlacierHeaders;
+import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.Headers;
+import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
+/**
+ * Provides asynchronous access to Amazon Glacier resources via their REST API.
+ *
+ *
+ * @see GlacierClient
+ * @see
+ * @author Roman Coedo
+ */
@Headers(keys = GlacierHeaders.VERSION, values = "2012-06-01")
@RequestFilters(RequestAuthorizeSignature.class)
@BlobScope(CONTAINER)
public interface GlacierAsyncClient extends Closeable {
+ /**
+ * @see GlacierClient#createVault
+ */
@Named("CreateVault")
@PUT
@Path("/-/vaults/{vault}")
- ListenableFuture createVault(@PathParam("vault") String vaultName);
+ ListenableFuture createVault(@PathParam("vault") @ParamValidators(VaultNameValidator.class) String vaultName);
+
+ /**
+ * @see GlacierClient#deleteVaultIfEmpty
+ */
+ @Named("DeleteVault")
+ @DELETE
+ @Path("/-/vaults/{vault}")
+ @Fallback(FalseIfVaultNotEmpty.class)
+ ListenableFuture deleteVaultIfEmpty(@PathParam("vault") @ParamValidators(VaultNameValidator.class) String vaultName);
+
+ /**
+ * @see GlacierClient#describeVault
+ */
+ @Named("DescribeVault")
+ @GET
+ @Path("/-/vaults/{vault}")
+ @ResponseParser(ParseVaultMetadataFromHttpContent.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture describeVault(
+ @PathParam("vault") @ParamValidators(VaultNameValidator.class) String vaultName);
+
+ /**
+ * @see GlacierClient#listVaults(PaginationOptions)
+ */
+ @Named("ListVaults")
+ @GET
+ @Path("/-/vaults")
+ @ResponseParser(ParseVaultMetadataListFromHttpContent.class)
+ ListenableFuture listVaults(PaginationOptions options);
+
+ /**
+ * @see GlacierClient#listVaults
+ */
+ @Named("ListVaults")
+ @GET
+ @Path("/-/vaults")
+ @ResponseParser(ParseVaultMetadataListFromHttpContent.class)
+ ListenableFuture listVaults();
}
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java
index 3d392b9c8e..8dc16d1971 100644
--- a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierClient.java
@@ -19,7 +19,64 @@ package org.jclouds.glacier;
import java.io.Closeable;
import java.net.URI;
+import org.jclouds.glacier.domain.PaginatedVaultCollection;
+import org.jclouds.glacier.domain.VaultMetadata;
+import org.jclouds.glacier.options.PaginationOptions;
+
+/**
+ * Provides access to Amazon Glacier resources via their REST API.
+ *
+ *
+ * @see GlacierAsyncClient
+ * @see
+ * @author Roman Coedo
+ */
public interface GlacierClient extends Closeable {
+ /**
+ * A PUT request operation with a vault name to create a new vault to store archives.
+ *
+ * @param vaultName
+ * A name for the Vault being created.
+ * @return A reference to an URI pointing to the resource created.
+ * @see
+ */
URI createVault(String vaultName);
+
+ /**
+ * A DELETE request operation with a vault name to delete an existing vault. The vault must be empty.
+ *
+ * @param vaultName
+ * Name of the Vault being deleted.
+ * @return False if the vault was not empty and therefore not deleted, true otherwise.
+ * @see
+ */
+ boolean deleteVaultIfEmpty(String vaultName);
+
+ /**
+ * A GET request operation with a vault name to fetch the vault metadata.
+ *
+ * @param vaultName
+ * Name of the Vault being described.
+ * @return A VaultMetadata object containing all the information relevant to the vault.
+ * @see
+ */
+ VaultMetadata describeVault(String vaultName);
+
+ /**
+ * A GET request operation to retrieve a vault listing.
+ *
+ * @param options
+ * Options used for pagination.
+ * @return A PaginatedVaultCollection object containing the list of vaults.
+ * @see
+ */
+ PaginatedVaultCollection listVaults(PaginationOptions options);
+
+ /**
+ * A GET request operation to retrieve a vault listing.
+ *
+ * @see GlacierClient#listVaults(PaginationOptions)
+ */
+ PaginatedVaultCollection listVaults();
}
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/GlacierResponseException.java b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierResponseException.java
new file mode 100644
index 0000000000..4db19f3e04
--- /dev/null
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/GlacierResponseException.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glacier;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.glacier.domain.GlacierError;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+
+/**
+ * Encapsulates a GlacierError.
+ *
+ * @author Roman Coedo
+ */
+public class GlacierResponseException extends HttpResponseException {
+
+ private static final long serialVersionUID = 1L;
+ private final GlacierError error;
+
+ public GlacierResponseException(String message, HttpCommand command, HttpResponse response, GlacierError error,
+ Throwable cause) {
+ super(message, command, response, cause);
+ this.error = checkNotNull(error, "error");
+ }
+
+ public GlacierResponseException(HttpCommand command, HttpResponse response, GlacierError error, Throwable cause) {
+ super("request " + command.getCurrentRequest().getRequestLine() + " failed with code " + response.getStatusCode()
+ + ", error: " + error.toString(), command, response, cause);
+ this.error = checkNotNull(error, "error");
+ }
+
+ public GlacierResponseException(HttpCommand command, HttpResponse response, GlacierError error) {
+ this(command, response, error, null);
+ }
+
+ public GlacierResponseException(String message, HttpCommand command, HttpResponse response, GlacierError error) {
+ this(message, command, response, error, null);
+ }
+
+ public GlacierError getError() {
+ return error;
+ }
+
+}
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierParserModule.java b/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierParserModule.java
new file mode 100644
index 0000000000..8a33a1a4cb
--- /dev/null
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierParserModule.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glacier.config;
+
+import org.jclouds.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+
+import com.google.inject.AbstractModule;
+
+/**
+ * Configures the parser mappings.
+ *
+ * @author Roman Coedo
+ */
+public class GlacierParserModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(Iso8601DateAdapter.class);
+ }
+}
diff --git a/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierRestClientModule.java b/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierRestClientModule.java
index 7631ce9913..6deb56a9a7 100644
--- a/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierRestClientModule.java
+++ b/apis/glacier/src/main/java/org/jclouds/glacier/config/GlacierRestClientModule.java
@@ -26,6 +26,11 @@ import org.jclouds.date.TimeStamp;
import org.jclouds.glacier.GlacierAsyncClient;
import org.jclouds.glacier.GlacierClient;
import org.jclouds.glacier.filters.RequestAuthorizeSignature;
+import org.jclouds.glacier.handlers.ParseGlacierErrorFromJsonContent;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
@@ -34,6 +39,11 @@ import com.google.common.base.Suppliers;
import com.google.inject.Provides;
import com.google.inject.Scopes;
+/**
+ * Configures the mappings. Installs the Object and Parser modules.
+ *
+ * @author Roman Coedo
+ */
@ConfiguresRestClient
public class GlacierRestClientModule extends RestClientModule {
@@ -61,4 +71,11 @@ public class GlacierRestClientModule extends RestClientModule {
+
+ @SerializedName("VaultList")
+ private final Iterable vaults;
+ @SerializedName("Marker")
+ private final String marker;
+
+ @ConstructorProperties({ "VaultList", "Marker" })
+ public PaginatedVaultCollection(Iterable vaults, String marker) {
+ this.vaults = vaults;
+ this.marker = marker;
+ }
+
+ @Override
+ public Iterator iterator() {
+ return vaults.iterator();
+ }
+
+ @Override
+ public Optional