Issue 536:terremark delete operation now returns tasks

This commit is contained in:
Adrian Cole 2011-04-19 16:57:37 -07:00
parent 83bed07d79
commit 2b111b2604
22 changed files with 597 additions and 363 deletions

View File

@ -18,16 +18,20 @@
*/ */
package org.jclouds.s3; package org.jclouds.s3;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import javax.inject.Qualifier;
/** /**
* Annotates the parameter that this is a bucket. * Annotates the parameter that this is a bucket.
*/ */
@Target(PARAMETER) @Target({ PARAMETER, METHOD })
@Retention(RUNTIME) @Retention(RUNTIME)
@Qualifier
public @interface Bucket { public @interface Bucket {
} }

View File

@ -33,6 +33,28 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.attr.BlobScope;
import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound;
import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound;
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.options.GetOptions;
import org.jclouds.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.s3.binders.BindACLToXMLPayload; import org.jclouds.s3.binders.BindACLToXMLPayload;
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured; import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
import org.jclouds.s3.binders.BindBucketLoggingToXmlPayload; import org.jclouds.s3.binders.BindBucketLoggingToXmlPayload;
@ -65,26 +87,6 @@ import org.jclouds.s3.xml.ListAllMyBucketsHandler;
import org.jclouds.s3.xml.ListBucketHandler; import org.jclouds.s3.xml.ListBucketHandler;
import org.jclouds.s3.xml.LocationConstraintHandler; import org.jclouds.s3.xml.LocationConstraintHandler;
import org.jclouds.s3.xml.PayerHandler; import org.jclouds.s3.xml.PayerHandler;
import org.jclouds.blobstore.attr.BlobScope;
import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound;
import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound;
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -121,7 +123,7 @@ public interface S3AsyncClient {
@ExceptionParser(ReturnNullOnKeyNotFound.class) @ExceptionParser(ReturnNullOnKeyNotFound.class)
@ResponseParser(ParseObjectFromHeadersAndHttpContent.class) @ResponseParser(ParseObjectFromHeadersAndHttpContent.class)
ListenableFuture<S3Object> getObject( ListenableFuture<S3Object> getObject(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key, GetOptions... options); @PathParam("key") String key, GetOptions... options);
/** /**
@ -132,7 +134,7 @@ public interface S3AsyncClient {
@ExceptionParser(ReturnNullOnKeyNotFound.class) @ExceptionParser(ReturnNullOnKeyNotFound.class)
@ResponseParser(ParseObjectMetadataFromHeaders.class) @ResponseParser(ParseObjectMetadataFromHeaders.class)
ListenableFuture<ObjectMetadata> headObject( ListenableFuture<ObjectMetadata> headObject(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key); @PathParam("key") String key);
/** /**
@ -142,7 +144,7 @@ public interface S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ExceptionParser(ReturnFalseOnKeyNotFound.class) @ExceptionParser(ReturnFalseOnKeyNotFound.class)
ListenableFuture<Boolean> objectExists( ListenableFuture<Boolean> objectExists(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key); @PathParam("key") String key);
/** /**
@ -152,7 +154,7 @@ public interface S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class) @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> deleteObject( ListenableFuture<Void> deleteObject(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key); @PathParam("key") String key);
/** /**
@ -162,7 +164,7 @@ public interface S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ResponseParser(ParseETagHeader.class) @ResponseParser(ParseETagHeader.class)
ListenableFuture<String> putObject( ListenableFuture<String> putObject(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") @ParamParser(ObjectKey.class) @BinderParam(BindS3ObjectMetadataToRequest.class) S3Object object, @PathParam("key") @ParamParser(ObjectKey.class) @BinderParam(BindS3ObjectMetadataToRequest.class) S3Object object,
PutObjectOptions... options); PutObjectOptions... options);
@ -173,9 +175,8 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState.class) @ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState.class)
ListenableFuture<Boolean> putBucketInRegion( ListenableFuture<Boolean> putBucketInRegion(
// TODO endpoint based on region @EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @BinderParam(BindRegionToXmlPayload.class) @Nullable String region,
@BinderParam(BindRegionToXmlPayload.class) @Nullable String region, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName,
PutBucketOptions... options); PutBucketOptions... options);
/** /**
@ -185,7 +186,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class) @ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class)
ListenableFuture<Boolean> deleteBucketIfEmpty( ListenableFuture<Boolean> deleteBucketIfEmpty(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#bucketExists * @see S3Client#bucketExists
@ -195,7 +196,7 @@ public interface S3AsyncClient {
@QueryParams(keys = "max-keys", values = "0") @QueryParams(keys = "max-keys", values = "0")
@ExceptionParser(ReturnFalseOnContainerNotFound.class) @ExceptionParser(ReturnFalseOnContainerNotFound.class)
ListenableFuture<Boolean> bucketExists( ListenableFuture<Boolean> bucketExists(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#getBucketLocation * @see S3Client#getBucketLocation
@ -205,7 +206,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@XMLResponseParser(LocationConstraintHandler.class) @XMLResponseParser(LocationConstraintHandler.class)
ListenableFuture<String> getBucketLocation( ListenableFuture<String> getBucketLocation(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#getBucketPayer * @see S3Client#getBucketPayer
@ -215,7 +216,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@XMLResponseParser(PayerHandler.class) @XMLResponseParser(PayerHandler.class)
ListenableFuture<Payer> getBucketPayer( ListenableFuture<Payer> getBucketPayer(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#setBucketPayer * @see S3Client#setBucketPayer
@ -224,7 +225,7 @@ public interface S3AsyncClient {
@QueryParams(keys = "requestPayment") @QueryParams(keys = "requestPayment")
@Path("/") @Path("/")
ListenableFuture<Void> setBucketPayer( ListenableFuture<Void> setBucketPayer(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@BinderParam(BindPayerToXmlPayload.class) Payer payer); @BinderParam(BindPayerToXmlPayload.class) Payer payer);
/** /**
@ -234,7 +235,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@XMLResponseParser(ListBucketHandler.class) @XMLResponseParser(ListBucketHandler.class)
ListenableFuture<ListBucketResponse> listBucket( ListenableFuture<ListBucketResponse> listBucket(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
ListBucketOptions... options); ListBucketOptions... options);
/** /**
@ -256,7 +257,7 @@ public interface S3AsyncClient {
ListenableFuture<ObjectMetadata> copyObject( ListenableFuture<ObjectMetadata> copyObject(
@PathParam("sourceBucket") String sourceBucket, @PathParam("sourceBucket") String sourceBucket,
@PathParam("sourceObject") String sourceObject, @PathParam("sourceObject") String sourceObject,
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String destinationBucket, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String destinationBucket,
@PathParam("destinationObject") String destinationObject, CopyObjectOptions... options); @PathParam("destinationObject") String destinationObject, CopyObjectOptions... options);
/** /**
@ -268,7 +269,7 @@ public interface S3AsyncClient {
@ExceptionParser(ThrowContainerNotFoundOn404.class) @ExceptionParser(ThrowContainerNotFoundOn404.class)
@Path("/") @Path("/")
ListenableFuture<AccessControlList> getBucketACL( ListenableFuture<AccessControlList> getBucketACL(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#putBucketACL * @see S3Client#putBucketACL
@ -277,7 +278,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@QueryParams(keys = "acl") @QueryParams(keys = "acl")
ListenableFuture<Boolean> putBucketACL( ListenableFuture<Boolean> putBucketACL(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@BinderParam(BindACLToXMLPayload.class) AccessControlList acl); @BinderParam(BindACLToXMLPayload.class) AccessControlList acl);
/** /**
@ -289,7 +290,7 @@ public interface S3AsyncClient {
@XMLResponseParser(AccessControlListHandler.class) @XMLResponseParser(AccessControlListHandler.class)
@ExceptionParser(ThrowKeyNotFoundOn404.class) @ExceptionParser(ThrowKeyNotFoundOn404.class)
ListenableFuture<AccessControlList> getObjectACL( ListenableFuture<AccessControlList> getObjectACL(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key); @PathParam("key") String key);
/** /**
@ -299,9 +300,8 @@ public interface S3AsyncClient {
@QueryParams(keys = "acl") @QueryParams(keys = "acl")
@Path("/{key}") @Path("/{key}")
ListenableFuture<Boolean> putObjectACL( ListenableFuture<Boolean> putObjectACL(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key, @PathParam("key") String key, @BinderParam(BindACLToXMLPayload.class) AccessControlList acl);
@BinderParam(BindACLToXMLPayload.class) AccessControlList acl);
/** /**
* @see S3Client#getBucketLogging * @see S3Client#getBucketLogging
@ -312,7 +312,7 @@ public interface S3AsyncClient {
@ExceptionParser(ThrowContainerNotFoundOn404.class) @ExceptionParser(ThrowContainerNotFoundOn404.class)
@Path("/") @Path("/")
ListenableFuture<BucketLogging> getBucketLogging( ListenableFuture<BucketLogging> getBucketLogging(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see S3Client#enableBucketLogging * @see S3Client#enableBucketLogging
@ -321,7 +321,7 @@ public interface S3AsyncClient {
@Path("/") @Path("/")
@QueryParams(keys = "logging") @QueryParams(keys = "logging")
ListenableFuture<Void> enableBucketLogging( ListenableFuture<Void> enableBucketLogging(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@BinderParam(BindBucketLoggingToXmlPayload.class) BucketLogging logging); @BinderParam(BindBucketLoggingToXmlPayload.class) BucketLogging logging);
/** /**
@ -332,6 +332,6 @@ public interface S3AsyncClient {
@QueryParams(keys = "logging") @QueryParams(keys = "logging")
@Produces(MediaType.TEXT_XML) @Produces(MediaType.TEXT_XML)
ListenableFuture<Void> disableBucketLogging( ListenableFuture<Void> disableBucketLogging(
@Bucket @BinderParam(BindNoBucketLoggingToXmlPayload.class) @ParamValidators( { BucketNameValidator.class }) String bucketName); @Bucket @BinderParam(BindNoBucketLoggingToXmlPayload.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
} }

View File

@ -45,10 +45,10 @@ import com.google.common.collect.Maps;
@Singleton @Singleton
public class BindAsHostPrefixIfConfigured implements Binder { public class BindAsHostPrefixIfConfigured implements Binder {
private final Provider<UriBuilder> uriBuilderProvider; protected final Provider<UriBuilder> uriBuilderProvider;
private final BindAsHostPrefix bindAsHostPrefix; protected final BindAsHostPrefix bindAsHostPrefix;
private final boolean isVhostStyle; protected final boolean isVhostStyle;
private final String servicePath; protected final String servicePath;
@Inject @Inject
public BindAsHostPrefixIfConfigured(BindAsHostPrefix bindAsHostPrefix, public BindAsHostPrefixIfConfigured(BindAsHostPrefix bindAsHostPrefix,

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.s3.config; package org.jclouds.s3.config;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
@ -34,6 +35,7 @@ import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RequestSigner; import org.jclouds.rest.RequestSigner;
import org.jclouds.s3.Bucket;
import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client; import org.jclouds.s3.S3Client;
import org.jclouds.s3.filters.RequestAuthorizeSignature; import org.jclouds.s3.filters.RequestAuthorizeSignature;
@ -41,6 +43,7 @@ import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.Maps;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
@ -60,6 +63,13 @@ public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> ext
super(sync, async); super(sync, async);
} }
@Provides
@Bucket
@Singleton
protected Map<String, String> bucketToRegion() {
return Maps.newConcurrentMap();
}
@Override @Override
protected void configure() { protected void configure() {
install(new S3ObjectModule()); install(new S3ObjectModule());

View File

@ -20,6 +20,8 @@ package org.jclouds.s3.functions;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import java.net.URI;
import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.annotation.Nullable; import javax.annotation.Nullable;

View File

@ -20,8 +20,15 @@ package org.jclouds.s3.xml;
import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.util.SaxUtils.currentOrNull;
import java.util.concurrent.ConcurrentMap;
import javax.inject.Inject;
import org.jclouds.aws.domain.Region; import org.jclouds.aws.domain.Region;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.s3.Bucket;
/** /**
* Parses the response from Amazon S3 GET Bucket Location * Parses the response from Amazon S3 GET Bucket Location
@ -32,8 +39,15 @@ import org.jclouds.http.functions.ParseSax;
* @author Adrian Cole * @author Adrian Cole
*/ */
public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String> { public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String> {
private final ConcurrentMap<String, String> bucketToRegion;
private StringBuilder currentText = new StringBuilder(); private StringBuilder currentText = new StringBuilder();
private String region; private String region;
private String bucket;
@Inject
public LocationConstraintHandler(@Bucket ConcurrentMap<String, String> bucketToRegion) {
this.bucketToRegion = bucketToRegion;
}
public String getResult() { public String getResult() {
return region; return region;
@ -41,6 +55,18 @@ public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String
public void endElement(String uri, String name, String qName) { public void endElement(String uri, String name, String qName) {
region = fromValue(currentOrNull(currentText)); region = fromValue(currentOrNull(currentText));
bucketToRegion.put(bucket, region);
}
@Override
public LocationConstraintHandler setContext(HttpRequest request) {
super.setContext(request);
setBucket(GeneratedHttpRequest.class.cast(getRequest()).getArgs().get(0).toString());
return this;
}
void setBucket(String bucket) {
this.bucket = bucket;
} }
/** /**

View File

@ -37,12 +37,12 @@ import org.jclouds.predicates.validators.DnsNameValidator;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload; import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload; import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
@ -52,6 +52,7 @@ import org.jclouds.vcloud.domain.network.OrgNetwork;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler; import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler;
@ -164,7 +165,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends VCloudExpressVApp> getVApp(@EndpointParam URI vApp); ListenableFuture<? extends VCloudExpressVApp> getVApp(@EndpointParam URI vApp);
/** /**
* @see CommonVCloudClient#deployVApp * @see VCloudExpressClient#deployVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -173,7 +174,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#undeployVApp * @see VCloudExpressClient#undeployVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -182,7 +183,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#powerOnVApp * @see VCloudExpressClient#powerOnVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -191,7 +192,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#powerOffVApp * @see VCloudExpressClient#powerOffVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -200,14 +201,14 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#shutdownVApp * @see VCloudExpressClient#shutdownVApp
*/ */
@POST @POST
@Path("/power/action/shutdown") @Path("/power/action/shutdown")
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId); ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#resetVApp * @see VCloudExpressClient#resetVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -216,7 +217,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#suspendVApp * @see VCloudExpressClient#suspendVApp
*/ */
@POST @POST
@Consumes(TASK_XML) @Consumes(TASK_XML)
@ -225,10 +226,10 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId); ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
/** /**
* @see CommonVCloudClient#deleteVApp * @see VCloudExpressClient#deleteVApp
*/ */
@DELETE @DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class) @ResponseParser(ParseTaskFromLocationHeader.class)
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId); @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Task> deleteVApp(@EndpointParam URI vAppId);
} }

