mirror of https://github.com/apache/jclouds.git
Issue 536:terremark delete operation now returns tasks
This commit is contained in:
parent
83bed07d79
commit
2b111b2604
|
@ -18,16 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.s3;
|
||||
|
||||
import static java.lang.annotation.ElementType.METHOD;
|
||||
import static java.lang.annotation.ElementType.PARAMETER;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Annotates the parameter that this is a bucket.
|
||||
*/
|
||||
@Target(PARAMETER)
|
||||
@Target({ PARAMETER, METHOD })
|
||||
@Retention(RUNTIME)
|
||||
@Qualifier
|
||||
public @interface Bucket {
|
||||
}
|
||||
|
|
|
@ -33,6 +33,28 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
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.BindAsHostPrefixIfConfigured;
|
||||
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.LocationConstraintHandler;
|
||||
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.inject.Provides;
|
||||
|
@ -121,7 +123,7 @@ public interface S3AsyncClient {
|
|||
@ExceptionParser(ReturnNullOnKeyNotFound.class)
|
||||
@ResponseParser(ParseObjectFromHeadersAndHttpContent.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -132,7 +134,7 @@ public interface S3AsyncClient {
|
|||
@ExceptionParser(ReturnNullOnKeyNotFound.class)
|
||||
@ResponseParser(ParseObjectMetadataFromHeaders.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -142,7 +144,7 @@ public interface S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ExceptionParser(ReturnFalseOnKeyNotFound.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -152,7 +154,7 @@ public interface S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -162,7 +164,7 @@ public interface S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ResponseParser(ParseETagHeader.class)
|
||||
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,
|
||||
PutObjectOptions... options);
|
||||
|
||||
|
@ -173,9 +175,8 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@ExceptionParser(ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState.class)
|
||||
ListenableFuture<Boolean> putBucketInRegion(
|
||||
// TODO endpoint based on region
|
||||
@BinderParam(BindRegionToXmlPayload.class) @Nullable String region,
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName,
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @BinderParam(BindRegionToXmlPayload.class) @Nullable String region,
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
|
||||
PutBucketOptions... options);
|
||||
|
||||
/**
|
||||
|
@ -185,7 +186,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@ExceptionParser(ReturnTrueOn404OrNotFoundFalseOnIllegalState.class)
|
||||
ListenableFuture<Boolean> deleteBucketIfEmpty(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#bucketExists
|
||||
|
@ -195,7 +196,7 @@ public interface S3AsyncClient {
|
|||
@QueryParams(keys = "max-keys", values = "0")
|
||||
@ExceptionParser(ReturnFalseOnContainerNotFound.class)
|
||||
ListenableFuture<Boolean> bucketExists(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#getBucketLocation
|
||||
|
@ -205,7 +206,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@XMLResponseParser(LocationConstraintHandler.class)
|
||||
ListenableFuture<String> getBucketLocation(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#getBucketPayer
|
||||
|
@ -215,7 +216,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@XMLResponseParser(PayerHandler.class)
|
||||
ListenableFuture<Payer> getBucketPayer(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#setBucketPayer
|
||||
|
@ -224,7 +225,7 @@ public interface S3AsyncClient {
|
|||
@QueryParams(keys = "requestPayment")
|
||||
@Path("/")
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -234,7 +235,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@XMLResponseParser(ListBucketHandler.class)
|
||||
ListenableFuture<ListBucketResponse> listBucket(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName,
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
|
||||
ListBucketOptions... options);
|
||||
|
||||
/**
|
||||
|
@ -256,7 +257,7 @@ public interface S3AsyncClient {
|
|||
ListenableFuture<ObjectMetadata> copyObject(
|
||||
@PathParam("sourceBucket") String sourceBucket,
|
||||
@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);
|
||||
|
||||
/**
|
||||
|
@ -268,7 +269,7 @@ public interface S3AsyncClient {
|
|||
@ExceptionParser(ThrowContainerNotFoundOn404.class)
|
||||
@Path("/")
|
||||
ListenableFuture<AccessControlList> getBucketACL(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#putBucketACL
|
||||
|
@ -277,7 +278,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@QueryParams(keys = "acl")
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -289,7 +290,7 @@ public interface S3AsyncClient {
|
|||
@XMLResponseParser(AccessControlListHandler.class)
|
||||
@ExceptionParser(ThrowKeyNotFoundOn404.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -299,9 +300,8 @@ public interface S3AsyncClient {
|
|||
@QueryParams(keys = "acl")
|
||||
@Path("/{key}")
|
||||
ListenableFuture<Boolean> putObjectACL(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName,
|
||||
@PathParam("key") String key,
|
||||
@BinderParam(BindACLToXMLPayload.class) AccessControlList acl);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName,
|
||||
@PathParam("key") String key, @BinderParam(BindACLToXMLPayload.class) AccessControlList acl);
|
||||
|
||||
/**
|
||||
* @see S3Client#getBucketLogging
|
||||
|
@ -312,7 +312,7 @@ public interface S3AsyncClient {
|
|||
@ExceptionParser(ThrowContainerNotFoundOn404.class)
|
||||
@Path("/")
|
||||
ListenableFuture<BucketLogging> getBucketLogging(
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
/**
|
||||
* @see S3Client#enableBucketLogging
|
||||
|
@ -321,7 +321,7 @@ public interface S3AsyncClient {
|
|||
@Path("/")
|
||||
@QueryParams(keys = "logging")
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -332,6 +332,6 @@ public interface S3AsyncClient {
|
|||
@QueryParams(keys = "logging")
|
||||
@Produces(MediaType.TEXT_XML)
|
||||
ListenableFuture<Void> disableBucketLogging(
|
||||
@Bucket @BinderParam(BindNoBucketLoggingToXmlPayload.class) @ParamValidators( { BucketNameValidator.class }) String bucketName);
|
||||
@Bucket @BinderParam(BindNoBucketLoggingToXmlPayload.class) @ParamValidators({ BucketNameValidator.class }) String bucketName);
|
||||
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ import com.google.common.collect.Maps;
|
|||
@Singleton
|
||||
public class BindAsHostPrefixIfConfigured implements Binder {
|
||||
|
||||
private final Provider<UriBuilder> uriBuilderProvider;
|
||||
private final BindAsHostPrefix bindAsHostPrefix;
|
||||
private final boolean isVhostStyle;
|
||||
private final String servicePath;
|
||||
protected final Provider<UriBuilder> uriBuilderProvider;
|
||||
protected final BindAsHostPrefix bindAsHostPrefix;
|
||||
protected final boolean isVhostStyle;
|
||||
protected final String servicePath;
|
||||
|
||||
@Inject
|
||||
public BindAsHostPrefixIfConfigured(BindAsHostPrefix bindAsHostPrefix,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.s3.config;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
@ -34,6 +35,7 @@ import org.jclouds.http.annotation.Redirection;
|
|||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RequestSigner;
|
||||
import org.jclouds.s3.Bucket;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
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.Suppliers;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Scopes;
|
||||
|
||||
|
@ -60,6 +63,13 @@ public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> ext
|
|||
super(sync, async);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Bucket
|
||||
@Singleton
|
||||
protected Map<String, String> bucketToRegion() {
|
||||
return Maps.newConcurrentMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new S3ObjectModule());
|
||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.s3.functions;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
|
@ -20,8 +20,15 @@ package org.jclouds.s3.xml;
|
|||
|
||||
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.http.HttpRequest;
|
||||
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
|
||||
|
@ -32,8 +39,15 @@ import org.jclouds.http.functions.ParseSax;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String> {
|
||||
private final ConcurrentMap<String, String> bucketToRegion;
|
||||
private StringBuilder currentText = new StringBuilder();
|
||||
private String region;
|
||||
private String bucket;
|
||||
|
||||
@Inject
|
||||
public LocationConstraintHandler(@Bucket ConcurrentMap<String, String> bucketToRegion) {
|
||||
this.bucketToRegion = bucketToRegion;
|
||||
}
|
||||
|
||||
public String getResult() {
|
||||
return region;
|
||||
|
@ -41,6 +55,18 @@ public class LocationConstraintHandler extends ParseSax.HandlerWithResult<String
|
|||
|
||||
public void endElement(String uri, String name, String qName) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,12 +37,12 @@ import org.jclouds.predicates.validators.DnsNameValidator;
|
|||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.ParamValidators;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.vcloud.binders.BindCloneVAppParamsToXmlPayload;
|
||||
import org.jclouds.vcloud.binders.BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload;
|
||||
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.functions.OrgNameCatalogNameVAppTemplateNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameVDCNameResourceEntityNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.OrgNetworkFromVCloudExpressNetworkHandler;
|
||||
|
@ -164,7 +165,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends VCloudExpressVApp> getVApp(@EndpointParam URI vApp);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#deployVApp
|
||||
* @see VCloudExpressClient#deployVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -173,7 +174,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> deployVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#undeployVApp
|
||||
* @see VCloudExpressClient#undeployVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -182,7 +183,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> undeployVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#powerOnVApp
|
||||
* @see VCloudExpressClient#powerOnVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -191,7 +192,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> powerOnVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#powerOffVApp
|
||||
* @see VCloudExpressClient#powerOffVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -200,14 +201,14 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> powerOffVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#shutdownVApp
|
||||
* @see VCloudExpressClient#shutdownVApp
|
||||
*/
|
||||
@POST
|
||||
@Path("/power/action/shutdown")
|
||||
ListenableFuture<Void> shutdownVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#resetVApp
|
||||
* @see VCloudExpressClient#resetVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -216,7 +217,7 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> resetVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#suspendVApp
|
||||
* @see VCloudExpressClient#suspendVApp
|
||||
*/
|
||||
@POST
|
||||
@Consumes(TASK_XML)
|
||||
|
@ -225,10 +226,10 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
|
|||
ListenableFuture<? extends Task> suspendVApp(@EndpointParam URI vAppId);
|
||||
|
||||
/**
|
||||
* @see CommonVCloudClient#deleteVApp
|
||||
* @see VCloudExpressClient#deleteVApp
|
||||
*/
|
||||
@DELETE
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> deleteVApp(@EndpointParam URI vAppId);
|
||||
|
||||
@ResponseParser(ParseTaskFromLocationHeader.class)
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Task> deleteVApp(@EndpointParam URI vAppId);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,6 @@ public interface VCloudExpressClient extends CommonVCloudClient {
|
|||
*/
|
||||
Task suspendVApp(URI vAppId);
|
||||
|
||||
void deleteVApp(URI vAppId);
|
||||
Task deleteVApp(URI vAppId);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import javax.inject.Inject;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OperatingSystemBuilder;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.compute.util.ComputeServiceUtils;
|
||||
|
||||
|
@ -51,7 +50,7 @@ public class ParseOsFromVAppTemplateName implements Function<String, OperatingSy
|
|||
|
||||
@Override
|
||||
public OperatingSystem apply(String from) {
|
||||
OperatingSystemBuilder builder = new OperatingSystemBuilder();
|
||||
OperatingSystem.Builder builder = OperatingSystem.builder();
|
||||
OsFamily osFamily = parseOsFamilyOrUnrecognized(checkNotNull(from, "vapp template name"));
|
||||
builder.family(osFamily);
|
||||
builder.description(from);
|
||||
|
|
|
@ -60,7 +60,10 @@ public class VCloudExpressComputeClientImpl extends
|
|||
@Override
|
||||
protected void deleteVApp(VCloudExpressVApp vApp) {
|
||||
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
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.vcloud.terremark.functions;
|
||||
|
||||
package org.jclouds.vcloud.functions;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
|
@ -44,7 +44,6 @@ import org.jclouds.rest.RestClientTest;
|
|||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.util.Strings2;
|
||||
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.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
|
||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||
|
@ -500,9 +500,9 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
assertResponseParserClassEquals(method, request, ParseTaskFromLocationHeader.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(request);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@ import org.jclouds.predicates.validators.DnsNameValidator;
|
|||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.ParamValidators;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
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.OrgNameCatalogNameItemNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.OrgNameToEndpoint;
|
||||
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.binders.BindNodeConfigurationToXmlPayload;
|
||||
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.TerremarkVDC;
|
||||
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.VDCURIToInternetServicesEndpoint;
|
||||
import org.jclouds.vcloud.terremark.functions.VDCURIToPublicIPsEndpoint;
|
||||
|
|
|
@ -177,4 +177,5 @@ public interface TerremarkVCloudClient extends VCloudExpressClient {
|
|||
// keyPairConfiguration);
|
||||
|
||||
void deleteKeyPair(URI keyPair);
|
||||
|
||||
}
|
|
@ -24,9 +24,9 @@ import static org.jclouds.vcloud.terremark.options.AddInternetServiceOptions.Bui
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
@ -142,12 +142,16 @@ public class TerremarkVCloudComputeClient extends VCloudExpressComputeClientImpl
|
|||
|
||||
} else {
|
||||
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(),
|
||||
vApp.getName())));
|
||||
}
|
||||
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(), is
|
||||
.getProtocol(), is.getPort());
|
||||
logger.debug("<< created InternetService(%s) %s:%s:%d", is.getName(), is.getPublicIpAddress().getAddress(),
|
||||
is.getProtocol(), is.getPort());
|
||||
logger.debug(">> adding Node %s:%d -> %s:%d", is.getPublicIpAddress().getAddress(), is.getPort(),
|
||||
privateAddress, port);
|
||||
Node node = client.addNode(is.getId(), privateAddress, vApp.getName() + "-" + port, port);
|
||||
|
|
|
@ -20,8 +20,10 @@ package org.jclouds.json.config;
|
|||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -33,6 +35,8 @@ import org.jclouds.json.Json;
|
|||
import org.jclouds.json.internal.EnumTypeAdapterThatReturnsFromValue;
|
||||
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.primitives.Bytes;
|
||||
import com.google.gson.Gson;
|
||||
|
@ -51,6 +55,7 @@ import com.google.gson.reflect.TypeToken;
|
|||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.ImplementedBy;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Contains logic for parsing objects from Strings.
|
||||
|
@ -63,13 +68,15 @@ public class GsonModule extends AbstractModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
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();
|
||||
JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Enum.class,
|
||||
new EnumTypeAdapterThatReturnsFromValue());
|
||||
JcloudsGsonPackageAccessor.registerTypeHierarchyAdapter(builder, Map.class, new MapTypeAdapter());
|
||||
builder.registerTypeAdapter(JsonBall.class, jsonAdapter);
|
||||
builder.registerTypeAdapter(Date.class, adapter);
|
||||
builder.registerTypeAdapter(Properties.class, propertiesAdapter);
|
||||
builder.registerTypeAdapter(new TypeToken<List<Byte>>() {
|
||||
}.getType(), byteListAdapter);
|
||||
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
|
||||
public static class CDateAdapter implements DateAdapter {
|
||||
private final DateService dateService;
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.json;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -44,6 +45,19 @@ public class JsonTest {
|
|||
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() {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
map.put("string", "string");
|
||||
|
|
|
@ -18,29 +18,13 @@
|
|||
*/
|
||||
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 java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -56,6 +40,7 @@ import org.jclouds.blobstore.attr.BlobScope;
|
|||
import org.jclouds.http.functions.ParseETagHeader;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.ParamParser;
|
||||
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.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.XMLResponseParser;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.s3.Bucket;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
|
||||
import org.jclouds.s3.domain.ObjectMetadata;
|
||||
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.predicates.validators.BucketNameValidator;
|
||||
import org.jclouds.s3.xml.LocationConstraintHandler;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
|
@ -83,6 +74,31 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
@RequestFilters(RequestAuthorizeSignature.class)
|
||||
@BlobScope(CONTAINER)
|
||||
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
|
||||
*/
|
||||
|
@ -91,7 +107,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ResponseParser(UploadIdFromHttpResponseViaRegex.class)
|
||||
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,
|
||||
PutObjectOptions... options);
|
||||
|
||||
|
@ -102,7 +118,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
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);
|
||||
|
||||
/**
|
||||
|
@ -112,7 +128,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ResponseParser(ParseETagHeader.class)
|
||||
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,
|
||||
@QueryParam("uploadId") String uploadId, Payload part);
|
||||
|
||||
|
@ -123,7 +139,7 @@ public interface AWSS3AsyncClient extends S3AsyncClient {
|
|||
@Path("/{key}")
|
||||
@ResponseParser(ETagFromHttpResponseViaRegex.class)
|
||||
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,
|
||||
@BinderParam(BindPartIdsAndETagsToRequest.class) Map<Integer, String> parts);
|
||||
|
||||
|
|
|
@ -18,14 +18,24 @@
|
|||
*/
|
||||
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 org.jclouds.aws.s3.AWSS3AsyncClient;
|
||||
import org.jclouds.aws.s3.AWSS3Client;
|
||||
import org.jclouds.aws.s3.binders.AssignCorrectHostnameAndBindAsHostPrefixIfConfigured;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.s3.Bucket;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.binders.BindAsHostPrefixIfConfigured;
|
||||
import org.jclouds.s3.config.S3RestClientModule;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
@ -39,6 +49,19 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
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() {
|
||||
super(AWSS3Client.class, AWSS3AsyncClient.class);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,10 @@ package org.jclouds.aws.s3;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.jclouds.aws.s3.config.AWSS3RestClientModule;
|
||||
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.RequiresHttp;
|
||||
import org.jclouds.http.functions.ParseETagHeader;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||
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.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.domain.ObjectMetadata;
|
||||
import org.jclouds.s3.domain.ObjectMetadataBuilder;
|
||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
||||
import org.jclouds.s3.options.PutBucketOptions;
|
||||
import org.jclouds.s3.options.PutObjectOptions;
|
||||
import org.jclouds.s3.xml.LocationConstraintHandler;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -63,6 +69,21 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
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
|
||||
protected TypeLiteral<RestAnnotationProcessor<AWSS3AsyncClient>> createTypeLiteral() {
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request,
|
||||
"Authorization: AWS identity:Sp1FX4svL9P2u2bFJwroaYpSANo=\nContent-MD5: AQIDBA==\n"
|
||||
+ "Content-Type: binary/octet-stream\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket." + url
|
||||
+ "\n");
|
||||
+ "Content-Type: binary/octet-stream\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket." + url + "\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
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 {
|
||||
Method method = AWSS3AsyncClient.class
|
||||
.getMethod("abortMultipartUpload", String.class, String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", 1, Payloads
|
||||
.newStringPayload(""));
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", 1,
|
||||
Payloads.newStringPayload(""));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1");
|
||||
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 {
|
||||
Method method = AWSS3AsyncClient.class.getMethod("uploadPart", String.class, String.class, int.class,
|
||||
String.class, Payload.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", 1, "asdsadasdas", Payloads
|
||||
.newStringPayload(""));
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", 1, "asdsadasdas",
|
||||
Payloads.newStringPayload(""));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/foo?partNumber=1&uploadId=asdsadasdas HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -142,8 +162,8 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
NoSuchMethodException {
|
||||
Method method = AWSS3AsyncClient.class.getMethod("completeMultipartUpload", String.class, String.class,
|
||||
String.class, Map.class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas", ImmutableMap
|
||||
.<Integer, String> of(1, "\"a54357aff0632cce46d942af68356b38\""));
|
||||
HttpRequest request = processor.createRequest(method, "bucket", "foo", "asdsadasdas",
|
||||
ImmutableMap.<Integer, String> of(1, "\"a54357aff0632cce46d942af68356b38\""));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://bucket." + url + "/foo?uploadId=asdsadasdas HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
|
@ -186,6 +206,18 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
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
|
||||
protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
|
||||
return "2009-11-08T15:54:08.897Z";
|
||||
|
|
|
@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.jclouds.vcloud.CommonVCloudClient;
|
||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier;
|
||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.config.CommonVCloudRestClientModule.OrgVDCSupplier;
|
||||
import org.jclouds.vcloud.domain.AllocationModel;
|
||||
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.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.config.TerremarkECloudRestClientModule;
|
||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||
|
@ -104,8 +105,8 @@ import com.google.inject.TypeLiteral;
|
|||
public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkECloudAsyncClient> {
|
||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||
|
@ -118,6 +119,22 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
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 {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("findNetworkInOrgVDCNamed", String.class,
|
||||
String.class, String.class);
|
||||
|
@ -170,14 +187,16 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"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");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
|
@ -192,16 +211,21 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
IOException {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row").addNetworkConfig(
|
||||
new NetworkConfig(URI.create("http://network"))));
|
||||
HttpRequest request = processor.createRequest(
|
||||
method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name",
|
||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row")
|
||||
.addNetworkConfig(new NetworkConfig(URI.create("http://network"))));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"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");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
|
@ -214,8 +238,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
|
||||
public void testActivatePublicIpInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("activatePublicIpInVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
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 {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(
|
||||
getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")).replace(
|
||||
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml"))
|
||||
.replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
"application/vnd.tmrk.ecloud.internetService+xml", false);
|
||||
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.internetService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(
|
||||
getClass().getResourceAsStream("/CreateInternetService-options-test.xml")).replace(
|
||||
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/CreateInternetService-options-test.xml"))
|
||||
.replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
"application/vnd.tmrk.ecloud.internetService+xml", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(
|
||||
getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")).replace(
|
||||
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml",
|
||||
false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml"))
|
||||
.replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
"application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
||||
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(
|
||||
getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")).replace(
|
||||
"vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"), "application/vnd.tmrk.vCloud.nodeService+xml",
|
||||
false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml"))
|
||||
.replace("vCloudExpressExtensions-1.6", "eCloudExtensions-2.7"),
|
||||
"application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
@ -355,8 +379,8 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
|
||||
public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair");
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
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 {
|
||||
Method method = TerremarkECloudAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.ecloud.keysList+xml\n");
|
||||
|
@ -575,8 +599,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
@Override
|
||||
public ReferenceType apply(ReferenceType from) {
|
||||
return new ReferenceTypeImpl(from.getName(), TerremarkECloudMediaType.KEYSLIST_XML, URI.create(from
|
||||
.getHref().toASCIIString()
|
||||
+ "/keysList"));
|
||||
.getHref().toASCIIString() + "/keysList"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -591,17 +614,21 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
|
|||
|
||||
@Override
|
||||
public Map<String, Org> get() {
|
||||
return ImmutableMap.<String, Org> of("org", new TerremarkOrgImpl("org", null, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap
|
||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog",
|
||||
TerremarkECloudMediaType.CATALOG_XML, URI
|
||||
return ImmutableMap.<String, Org> of(
|
||||
"org",
|
||||
new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"),
|
||||
null, ImmutableMap.<String, ReferenceType> of(
|
||||
"catalog",
|
||||
new ReferenceTypeImpl("catalog", TerremarkECloudMediaType.CATALOG_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", TerremarkECloudMediaType.VDC_XML,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(
|
||||
"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",
|
||||
TerremarkECloudMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), new ReferenceTypeImpl(
|
||||
"keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")),
|
||||
new ReferenceTypeImpl("keysList", TerremarkECloudMediaType.KEYSLIST_XML, URI
|
||||
.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() {
|
||||
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
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description",
|
||||
ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED, new Capacity("MB", 0, 0, 0, 0), new Capacity(
|
||||
"MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), 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",
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||
"vdc",
|
||||
new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED,
|
||||
new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
|
||||
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
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap
|
||||
.<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog",
|
||||
|
|
|
@ -48,9 +48,9 @@ import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.jclouds.vcloud.CommonVCloudClient;
|
||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogItemSupplier;
|
||||
import org.jclouds.vcloud.VCloudExpressAsyncClientTest.VCloudRestClientModuleExtension.TestOrgCatalogSupplier;
|
||||
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
|
||||
import org.jclouds.vcloud.domain.AllocationModel;
|
||||
import org.jclouds.vcloud.domain.Capacity;
|
||||
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.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.filters.SetVCloudTokenCookie;
|
||||
import org.jclouds.vcloud.functions.ParseTaskFromLocationHeader;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.vcloud.terremark.config.TerremarkVCloudExpressRestClientModule;
|
||||
import org.jclouds.vcloud.terremark.domain.Protocol;
|
||||
|
@ -104,8 +105,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||
|
@ -118,6 +119,22 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
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 {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed",
|
||||
String.class, String.class, String.class);
|
||||
|
@ -170,14 +187,16 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class,
|
||||
URI.class, String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"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");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-test.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
|
@ -192,16 +211,21 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class,
|
||||
URI.class, String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name", TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row").addNetworkConfig(
|
||||
new NetworkConfig(URI.create("http://network"))));
|
||||
HttpRequest request = processor.createRequest(
|
||||
method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud/vAppTemplate/3"),
|
||||
"name",
|
||||
TerremarkInstantiateVAppTemplateOptions.Builder.processorCount(2).memory(512).inGroup("group")
|
||||
.withPassword("password").inRow("row")
|
||||
.addNetworkConfig(new NetworkConfig(URI.create("http://network"))));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"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");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
assertPayloadEquals(
|
||||
request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/InstantiateVAppTemplateParams-options-test.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
|
@ -215,13 +239,14 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
public void testAddInternetService() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("addInternetServiceToVDC", URI.class,
|
||||
String.class, Protocol.class, int.class, AddInternetServiceOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "name", Protocol.TCP, 22);
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")), "application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")),
|
||||
"application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.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");
|
||||
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")),
|
||||
"application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
|
@ -251,8 +278,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
public void testGetAllInternetServices() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getAllInternetServicesInVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.internetService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateInternetService-test2.xml")), "application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateInternetService-test2.xml")),
|
||||
"application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.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");
|
||||
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")),
|
||||
"application/vnd.tmrk.vCloud.internetService+xml", false);
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService-test2.xml")), "application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-test2.xml")),
|
||||
"application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vCloud.nodeService+xml\n");
|
||||
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/terremark/CreateNodeService-options-test.xml")), "application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/terremark/CreateNodeService-options-test.xml")),
|
||||
"application/vnd.tmrk.vCloud.nodeService+xml", false);
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, NodeHandler.class);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
@ -369,8 +401,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
public void testGetKeyPairInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("findKeyPairInOrg", URI.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "keyPair");
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
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 {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("getCustomizationOptions", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud/extensions/template/12/options/customization"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud/extensions/template/12/options/customization"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud/extensions/template/12/options/customization HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request,
|
||||
|
@ -470,8 +502,8 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
public void testListKeyPairsInOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = TerremarkVCloudExpressAsyncClient.class.getMethod("listKeyPairsInOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
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");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.tmrk.vcloudExpress.keysList+xml\n");
|
||||
|
@ -676,18 +708,21 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
|
|||
|
||||
@Override
|
||||
public Map<String, Org> get() {
|
||||
return ImmutableMap.<String, Org> of("org", new TerremarkOrgImpl("org", null, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap
|
||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog",
|
||||
TerremarkVCloudExpressMediaType.CATALOG_XML, URI
|
||||
return ImmutableMap.<String, Org> of(
|
||||
"org",
|
||||
new TerremarkOrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"),
|
||||
null, ImmutableMap.<String, ReferenceType> of(
|
||||
"catalog",
|
||||
new ReferenceTypeImpl("catalog", TerremarkVCloudExpressMediaType.CATALOG_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc",
|
||||
TerremarkVCloudExpressMediaType.VDC_XML, URI
|
||||
.<String, ReferenceType> of(
|
||||
"vdc",
|
||||
new ReferenceTypeImpl("vdc", TerremarkVCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
|
||||
TerremarkVCloudExpressMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), new ReferenceTypeImpl(
|
||||
"keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")),
|
||||
new ReferenceTypeImpl("keysList", TerremarkVCloudExpressMediaType.KEYSLIST_XML, URI
|
||||
.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() {
|
||||
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
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), VDCStatus.READY, null, "description",
|
||||
ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED, new Capacity("MB", 0, 0, 0, 0),
|
||||
new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
|
||||
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",
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||
"vdc",
|
||||
new TerremarkVDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.UNRECOGNIZED,
|
||||
new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0), new Capacity("MB", 0, 0, 0, 0),
|
||||
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
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), ImmutableMap
|
||||
.<String, ReferenceType> of(), 0, 0, 0, false, new ReferenceTypeImpl("catalog",
|
||||
|
|
Loading…
Reference in New Issue