View File

@ -101,6 +101,6 @@ public interface VCloudExpressClient extends CommonVCloudClient {
*/ */
Task suspendVApp(URI vAppId); Task suspendVApp(URI vAppId);
void deleteVApp(URI vAppId); Task deleteVApp(URI vAppId);
} }

View File

@ -29,7 +29,6 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OperatingSystemBuilder;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.util.ComputeServiceUtils; import org.jclouds.compute.util.ComputeServiceUtils;
@ -51,7 +50,7 @@ public class ParseOsFromVAppTemplateName implements Function<String, OperatingSy
@Override @Override
public OperatingSystem apply(String from) { public OperatingSystem apply(String from) {
OperatingSystemBuilder builder = new OperatingSystemBuilder(); OperatingSystem.Builder builder = OperatingSystem.builder();
OsFamily osFamily = parseOsFamilyOrUnrecognized(checkNotNull(from, "vapp template name")); OsFamily osFamily = parseOsFamilyOrUnrecognized(checkNotNull(from, "vapp template name"));
builder.family(osFamily); builder.family(osFamily);
builder.description(from); builder.description(from);

View File

@ -60,7 +60,10 @@ public class VCloudExpressComputeClientImpl extends
@Override @Override
protected void deleteVApp(VCloudExpressVApp vApp) { protected void deleteVApp(VCloudExpressVApp vApp) {
logger.debug(">> deleting vApp(%s)", vApp.getName()); logger.debug(">> deleting vApp(%s)", vApp.getName());
VCloudExpressClient.class.cast(client).deleteVApp(vApp.getHref()); Task task = VCloudExpressClient.class.cast(client).deleteVApp(vApp.getHref());
if (task != null)
if (!taskTester.apply(task.getHref()))
throw new RuntimeException(String.format("failed to %s %s: %s", "delete", vApp.getName(), task));
} }
@Override @Override

View File

@ -16,7 +16,8 @@
* limitations under the License. * limitations under the License.
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud.terremark.functions;
package org.jclouds.vcloud.functions;
import java.net.URI; import java.net.URI;
import java.util.Date; import java.util.Date;

View File

@ -44,7 +44,6 @@ import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.jclouds.vcloud.config.VCloudExpressRestClientModule; import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
@ -60,6 +59,7 @@ import org.jclouds.vcloud.domain.internal.VDCImpl;
import org.jclouds.vcloud.domain.network.FenceMode; import org.jclouds.vcloud.domain.network.FenceMode;
import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.domain.network.NetworkConfig;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.CloneVAppOptions; import org.jclouds.vcloud.options.CloneVAppOptions;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.xml.CatalogHandler; import org.jclouds.vcloud.xml.CatalogHandler;
@ -500,9 +500,9 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
assertNonPayloadHeadersEqual(request, ""); assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false); assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, request, ParseTaskFromLocationHeader.class);
assertSaxResponseParserClassEquals(method, null); assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request); checkFilters(request);
} }

View File

@ -46,8 +46,8 @@ import org.jclouds.predicates.validators.DnsNameValidator;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
@ -64,6 +64,7 @@ import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameAndVDCNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameCatalogNameItemNameToEndpoint;
import org.jclouds.vcloud.functions.OrgNameToEndpoint; import org.jclouds.vcloud.functions.OrgNameToEndpoint;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload; import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload;
import org.jclouds.vcloud.terremark.binders.BindVAppConfigurationToXmlPayload; import org.jclouds.vcloud.terremark.binders.BindVAppConfigurationToXmlPayload;
@ -77,7 +78,6 @@ import org.jclouds.vcloud.terremark.domain.TerremarkCatalogItem;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg; import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import org.jclouds.vcloud.terremark.domain.TerremarkVDC; import org.jclouds.vcloud.terremark.domain.TerremarkVDC;
import org.jclouds.vcloud.terremark.domain.VAppConfiguration; import org.jclouds.vcloud.terremark.domain.VAppConfiguration;
import org.jclouds.vcloud.terremark.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.terremark.functions.ReturnVoidOnDeleteDefaultIp; import org.jclouds.vcloud.terremark.functions.ReturnVoidOnDeleteDefaultIp;
import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToInternetServicesEndpoint;
import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint; import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint;

View File

@ -177,4 +177,5 @@ public interface TerremarkVCloudClient extends VCloudExpressClient {
// keyPairConfiguration); // keyPairConfiguration);
void deleteKeyPair(URI keyPair); void deleteKeyPair(URI keyPair);
} }

View File

@ -24,9 +24,9 @@ import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Bui
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.Map.Entry;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.inject.Inject; import javax.inject.Inject;
@ -142,12 +142,16 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
} else { } else {
logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port); logger.debug(">> adding InternetService %s:%s:%d", ip.getAddress(), protocol, port);
is = client.addInternetServiceToExistingIp(ip.getId(), vApp.getName() + "-" + port, protocol, port, is = client.addInternetServiceToExistingIp(
ip.getId(),
vApp.getName() + "-" + port,
protocol,
port,
withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(), withDescription(String.format("port %d access to serverId: %s name: %s", port, vApp.getName(),
vApp.getName()))); vApp.getName())));
} }
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(), is logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(),
.getProtocol(), is.getPort()); is.getProtocol(), is.getPort());
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(), logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
privateAddress, port); privateAddress, port);
Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port); Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);

View File

@ -20,8 +20,10 @@ package org.jclouds.json.config;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
@ -33,6 +35,8 @@ import org.jclouds.json.Json;
import org.jclouds.json.internal.EnumTypeAdapterThatReturnsFromValue; import org.jclouds.json.internal.EnumTypeAdapterThatReturnsFromValue;
import org.jclouds.json.internal.GsonWrapper; import org.jclouds.json.internal.GsonWrapper;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import com.google.gson.Gson; import com.google.gson.Gson;
@ -51,6 +55,7 @@ import com.google.gson.reflect.TypeToken;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
/** /**
* Contains logic for parsing objects from Strings. * Contains logic for parsing objects from Strings.
@ -63,13 +68,15 @@ public class GsonModule extends AbstractModule {
@Provides @Provides
@Singleton @Singleton
Gson provideGson(JsonBallAdapter jsonAdapter, DateAdapter adapter, ByteListAdapter byteListAdapter, Gson provideGson(JsonBallAdapter jsonAdapter, DateAdapter adapter, ByteListAdapter byteListAdapter,
ByteArrayAdapter byteArrayAdapter, JsonAdapterBindings bindings) throws ClassNotFoundException, Exception { ByteArrayAdapter byteArrayAdapter, SerializePropertiesDefaults propertiesAdapter, JsonAdapterBindings bindings)
throws ClassNotFoundException, Exception {
GsonBuilder builder = new GsonBuilder(); GsonBuilder builder = new GsonBuilder();
JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Enum.class, JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Enum.class,
new EnumTypeAdapterThatReturnsFromValue()); new EnumTypeAdapterThatReturnsFromValue());
JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Map.class, new MapTypeAdapter()); JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Map.class, new MapTypeAdapter());
builder.registerTypeAdapter(JsonBall.class, jsonAdapter); builder.registerTypeAdapter(JsonBall.class, jsonAdapter);
builder.registerTypeAdapter(Date.class, adapter); builder.registerTypeAdapter(Date.class, adapter);
builder.registerTypeAdapter(Properties.class, propertiesAdapter);
builder.registerTypeAdapter(new TypeToken<List<Byte>>() { builder.registerTypeAdapter(new TypeToken<List<Byte>>() {
}.getType(), byteListAdapter); }.getType(), byteListAdapter);
builder.registerTypeAdapter(byte[].class, byteArrayAdapter); builder.registerTypeAdapter(byte[].class, byteArrayAdapter);
@ -169,6 +176,28 @@ public class GsonModule extends AbstractModule {
} }
@Singleton
public static class SerializePropertiesDefaults implements JsonSerializer<Properties> {
private final Json json;
private final Type mapType = new TypeLiteral<Map<String, String>>() {
}.getRawType();
@Inject
public SerializePropertiesDefaults(Json json) {
this.json = json;
}
public JsonElement serialize(Properties src, Type typeOfSrc, JsonSerializationContext context) {
Builder<String, String> srcMap = ImmutableMap.<String, String> builder();
for (Enumeration<?> propNames = src.propertyNames(); propNames.hasMoreElements();) {
String propName = (String) propNames.nextElement();
srcMap.put(propName, src.getProperty(propName));
}
return new JsonLiteral(json.toJson(srcMap.build(), mapType));
}
}
@Singleton @Singleton
public static class CDateAdapter implements DateAdapter { public static class CDateAdapter implements DateAdapter {
private final DateService dateService; private final DateService dateService;

View File

@ -21,6 +21,7 @@ package org.jclouds.json;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import org.jclouds.json.config.GsonModule; import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -44,6 +45,19 @@ public class JsonTest {
private Test enumValue; private Test enumValue;
} }
public void testPropertiesSerializesDefaults() {
Properties props = new Properties();
props.put("string", "string");
props.put("number", "1");
props.put("boolean", "true");
assertEquals(json.toJson(props), "{\"string\":\"string\",\"boolean\":\"true\",\"number\":\"1\"}");
Properties props3 = new Properties(props);
assertEquals(json.toJson(props3), "{\"string\":\"string\",\"boolean\":\"true\",\"number\":\"1\"}");
Properties props2 = json.fromJson(json.toJson(props), Properties.class);
assertEquals(props2, props);
assertEquals(json.toJson(props2), json.toJson(props));
}
public void testMapStringObjectWithAllValidValuesOneDeep() { public void testMapStringObjectWithAllValidValuesOneDeep() {
Map<String, Object> map = Maps.newHashMap(); Map<String, Object> map = Maps.newHashMap();
map.put("string", "string"); map.put("string", "string");

View File

@ -18,29 +18,13 @@
*/ */
package org.jclouds.aws.s3; package org.jclouds.aws.s3;
/**
*
*
* ====================================================================
* Licensed 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.
* ====================================================================
*/
import static org.jclouds.blobstore.attr.BlobScopes.CONTAINER; import static org.jclouds.blobstore.attr.BlobScopes.CONTAINER;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@ -56,6 +40,7 @@ import org.jclouds.blobstore.attr.BlobScope;
import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
@ -63,14 +48,20 @@ import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.s3.Bucket; import org.jclouds.s3.Bucket;
import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured; import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
import org.jclouds.s3.domain.ObjectMetadata; import org.jclouds.s3.domain.ObjectMetadata;
import org.jclouds.s3.filters.RequestAuthorizeSignature; import org.jclouds.s3.filters.RequestAuthorizeSignature;
import org.jclouds.s3.functions.BindRegionToXmlPayload;
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
import org.jclouds.s3.options.PutBucketOptions;
import org.jclouds.s3.options.PutObjectOptions; import org.jclouds.s3.options.PutObjectOptions;
import org.jclouds.s3.predicates.validators.BucketNameValidator; import org.jclouds.s3.predicates.validators.BucketNameValidator;
import org.jclouds.s3.xml.LocationConstraintHandler;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -83,6 +74,31 @@ import com.google.common.util.concurrent.ListenableFuture;
@RequestFilters(RequestAuthorizeSignature.class) @RequestFilters(RequestAuthorizeSignature.class)
@BlobScope(CONTAINER) @BlobScope(CONTAINER)
public interface AWSS3AsyncClient extends S3AsyncClient { public interface AWSS3AsyncClient extends S3AsyncClient {
/**
* @see S3Client#putBucketInRegion
*/
@Override
@PUT
@Path("/")
@Endpoint(Bucket.class)
@ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState.class)
ListenableFuture<Boolean> putBucketInRegion(
@BinderParam(BindRegionToXmlPayload.class) @Nullable String region,
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
PutBucketOptions... options);
/**
* @see S3Client#getBucketLocation
*/
@Override
@GET
@QueryParams(keys = "location")
@Path("/")
@Endpoint(Bucket.class)
@XMLResponseParser(LocationConstraintHandler.class)
ListenableFuture<String> getBucketLocation(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
/** /**
* @see AWSS3Client#initiateMultipartUpload * @see AWSS3Client#initiateMultipartUpload
*/ */
@ -91,7 +107,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ResponseParser(UploadIdFromHttpResponseViaRegex.class) @ResponseParser(UploadIdFromHttpResponseViaRegex.class)
ListenableFuture<String> initiateMultipartUpload( ListenableFuture<String> initiateMultipartUpload(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") @ParamParser(ObjectMetadataKey.class) @BinderParam(BindObjectMetadataToRequest.class) ObjectMetadata objectMetadata, @PathParam("key") @ParamParser(ObjectMetadataKey.class) @BinderParam(BindObjectMetadataToRequest.class) ObjectMetadata objectMetadata,
PutObjectOptions... options); PutObjectOptions... options);
@ -102,7 +118,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class) @ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture<Void> abortMultipartUpload( ListenableFuture<Void> abortMultipartUpload(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key, @QueryParam("uploadId") String uploadId); @PathParam("key") String key, @QueryParam("uploadId") String uploadId);
/** /**
@ -112,7 +128,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ResponseParser(ParseETagHeader.class) @ResponseParser(ParseETagHeader.class)
ListenableFuture<String> uploadPart( ListenableFuture<String> uploadPart(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key, @QueryParam("partNumber") int partNumber, @PathParam("key") String key, @QueryParam("partNumber") int partNumber,
@QueryParam("uploadId") String uploadId, Payload part); @QueryParam("uploadId") String uploadId, Payload part);
@ -123,7 +139,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
@Path("/{key}") @Path("/{key}")
@ResponseParser(ETagFromHttpResponseViaRegex.class) @ResponseParser(ETagFromHttpResponseViaRegex.class)
ListenableFuture<String> completeMultipartUpload( ListenableFuture<String> completeMultipartUpload(
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName, @Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
@PathParam("key") String key, @QueryParam("uploadId") String uploadId, @PathParam("key") String key, @QueryParam("uploadId") String uploadId,
@BinderParam(BindPartIdsAndETagsToRequest.class) Map<Integer, String> parts); @BinderParam(BindPartIdsAndETagsToRequest.class) Map<Integer, String> parts);

View File

@ -18,14 +18,24 @@
*/ */
package org.jclouds.aws.s3.config; package org.jclouds.aws.s3.config;
import static org.jclouds.aws.domain.Region.US_STANDARD;
import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
import java.net.URI;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.aws.s3.AWSS3AsyncClient; import org.jclouds.aws.s3.AWSS3AsyncClient;
import org.jclouds.aws.s3.AWSS3Client; import org.jclouds.aws.s3.AWSS3Client;
import org.jclouds.aws.s3.binders.AssignCorrectHostnameAndBindAsHostPrefixIfConfigured;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.s3.Bucket;
import org.jclouds.s3.S3AsyncClient; import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client; import org.jclouds.s3.S3Client;
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
import org.jclouds.s3.config.S3RestClientModule; import org.jclouds.s3.config.S3RestClientModule;
import com.google.inject.Provides; import com.google.inject.Provides;
@ -39,6 +49,19 @@ import com.google.inject.Provides;
@ConfiguresRestClient @ConfiguresRestClient
public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3AsyncClient> { public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3AsyncClient> {
@Provides
@Singleton
@Bucket
protected URI provideLocationURI(@Named(PROPERTY_REGION + "." + US_STANDARD + "." + ENDPOINT) String endpoint) {
return URI.create(endpoint);
}
@Override
protected void configure() {
bind(BindAsHostPrefixIfConfigured.class).to(AssignCorrectHostnameAndBindAsHostPrefixIfConfigured.class);
super.configure();
}
public AWSS3RestClientModule() { public AWSS3RestClientModule() {
super(AWSS3Client.class, AWSS3AsyncClient.class); super(AWSS3Client.class, AWSS3AsyncClient.class);
} }

View File

@ -21,8 +21,10 @@ package org.jclouds.aws.s3;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.URI;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ConcurrentMap;
import org.jclouds.aws.s3.config.AWSS3RestClientModule; import org.jclouds.aws.s3.config.AWSS3RestClientModule;
import org.jclouds.aws.s3.functions.ETagFromHttpResponseViaRegex; import org.jclouds.aws.s3.functions.ETagFromHttpResponseViaRegex;
@ -31,6 +33,7 @@ import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseETagHeader; import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
@ -40,15 +43,18 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.domain.ObjectMetadata; import org.jclouds.s3.domain.ObjectMetadata;
import org.jclouds.s3.domain.ObjectMetadataBuilder; import org.jclouds.s3.domain.ObjectMetadataBuilder;
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState; import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
import org.jclouds.s3.options.PutBucketOptions; import org.jclouds.s3.options.PutBucketOptions;
import org.jclouds.s3.options.PutObjectOptions; import org.jclouds.s3.options.PutObjectOptions;
import org.jclouds.s3.xml.LocationConstraintHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.inject.Module; import com.google.inject.Module;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
@ -63,6 +69,21 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
this.provider = "aws-s3"; this.provider = "aws-s3";
} }
public void testGetBucketLocationEU() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("getBucketLocation", String.class);
HttpRequest request = processor.createRequest(method, "eubucket");
assertRequestLineEquals(request, "GET https://eubucket.bucket/?location HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket.s3.amazonaws.com\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, LocationConstraintHandler.class);
assertExceptionParserClassEquals(method, null);
checkFilters(request);
}
@Override @Override
protected TypeLiteral<RestAnnotationProcessor<AWSS3AsyncClient>> createTypeLiteral() { protected TypeLiteral<RestAnnotationProcessor<AWSS3AsyncClient>> createTypeLiteral() {
return new TypeLiteral<RestAnnotationProcessor<AWSS3AsyncClient>>() { return new TypeLiteral<RestAnnotationProcessor<AWSS3AsyncClient>>() {
@ -93,8 +114,7 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1"); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploads HTTP/1.1");
assertNonPayloadHeadersEqual(request, assertNonPayloadHeadersEqual(request,
"Authorization: AWS identity:Sp1FX4svL9P2u2bFJwroaYpSANo=\nContent-MD5: AQIDBA==\n" "Authorization: AWS identity:Sp1FX4svL9P2u2bFJwroaYpSANo=\nContent-MD5: AQIDBA==\n"
+ "Content-Type: binary/octet-stream\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket." + url + "Content-Type: binary/octet-stream\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket." + url + "\n");
+ "\n");
assertPayloadEquals(request, null, null, false); assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, UploadIdFromHttpResponseViaRegex.class); assertResponseParserClassEquals(method, request, UploadIdFromHttpResponseViaRegex.class);
@ -107,8 +127,8 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
public void testAbortMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { public void testAbortMultipartUpload() throws SecurityException, NegativeArraySizeException, NoSuchMethodException {
Method method = AWSS3AsyncClient.class Method method = AWSS3AsyncClient.class
.getMethod("abortMultipartUpload", String.class, String.class, String.class); .getMethod("abortMultipartUpload", String.class, String.class, String.class);
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", 1, Payloads HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", 1,
.newStringPayload("")); Payloads.newStringPayload(""));
assertRequestLineEquals(request, "DELETE https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1"); assertRequestLineEquals(request, "DELETE https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -124,8 +144,8 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
public void testUploadPart() throws SecurityException, NegativeArraySizeException, NoSuchMethodException { public void testUploadPart() throws SecurityException, NegativeArraySizeException, NoSuchMethodException {
Method method = AWSS3AsyncClient.class.getMethod("uploadPart", String.class, String.class, int.class, Method method = AWSS3AsyncClient.class.getMethod("uploadPart", String.class, String.class, int.class,
String.class, Payload.class); String.class, Payload.class);
HttpRequest request = processor.createRequest(method, "bucket", "foo", 1, "asdsadasdas", Payloads HttpRequest request = processor.createRequest(method, "bucket", "foo", 1, "asdsadasdas",
.newStringPayload("")); Payloads.newStringPayload(""));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/foo?partNumber=1&uploadId=asdsadasdas HTTP/1.1"); assertRequestLineEquals(request, "PUT https://bucket." + url + "/foo?partNumber=1&uploadId=asdsadasdas HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -142,8 +162,8 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
NoSuchMethodException { NoSuchMethodException {
Method method = AWSS3AsyncClient.class.getMethod("completeMultipartUpload", String.class, String.class, Method method = AWSS3AsyncClient.class.getMethod("completeMultipartUpload", String.class, String.class,
String.class, Map.class); String.class, Map.class);
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", ImmutableMap HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas",
.<Integer, String> of(1, "\"a54357aff0632cce46d942af68356b38\"")); ImmutableMap.<Integer, String> of(1, "\"a54357aff0632cce46d942af68356b38\""));
assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1"); assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n"); assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -186,6 +206,18 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
super(); super();
} }
@Override
protected ConcurrentMap<String, String> bucketToRegion() {
ConcurrentMap<String, String> returnVal = Maps.newConcurrentMap();
returnVal.put("eubucket", "EU");
return returnVal;
}
@Override
protected URI provideLocationURI(String endpoint) {
return URI.create("https://bucket");
}
@Override @Override
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) { protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
return "2009-11-08T15:54:08.897Z"; return "2009-11-08T15:54:08.897Z";

View File

@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.CommonVCloudClient;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier; import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier;
import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.AllocationModel;
import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Capacity;
@ -62,6 +62,7 @@ import org.jclouds.vcloud.domain.VDCStatus;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.domain.network.NetworkConfig;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule; import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
@ -104,8 +105,8 @@ import com.google.inject.TypeLiteral;
public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkECloudAsyncClient> { public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkECloudAsyncClient> {
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException { public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class); Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
@ -118,6 +119,22 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
checkFilters(request); checkFilters(request);
} }
public void testDelete() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("deleteVApp", URI.class);
HttpRequest request = processor.createRequest(method,
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseTaskFromLocationHeader.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException { public void testFindNetworkInOrgVDCNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class, Method method = TerremarkECloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class,
String.class, String.class); String.class, String.class);
@ -170,14 +187,16 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class); String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
"name"); "name");
assertRequestLineEquals(request, assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/InstantiateVAppTemplateParams-test.xml")), "/terremark/InstantiateVAppTemplateParams-test.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
@ -192,16 +211,21 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
IOException { IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class, Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
String.class, InstantiateVAppTemplateOptions[].class); String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), method,
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group") URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
.withPassword("password").inRow("row").addNetworkConfig( URI.create("https://vcloud/vAppTemplate/3"),
new NetworkConfig(URI.create("http://network")))); "name",
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
.withPassword("password").inRow("row")
.addNetworkConfig(new NetworkConfig(URI.create("http://network"))));
assertRequestLineEquals(request, assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/InstantiateVAppTemplateParams-options-test.xml")), "/terremark/InstantiateVAppTemplateParams-options-test.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
@ -214,8 +238,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException, IOException { public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("activatePublicIpInVDC", URI.class); Method method = TerremarkECloudAsyncClient.class.getMethod("activatePublicIpInVDC", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/publicIps/1 HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/publicIps/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.publicIp+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.publicIp+xml\n");
@ -230,8 +254,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException { public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class); Method method = TerremarkECloudAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetServicesList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetServicesList+xml\n");
@ -282,9 +306,9 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request,
getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")).replace( Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml"))
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), .replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
"application/vnd.tmrk.ecloud.internetService+xml", false); "application/vnd.tmrk.ecloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -302,9 +326,9 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request,
getClass().getResourceAsStream("/CreateInternetService-options-test.xml")).replace( Strings2.toStringAndClose(getClass().getResourceAsStream("/CreateInternetService-options-test.xml"))
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), .replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
"application/vnd.tmrk.ecloud.internetService+xml", false); "application/vnd.tmrk.ecloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class); assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
@ -321,10 +345,10 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request,
getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")).replace( Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml"))
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml", .replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
false); "application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
@ -342,10 +366,10 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose( assertPayloadEquals(request,
getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")).replace( Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml"))
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml", .replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
false); "application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
assertExceptionParserClassEquals(method, null); assertExceptionParserClassEquals(method, null);
@ -355,8 +379,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException { public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class); Method method = TerremarkECloudAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair"); URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.keysList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.keysList+xml\n");
@ -455,8 +479,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException { public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class); Method method = TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.keysList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.keysList+xml\n");
@ -575,8 +599,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
@Override @Override
public ReferenceType apply(ReferenceType from) { public ReferenceType apply(ReferenceType from) {
return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from
.getHref().toASCIIString() .getHref().toASCIIString() + "/keysList"));
+ "/keysList"));
} }
}); });
} }
@ -591,17 +614,21 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
@Override @Override
public Map<String, Org> get() { public Map<String, Org> get() {
return ImmutableMap.<String, Org> of("org", new TerremarkOrgImpl("org", null, URI return ImmutableMap.<String, Org> of(
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap "org",
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog", new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"),
TerremarkECloudMediaType.CATALOG_XML, URI null, ImmutableMap.<String, ReferenceType> of(
"catalog",
new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, .<String, ReferenceType> of(
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap "vdc",
new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList", .<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
TerremarkECloudMediaType.TASKSLIST_XML, URI TerremarkECloudMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), new ReferenceTypeImpl( .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")),
"keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI new ReferenceTypeImpl("keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1"))));
} }
} }
@ -664,12 +691,16 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() { public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org", return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new TerremarkVDCImpl("vdc", null, URI ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description", "vdc",
ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED, new Capacity("MB", 0, 0, 0, 0), new Capacity( new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
"MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), ImmutableMap.<String, ReferenceType> of( VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED,
"vapp", new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), "network", ImmutableMap.<String, ReferenceType> of(
"vapp",
new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")),
"network",
new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap
.<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", .<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog",

View File

@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
import org.jclouds.vcloud.CommonVCloudClient; import org.jclouds.vcloud.CommonVCloudClient;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier;
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier; import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.domain.AllocationModel; import org.jclouds.vcloud.domain.AllocationModel;
import org.jclouds.vcloud.domain.Capacity; import org.jclouds.vcloud.domain.Capacity;
import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.Catalog;
@ -62,6 +62,7 @@ import org.jclouds.vcloud.domain.VDCStatus;
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.domain.network.NetworkConfig;
import org.jclouds.vcloud.filters.SetVCloudTokenCookie; import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
import org.jclouds.vcloud.terremark.config.TerremarkVCloudExpressRestClientModule; import org.jclouds.vcloud.terremark.config.TerremarkVCloudExpressRestClientModule;
import org.jclouds.vcloud.terremark.domain.Protocol; import org.jclouds.vcloud.terremark.domain.Protocol;
@ -104,8 +105,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException { public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class); Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
@ -118,6 +119,22 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
checkFilters(request); checkFilters(request);
} }
public void testDelete() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("deleteVApp", URI.class);
HttpRequest request = processor.createRequest(method,
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseTaskFromLocationHeader.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException { public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed",
String.class, String.class, String.class); String.class, String.class, String.class);
@ -170,14 +187,16 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException { public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class,
URI.class, String.class, InstantiateVAppTemplateOptions[].class); URI.class, String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
"name"); "name");
assertRequestLineEquals(request, assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/InstantiateVAppTemplateParams-test.xml")), "/terremark/InstantiateVAppTemplateParams-test.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
@ -192,16 +211,21 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
IOException { IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class,
URI.class, String.class, InstantiateVAppTemplateOptions[].class); URI.class, String.class, InstantiateVAppTemplateOptions[].class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"), method,
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group") URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
.withPassword("password").inRow("row").addNetworkConfig( URI.create("https://vcloud/vAppTemplate/3"),
new NetworkConfig(URI.create("http://network")))); "name",
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
.withPassword("password").inRow("row")
.addNetworkConfig(new NetworkConfig(URI.create("http://network"))));
assertRequestLineEquals(request, assertRequestLineEquals(request,
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1"); "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/InstantiateVAppTemplateParams-options-test.xml")), "/terremark/InstantiateVAppTemplateParams-options-test.xml")),
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false); "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
@ -215,13 +239,14 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testAddInternetService() throws SecurityException, NoSuchMethodException, IOException { public void testAddInternetService() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class, Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class,
String.class, Protocol.class, int.class, AddInternetServiceOptions[].class); String.class, Protocol.class, int.class, AddInternetServiceOptions[].class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22); URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22);
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(request,
"/terremark/CreateInternetService-test2.xml")), "application/vnd.tmrk.vCloud.internetService+xml", false); Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")),
"application/vnd.tmrk.vCloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class); assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
@ -239,7 +264,9 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/CreateInternetService-options-test.xml")), "/terremark/CreateInternetService-options-test.xml")),
"application/vnd.tmrk.vCloud.internetService+xml", false); "application/vnd.tmrk.vCloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -251,8 +278,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException { public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class); Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/internetServices/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetServicesList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetServicesList+xml\n");
@ -303,8 +330,9 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(request,
"/terremark/CreateInternetService-test2.xml")), "application/vnd.tmrk.vCloud.internetService+xml", false); Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")),
"application/vnd.tmrk.vCloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, InternetServiceHandler.class); assertSaxResponseParserClassEquals(method, InternetServiceHandler.class);
@ -321,7 +349,9 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/publicIp/12/internetServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(
request,
Strings2.toStringAndClose(getClass().getResourceAsStream(
"/terremark/CreateInternetService-options-test.xml")), "/terremark/CreateInternetService-options-test.xml")),
"application/vnd.tmrk.vCloud.internetService+xml", false); "application/vnd.tmrk.vCloud.internetService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
@ -339,8 +369,9 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(request,
"/terremark/CreateNodeService-test2.xml")), "application/vnd.tmrk.vCloud.nodeService+xml", false); Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")),
"application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
@ -358,8 +389,9 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1"); assertRequestLineEquals(request, "POST https://vcloud/extensions/internetService/12/nodeServices HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream( assertPayloadEquals(request,
"/terremark/CreateNodeService-options-test.xml")), "application/vnd.tmrk.vCloud.nodeService+xml", false); Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")),
"application/vnd.tmrk.vCloud.nodeService+xml", false);
assertResponseParserClassEquals(method, request, ParseSax.class); assertResponseParserClassEquals(method, request, ParseSax.class);
assertSaxResponseParserClassEquals(method, NodeHandler.class); assertSaxResponseParserClassEquals(method, NodeHandler.class);
assertExceptionParserClassEquals(method, null); assertExceptionParserClassEquals(method, null);
@ -369,8 +401,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException { public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class); Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair"); URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair");
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n");
@ -453,8 +485,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testGetCustomizationOptionsOfCatalogItem() throws SecurityException, NoSuchMethodException, IOException { public void testGetCustomizationOptionsOfCatalogItem() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCustomizationOptions", URI.class); Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCustomizationOptions", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud/extensions/template/12/options/customization")); URI.create("https://vcloud/extensions/template/12/options/customization"));
assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12/options/customization HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12/options/customization HTTP/1.1");
assertNonPayloadHeadersEqual(request, assertNonPayloadHeadersEqual(request,
@ -470,8 +502,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException { public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException {
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class); Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class);
HttpRequest request = processor.createRequest(method, URI HttpRequest request = processor.createRequest(method,
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")); URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1"); assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/keysList/1 HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n"); assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n");
@ -676,18 +708,21 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
@Override @Override
public Map<String, Org> get() { public Map<String, Org> get() {
return ImmutableMap.<String, Org> of("org", new TerremarkOrgImpl("org", null, URI return ImmutableMap.<String, Org> of(
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap "org",
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog", new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"),
TerremarkVCloudExpressMediaType.CATALOG_XML, URI null, ImmutableMap.<String, ReferenceType> of(
"catalog",
new ReferenceTypeImpl("catalog", TerremarkVCloudExpressMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", .<String, ReferenceType> of(
TerremarkVCloudExpressMediaType.VDC_XML, URI "vdc",
new ReferenceTypeImpl("vdc", TerremarkVCloudExpressMediaType.VDC_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList", .<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), new ReferenceTypeImpl( .create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")),
"keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1")))); .create("https://vcloud.safesecureweb.com/api/v0.8/keysList/1"))));
} }
} }
@ -703,13 +738,16 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() { public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org", return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new TerremarkVDCImpl("vdc", null, URI ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description", "vdc",
ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED, new Capacity("MB", 0, 0, 0, 0), new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED,
ImmutableMap.<String, ReferenceType> of("vapp", new ReferenceTypeImpl("vapp", new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
"application/vnd.vmware.vcloud.vApp+xml", URI ImmutableMap.<String, ReferenceType> of(
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")), "network", "vapp",
new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")),
"network",
new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap .create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap
.<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog", .<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog",