Issue 125:payload binder

This commit is contained in:
Adrian Cole 2011-02-14 15:17:19 +01:00
parent 37fc5505ff
commit 4627a91195
17 changed files with 160 additions and 270 deletions

View File

@ -59,7 +59,7 @@ import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Endpoint;
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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.annotations.SkipEncoding;
@ -162,8 +162,8 @@ public interface CloudServersAsyncClient {
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/servers") @Path("/servers")
@MapBinder(CreateServerOptions.class) @MapBinder(CreateServerOptions.class)
ListenableFuture<Server> createServer(@MapPayloadParam("name") String name, @MapPayloadParam("imageId") int imageId, ListenableFuture<Server> createServer(@PayloadParam("name") String name, @PayloadParam("imageId") int imageId,
@MapPayloadParam("flavorId") int flavorId, CreateServerOptions... options); @PayloadParam("flavorId") int flavorId, CreateServerOptions... options);
/** /**
* @see CloudServersClient#rebuildServer * @see CloudServersClient#rebuildServer
@ -181,8 +181,8 @@ public interface CloudServersAsyncClient {
@Path("/servers/{id}/ips/public/{address}") @Path("/servers/{id}/ips/public/{address}")
@MapBinder(BindSharedIpGroupToJsonPayload.class) @MapBinder(BindSharedIpGroupToJsonPayload.class)
ListenableFuture<Void> shareIp(@PathParam("address") String addressToShare, ListenableFuture<Void> shareIp(@PathParam("address") String addressToShare,
@PathParam("id") int serverToTosignBindressTo, @MapPayloadParam("sharedIpGroupId") int sharedIpGroup, @PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup,
@MapPayloadParam("configureServer") boolean configureServer); @PayloadParam("configureServer") boolean configureServer);
/** /**
* @see CloudServersClient#unshareIp * @see CloudServersClient#unshareIp
@ -270,8 +270,8 @@ public interface CloudServersAsyncClient {
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@MapBinder(BindCreateImageToJsonPayload.class) @MapBinder(BindCreateImageToJsonPayload.class)
@Path("/images") @Path("/images")
ListenableFuture<Image> createImageFromServer(@MapPayloadParam("imageName") String imageName, ListenableFuture<Image> createImageFromServer(@PayloadParam("imageName") String imageName,
@MapPayloadParam("serverId") int serverId); @PayloadParam("serverId") int serverId);
/** /**
* @see CloudServersClient#listSharedIpGroups * @see CloudServersClient#listSharedIpGroups
@ -304,7 +304,7 @@ public interface CloudServersAsyncClient {
@QueryParams(keys = "format", values = "json") @QueryParams(keys = "format", values = "json")
@Path("/shared_ip_groups") @Path("/shared_ip_groups")
@MapBinder(CreateSharedIpGroupOptions.class) @MapBinder(CreateSharedIpGroupOptions.class)
ListenableFuture<SharedIpGroup> createSharedIpGroup(@MapPayloadParam("name") String name, ListenableFuture<SharedIpGroup> createSharedIpGroup(@PayloadParam("name") String name,
CreateSharedIpGroupOptions... options); CreateSharedIpGroupOptions... options);
/** /**

View File

@ -47,8 +47,8 @@ import org.jclouds.rest.annotations.Endpoint;
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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.MapPayloadParams; import org.jclouds.rest.annotations.PayloadParams;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
@ -154,8 +154,8 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@XMLResponseParser(VAppHandler.class) @XMLResponseParser(VAppHandler.class)
@MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class) @MapBinder(BindInstantiateVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends VApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc, ListenableFuture<? extends VApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc,
@MapPayloadParam("template") URI template, @PayloadParam("template") URI template,
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
InstantiateVAppTemplateOptions... options); InstantiateVAppTemplateOptions... options);
/** /**
@ -167,8 +167,8 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@Consumes(TASK_XML) @Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class) @XMLResponseParser(TaskHandler.class)
@MapBinder(BindCloneVAppParamsToXmlPayload.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class)
ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone, ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone,
@MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, @PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppOptions... options); CloneVAppOptions... options);
/** /**
@ -181,8 +181,8 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@XMLResponseParser(VAppTemplateHandler.class) @XMLResponseParser(VAppTemplateHandler.class)
@MapBinder(BindCaptureVAppParamsToXmlPayload.class) @MapBinder(BindCaptureVAppParamsToXmlPayload.class)
ListenableFuture<? extends VAppTemplate> captureVAppInVDC(@EndpointParam URI vdc, ListenableFuture<? extends VAppTemplate> captureVAppInVDC(@EndpointParam URI vdc,
@MapPayloadParam("vApp") URI toCapture, @PayloadParam("vApp") URI toCapture,
@MapPayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName, @PayloadParam("templateName") @ParamValidators(DnsNameValidator.class) String templateName,
CaptureVAppOptions... options); CaptureVAppOptions... options);
/** /**
@ -246,7 +246,7 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@Produces(DEPLOYVAPPPARAMS_XML) @Produces(DEPLOYVAPPPARAMS_XML)
@Path("/action/deploy") @Path("/action/deploy")
@MapBinder(BindDeployVAppParamsToXmlPayload.class) @MapBinder(BindDeployVAppParamsToXmlPayload.class)
@MapPayloadParams(keys = "powerOn", values = "true") @PayloadParams(keys = "powerOn", values = "true")
@XMLResponseParser(TaskHandler.class) @XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> deployAndPowerOnVAppOrVm(@EndpointParam URI vAppOrVmId); ListenableFuture<? extends Task> deployAndPowerOnVAppOrVm(@EndpointParam URI vAppOrVmId);
@ -269,7 +269,7 @@ public interface VCloudAsyncClient extends CommonVCloudAsyncClient {
@Produces(UNDEPLOYVAPPPARAMS_XML) @Produces(UNDEPLOYVAPPPARAMS_XML)
@Path("/action/undeploy") @Path("/action/undeploy")
@MapBinder(BindUndeployVAppParamsToXmlPayload.class) @MapBinder(BindUndeployVAppParamsToXmlPayload.class)
@MapPayloadParams(keys = "saveState", values = "true") @PayloadParams(keys = "saveState", values = "true")
@XMLResponseParser(TaskHandler.class) @XMLResponseParser(TaskHandler.class)
ListenableFuture<? extends Task> undeployAndSaveStateOfVAppOrVm(@EndpointParam URI vAppOrVmId); ListenableFuture<? extends Task> undeployAndSaveStateOfVAppOrVm(@EndpointParam URI vAppOrVmId);

View File

@ -38,7 +38,7 @@ 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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
@ -126,8 +126,8 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
@XMLResponseParser(VCloudExpressVAppHandler.class) @XMLResponseParser(VCloudExpressVAppHandler.class)
@MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class) @MapBinder(BindInstantiateVCloudExpressVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends VCloudExpressVApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc, ListenableFuture<? extends VCloudExpressVApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc,
@MapPayloadParam("template") URI template, @PayloadParam("template") URI template,
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
InstantiateVAppTemplateOptions... options); InstantiateVAppTemplateOptions... options);
/** /**
@ -139,8 +139,8 @@ public interface VCloudExpressAsyncClient extends CommonVCloudAsyncClient {
@Consumes(TASK_XML) @Consumes(TASK_XML)
@XMLResponseParser(TaskHandler.class) @XMLResponseParser(TaskHandler.class)
@MapBinder(BindCloneVAppParamsToXmlPayload.class) @MapBinder(BindCloneVAppParamsToXmlPayload.class)
ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @MapPayloadParam("vApp") URI toClone, ListenableFuture<? extends Task> cloneVAppInVDC(@EndpointParam URI vdc, @PayloadParam("vApp") URI toClone,
@MapPayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName, @PayloadParam("newName") @ParamValidators(DnsNameValidator.class) String newName,
CloneVAppOptions... options); CloneVAppOptions... options);
/** /**

View File

@ -47,7 +47,7 @@ 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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
@ -191,8 +191,8 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
@XMLResponseParser(VCloudExpressVAppHandler.class) @XMLResponseParser(VCloudExpressVAppHandler.class)
@MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class) @MapBinder(TerremarkBindInstantiateVAppTemplateParamsToXmlPayload.class)
ListenableFuture<? extends VCloudExpressVApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc, ListenableFuture<? extends VCloudExpressVApp> instantiateVAppTemplateInVDC(@EndpointParam URI vdc,
@MapPayloadParam("template") URI template, @PayloadParam("template") URI template,
@MapPayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName, @PayloadParam("name") @ParamValidators(DnsNameValidator.class) String appName,
InstantiateVAppTemplateOptions... options); InstantiateVAppTemplateOptions... options);
/** /**
@ -215,8 +215,8 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
@XMLResponseParser(InternetServiceHandler.class) @XMLResponseParser(InternetServiceHandler.class)
@MapBinder(AddInternetServiceOptions.class) @MapBinder(AddInternetServiceOptions.class)
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI publicIpId, ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI publicIpId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol, @PayloadParam("name") String serviceName, @PayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options); @PayloadParam("port") int port, AddInternetServiceOptions... options);
/** /**
* @see TerremarkVCloudExpressClient#deletePublicIp * @see TerremarkVCloudExpressClient#deletePublicIp
@ -280,8 +280,8 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
@XMLResponseParser(NodeHandler.class) @XMLResponseParser(NodeHandler.class)
@MapBinder(AddNodeOptions.class) @MapBinder(AddNodeOptions.class)
ListenableFuture<? extends Node> addNode(@EndpointParam URI internetServiceId, ListenableFuture<? extends Node> addNode(@EndpointParam URI internetServiceId,
@MapPayloadParam("ipAddress") String ipAddress, @MapPayloadParam("name") String name, @PayloadParam("ipAddress") String ipAddress, @PayloadParam("name") String name,
@MapPayloadParam("port") int port, AddNodeOptions... options); @PayloadParam("port") int port, AddNodeOptions... options);
/** /**
* @see TerremarkVCloudExpressClient#getNodes * @see TerremarkVCloudExpressClient#getNodes
@ -310,8 +310,8 @@ public interface TerremarkVCloudAsyncClient extends VCloudExpressAsyncClient {
@Consumes(NODESERVICE_XML) @Consumes(NODESERVICE_XML)
@XMLResponseParser(NodeHandler.class) @XMLResponseParser(NodeHandler.class)
@MapBinder(BindNodeConfigurationToXmlPayload.class) @MapBinder(BindNodeConfigurationToXmlPayload.class)
ListenableFuture<? extends Node> configureNode(@EndpointParam URI nodeId, @MapPayloadParam("name") String name, ListenableFuture<? extends Node> configureNode(@EndpointParam URI nodeId, @PayloadParam("name") String name,
@MapPayloadParam("enabled") boolean enabled, @Nullable @MapPayloadParam("description") String description); @PayloadParam("enabled") boolean enabled, @Nullable @PayloadParam("description") String description);
/** /**
* @see TerremarkVCloudExpressClient#deleteNode * @see TerremarkVCloudExpressClient#deleteNode

View File

@ -34,7 +34,7 @@ public interface MapBinder extends Binder {
/** /**
* creates and binds the POST payload to the request using parameters specified. * creates and binds the POST payload to the request using parameters specified.
* *
* @see org.jclouds.rest.annotations.MapPayloadParam * @see org.jclouds.rest.annotations.PayloadParam
*/ */
<R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams); <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams);
} }

View File

@ -35,7 +35,7 @@ import java.lang.annotation.Target;
public @interface MapBinder { public @interface MapBinder {
/** /**
* How to bind {@link MapPayloadParam} values, if there is no {@link MapBinder} in the method * How to bind {@link PayloadParam} values, if there is no {@link MapBinder} in the method
* definition * definition
*/ */
Class<? extends org.jclouds.rest.MapBinder> value(); Class<? extends org.jclouds.rest.MapBinder> value();

View File

@ -1,41 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.rest.annotations;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Designates that this parameter will hold the payload for a PUT or POST command.
*
* @author Adrian Cole
*/
@Target(PARAMETER)
@Retention(RUNTIME)
public @interface MapPayloadParam {
/**
* The key used in a map passed to the {@link MapBinder} associated with the request.
*/
String value();
}

View File

@ -1,46 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.rest.annotations;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.ws.rs.QueryParam;
/**
* Designates that default parameters will be added a map that builds the request entity.
*
* @see QueryParam
* @author Adrian Cole
*/
@Target( { TYPE, METHOD })
@Retention(RUNTIME)
public @interface MapPayloadParams {
public static final String NULL = "MAP_PAYLOAD_NULL";
String[] keys();
String[] values() default NULL;
}

View File

@ -34,7 +34,6 @@ import org.jclouds.rest.MapBinder;
* Binds the object to the request as a json object. * Binds the object to the request as a json object.
* *
* @author Adrian Cole * @author Adrian Cole
* @since 4.0
*/ */
public class BindToJsonPayload implements MapBinder { public class BindToJsonPayload implements MapBinder {

View File

@ -52,9 +52,9 @@ import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.Map.Entry;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -81,6 +81,7 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.functions.ParseJson; import org.jclouds.http.functions.ParseJson;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnInputStream; import org.jclouds.http.functions.ReturnInputStream;
@ -89,7 +90,6 @@ import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValue;
import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet; import org.jclouds.http.functions.UnwrapOnlyNestedJsonValueInSet;
import org.jclouds.http.functions.ParseSax.HandlerWithResult;
import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.http.options.HttpRequestOptions;
import org.jclouds.http.utils.ModifyRequest; import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.internal.ClassMethodArgs; import org.jclouds.internal.ClassMethodArgs;
@ -112,12 +112,12 @@ import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.FormParams; import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.MapPayloadParam;
import org.jclouds.rest.annotations.MapPayloadParams;
import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.MatrixParams;
import org.jclouds.rest.annotations.OverrideRequestFilters; import org.jclouds.rest.annotations.OverrideRequestFilters;
import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.PartParam; import org.jclouds.rest.annotations.PartParam;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.PayloadParams;
import org.jclouds.rest.annotations.QueryParams; 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;
@ -125,6 +125,7 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.annotations.Unwrap;
import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.binders.BindMapToStringPayload;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.util.Strings2; import org.jclouds.util.Strings2;
@ -168,13 +169,13 @@ public class RestAnnotationProcessor<T> {
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToFormParamAnnotations = createMethodToIndexOfParamToAnnotation(FormParam.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToFormParamAnnotations = createMethodToIndexOfParamToAnnotation(FormParam.class);
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class);
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class);
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(MapPayloadParam.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(PayloadParam.class);
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class); static final Map<Method, Map<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
static final Map<MethodKey, Method> delegationMap = newHashMap(); static final Map<MethodKey, Method> delegationMap = newHashMap();
static Map<Method, Map<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation( static Map<Method, Map<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation(
final Class<? extends Annotation> annotation) { final Class<? extends Annotation> annotation) {
return new MapMaker().makeComputingMap(new Function<Method, Map<Integer, Set<Annotation>>>() { return new MapMaker().makeComputingMap(new Function<Method, Map<Integer, Set<Annotation>>>() {
public Map<Integer, Set<Annotation>> apply(final Method method) { public Map<Integer, Set<Annotation>> apply(final Method method) {
return new MapMaker().makeComputingMap(new GetAnnotationsForMethodParameterIndex(method, annotation)); return new MapMaker().makeComputingMap(new GetAnnotationsForMethodParameterIndex(method, annotation));
@ -208,7 +209,7 @@ public class RestAnnotationProcessor<T> {
} }
private static final Class<? extends HttpRequestOptions[]> optionsVarArgsClass = new HttpRequestOptions[] {} private static final Class<? extends HttpRequestOptions[]> optionsVarArgsClass = new HttpRequestOptions[] {}
.getClass(); .getClass();
private static final Function<? super Entry<String, String>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, String>, Part>() { private static final Function<? super Entry<String, String>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, String>, Part>() {
@ -220,17 +221,17 @@ public class RestAnnotationProcessor<T> {
}; };
private final Map<Method, Set<Integer>> methodToIndexesOfOptions = new MapMaker() private final Map<Method, Set<Integer>> methodToIndexesOfOptions = new MapMaker()
.makeComputingMap(new Function<Method, Set<Integer>>() { .makeComputingMap(new Function<Method, Set<Integer>>() {
public Set<Integer> apply(final Method method) { public Set<Integer> apply(final Method method) {
Set<Integer> toReturn = newHashSet(); Set<Integer> toReturn = newHashSet();
for (int index = 0; index < method.getParameterTypes().length; index++) { for (int index = 0; index < method.getParameterTypes().length; index++) {
Class<?> type = method.getParameterTypes()[index]; Class<?> type = method.getParameterTypes()[index];
if (HttpRequestOptions.class.isAssignableFrom(type) || optionsVarArgsClass.isAssignableFrom(type)) if (HttpRequestOptions.class.isAssignableFrom(type) || optionsVarArgsClass.isAssignableFrom(type))
toReturn.add(index); toReturn.add(index);
}
return toReturn;
} }
}); return toReturn;
}
});
private final ParseSax.Factory parserFactory; private final ParseSax.Factory parserFactory;
private final HttpUtils utils; private final HttpUtils utils;
@ -249,7 +250,7 @@ public class RestAnnotationProcessor<T> {
@VisibleForTesting @VisibleForTesting
public static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector, public static Function<HttpResponse, ?> createResponseParser(ParseSax.Factory parserFactory, Injector injector,
Method method, HttpRequest request) { Method method, HttpRequest request) {
Function<HttpResponse, ?> transformer; Function<HttpResponse, ?> transformer;
Class<? extends HandlerWithResult<?>> handler = getSaxResponseParserClassOrNull(method); Class<? extends HandlerWithResult<?>> handler = getSaxResponseParserClassOrNull(method);
if (handler != null) { if (handler != null) {
@ -270,7 +271,7 @@ public class RestAnnotationProcessor<T> {
@VisibleForTesting @VisibleForTesting
public static Function<Exception, ?> createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation( public static Function<Exception, ?> createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(
Injector injector, Method method) { Injector injector, Method method) {
ExceptionParser annotation = method.getAnnotation(ExceptionParser.class); ExceptionParser annotation = method.getAnnotation(ExceptionParser.class);
if (annotation != null) { if (annotation != null) {
return injector.getInstance(annotation.value()); return injector.getInstance(annotation.value());
@ -281,7 +282,7 @@ public class RestAnnotationProcessor<T> {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Inject @Inject
public RestAnnotationProcessor(Injector injector, ParseSax.Factory parserFactory, HttpUtils utils, public RestAnnotationProcessor(Injector injector, ParseSax.Factory parserFactory, HttpUtils utils,
TypeLiteral<T> typeLiteral) { TypeLiteral<T> typeLiteral) {
this.declaring = (Class<T>) typeLiteral.getRawType(); this.declaring = (Class<T>) typeLiteral.getRawType();
this.injector = injector; this.injector = injector;
this.parserFactory = parserFactory; this.parserFactory = parserFactory;
@ -397,7 +398,7 @@ public class RestAnnotationProcessor<T> {
public GeneratedHttpRequest<T> createRequest(Method method, Object... args) { public GeneratedHttpRequest<T> createRequest(Method method, Object... args) {
inputParamValidator.validateMethodParametersOrThrow(method, args); inputParamValidator.validateMethodParametersOrThrow(method, args);
ClassMethodArgs cma = logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args) ClassMethodArgs cma = logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args)
: null; : null;
URI endpoint = callerEndpoint; URI endpoint = callerEndpoint;
try { try {
@ -511,8 +512,8 @@ public class RestAnnotationProcessor<T> {
org.jclouds.rest.MapBinder mapBinder = getMapPayloadBinderOrNull(method, args); org.jclouds.rest.MapBinder mapBinder = getMapPayloadBinderOrNull(method, args);
if (mapBinder != null) { if (mapBinder != null) {
Map<String, String> mapParams = buildPostParams(method, args); Map<String, String> mapParams = buildPostParams(method, args);
if (method.isAnnotationPresent(MapPayloadParams.class)) { if (method.isAnnotationPresent(PayloadParams.class)) {
MapPayloadParams params = method.getAnnotation(MapPayloadParams.class); PayloadParams params = method.getAnnotation(PayloadParams.class);
addMapPayload(mapParams, params, headers.entries()); addMapPayload(mapParams, params, headers.entries());
} }
request = mapBinder.bindToRequest(request, mapParams); request = mapBinder.bindToRequest(request, mapParams);
@ -553,14 +554,14 @@ public class RestAnnotationProcessor<T> {
} }
public static URI replaceQuery(Provider<UriBuilder> uriBuilderProvider, URI in, String newQuery, public static URI replaceQuery(Provider<UriBuilder> uriBuilderProvider, URI in, String newQuery,
@Nullable Comparator<Entry<String, String>> sorter, char... skips) { @Nullable Comparator<Entry<String, String>> sorter, char... skips) {
UriBuilder builder = uriBuilderProvider.get().uri(in); UriBuilder builder = uriBuilderProvider.get().uri(in);
builder.replaceQuery(ModifyRequest.makeQueryLine(ModifyRequest.parseQueryToMap(newQuery), sorter, skips)); builder.replaceQuery(ModifyRequest.makeQueryLine(ModifyRequest.parseQueryToMap(newQuery), sorter, skips));
return builder.build(); return builder.build();
} }
private Multimap<String, String> addMatrixParams(Collection<Entry<String, String>> tokenValues, Method method, private Multimap<String, String> addMatrixParams(Collection<Entry<String, String>> tokenValues, Method method,
Object... args) { Object... args) {
Multimap<String, String> matrixMap = LinkedListMultimap.create(); Multimap<String, String> matrixMap = LinkedListMultimap.create();
if (declaring.isAnnotationPresent(MatrixParams.class)) { if (declaring.isAnnotationPresent(MatrixParams.class)) {
MatrixParams matrix = declaring.getAnnotation(MatrixParams.class); MatrixParams matrix = declaring.getAnnotation(MatrixParams.class);
@ -579,7 +580,7 @@ public class RestAnnotationProcessor<T> {
} }
private Multimap<String, String> addFormParams(Collection<Entry<String, String>> tokenValues, Method method, private Multimap<String, String> addFormParams(Collection<Entry<String, String>> tokenValues, Method method,
Object... args) { Object... args) {
Multimap<String, String> formMap = LinkedListMultimap.create(); Multimap<String, String> formMap = LinkedListMultimap.create();
if (declaring.isAnnotationPresent(FormParams.class)) { if (declaring.isAnnotationPresent(FormParams.class)) {
FormParams form = declaring.getAnnotation(FormParams.class); FormParams form = declaring.getAnnotation(FormParams.class);
@ -598,7 +599,7 @@ public class RestAnnotationProcessor<T> {
} }
private Multimap<String, String> addQueryParams(Collection<Entry<String, String>> tokenValues, Method method, private Multimap<String, String> addQueryParams(Collection<Entry<String, String>> tokenValues, Method method,
Object... args) { Object... args) {
Multimap<String, String> queryMap = LinkedListMultimap.create(); Multimap<String, String> queryMap = LinkedListMultimap.create();
if (declaring.isAnnotationPresent(QueryParams.class)) { if (declaring.isAnnotationPresent(QueryParams.class)) {
QueryParams query = declaring.getAnnotation(QueryParams.class); QueryParams query = declaring.getAnnotation(QueryParams.class);
@ -617,7 +618,7 @@ public class RestAnnotationProcessor<T> {
} }
private void addForm(Multimap<String, String> formParams, FormParams form, private void addForm(Multimap<String, String> formParams, FormParams form,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
for (int i = 0; i < form.keys().length; i++) { for (int i = 0; i < form.keys().length; i++) {
if (form.values()[i].equals(FormParams.NULL)) { if (form.values()[i].equals(FormParams.NULL)) {
formParams.removeAll(form.keys()[i]); formParams.removeAll(form.keys()[i]);
@ -629,7 +630,7 @@ public class RestAnnotationProcessor<T> {
} }
private void addQuery(Multimap<String, String> queryParams, QueryParams query, private void addQuery(Multimap<String, String> queryParams, QueryParams query,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
for (int i = 0; i < query.keys().length; i++) { for (int i = 0; i < query.keys().length; i++) {
if (query.values()[i].equals(QueryParams.NULL)) { if (query.values()[i].equals(QueryParams.NULL)) {
queryParams.removeAll(query.keys()[i]); queryParams.removeAll(query.keys()[i]);
@ -641,7 +642,7 @@ public class RestAnnotationProcessor<T> {
} }
private void addMatrix(Multimap<String, String> matrixParams, MatrixParams matrix, private void addMatrix(Multimap<String, String> matrixParams, MatrixParams matrix,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
for (int i = 0; i < matrix.keys().length; i++) { for (int i = 0; i < matrix.keys().length; i++) {
if (matrix.values()[i].equals(MatrixParams.NULL)) { if (matrix.values()[i].equals(MatrixParams.NULL)) {
matrixParams.removeAll(matrix.keys()[i]); matrixParams.removeAll(matrix.keys()[i]);
@ -652,10 +653,10 @@ public class RestAnnotationProcessor<T> {
} }
} }
private void addMapPayload(Map<String, String> postParams, MapPayloadParams mapDefaults, private void addMapPayload(Map<String, String> postParams, PayloadParams mapDefaults,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
for (int i = 0; i < mapDefaults.keys().length; i++) { for (int i = 0; i < mapDefaults.keys().length; i++) {
if (mapDefaults.values()[i].equals(MapPayloadParams.NULL)) { if (mapDefaults.values()[i].equals(PayloadParams.NULL)) {
postParams.put(mapDefaults.keys()[i], null); postParams.put(mapDefaults.keys()[i], null);
} else { } else {
postParams.put(mapDefaults.keys()[i], Strings2.replaceTokens(mapDefaults.values()[i], tokenValues)); postParams.put(mapDefaults.keys()[i], Strings2.replaceTokens(mapDefaults.values()[i], tokenValues));
@ -688,7 +689,7 @@ public class RestAnnotationProcessor<T> {
@VisibleForTesting @VisibleForTesting
public static URI getEndpointInParametersOrNull(Method method, final Object[] args, Injector injector) { public static URI getEndpointInParametersOrNull(Method method, final Object[] args, Injector injector) {
Map<Integer, Set<Annotation>> map = indexWithAtLeastOneAnnotation(method, Map<Integer, Set<Annotation>> map = indexWithAtLeastOneAnnotation(method,
methodToIndexOfParamToEndpointParamAnnotations); methodToIndexOfParamToEndpointParamAnnotations);
if (map.size() >= 1 && args.length > 0) { if (map.size() >= 1 && args.length > 0) {
EndpointParam firstAnnotation = (EndpointParam) get(get(map.values(), 0), 0); EndpointParam firstAnnotation = (EndpointParam) get(get(map.values(), 0), 0);
Function<Object, URI> parser = injector.getInstance(firstAnnotation.parser()); Function<Object, URI> parser = injector.getInstance(firstAnnotation.parser());
@ -697,8 +698,8 @@ public class RestAnnotationProcessor<T> {
int index = map.keySet().iterator().next(); int index = map.keySet().iterator().next();
try { try {
URI returnVal = parser.apply(args[index]); URI returnVal = parser.apply(args[index]);
checkArgument(returnVal != null, String.format("endpoint for [%s] not configured for %s", args[index], checkArgument(returnVal != null,
method)); String.format("endpoint for [%s] not configured for %s", args[index], method));
return returnVal; return returnVal;
} catch (NullPointerException e) { } catch (NullPointerException e) {
throw new IllegalArgumentException(String.format("argument at index %d on method %s", index, method), e); throw new IllegalArgumentException(String.format("argument at index %d on method %s", index, method), e);
@ -715,12 +716,12 @@ public class RestAnnotationProcessor<T> {
}); });
try { try {
URI returnVal = parser.apply(argsToParse); URI returnVal = parser.apply(argsToParse);
checkArgument(returnVal != null, String.format("endpoint for [%s] not configured for %s", argsToParse, checkArgument(returnVal != null,
method)); String.format("endpoint for [%s] not configured for %s", argsToParse, method));
return returnVal; return returnVal;
} catch (NullPointerException e) { } catch (NullPointerException e) {
throw new IllegalArgumentException(String.format("argument at indexes %s on method %s", map.keySet(), throw new IllegalArgumentException(String.format("argument at indexes %s on method %s", map.keySet(),
method), e); method), e);
} }
} }
} }
@ -756,21 +757,21 @@ public class RestAnnotationProcessor<T> {
public static final TypeLiteral<ListenableFuture<HttpResponse>> futureHttpResponseLiteral = new TypeLiteral<ListenableFuture<HttpResponse>>() { public static final TypeLiteral<ListenableFuture<HttpResponse>> futureHttpResponseLiteral = new TypeLiteral<ListenableFuture<HttpResponse>>() {
}; };
@SuppressWarnings( { "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
public static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Method method) { public static Key<? extends Function<HttpResponse, ?>> getParserOrThrowException(Method method) {
ResponseParser annotation = method.getAnnotation(ResponseParser.class); ResponseParser annotation = method.getAnnotation(ResponseParser.class);
if (annotation == null) { if (annotation == null) {
if (method.getReturnType().equals(void.class) if (method.getReturnType().equals(void.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureVoidLiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureVoidLiteral)) {
return Key.get(ReleasePayloadAndReturn.class); return Key.get(ReleasePayloadAndReturn.class);
} else if (method.getReturnType().equals(boolean.class) || method.getReturnType().equals(Boolean.class) } else if (method.getReturnType().equals(boolean.class) || method.getReturnType().equals(Boolean.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureBooleanLiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureBooleanLiteral)) {
return Key.get(ReturnTrueIf2xx.class); return Key.get(ReturnTrueIf2xx.class);
} else if (method.getReturnType().equals(InputStream.class) } else if (method.getReturnType().equals(InputStream.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureInputStreamLiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureInputStreamLiteral)) {
return Key.get(ReturnInputStream.class); return Key.get(ReturnInputStream.class);
} else if (method.getReturnType().equals(HttpResponse.class) } else if (method.getReturnType().equals(HttpResponse.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureHttpResponseLiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureHttpResponseLiteral)) {
return Key.get((Class) IdentityFunction.class); return Key.get((Class) IdentityFunction.class);
} else if (getAcceptHeadersOrNull(method).contains(MediaType.APPLICATION_JSON)) { } else if (getAcceptHeadersOrNull(method).contains(MediaType.APPLICATION_JSON)) {
Type returnVal; Type returnVal;
@ -796,16 +797,16 @@ public class RestAnnotationProcessor<T> {
parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValueInSet.class, returnVal); parserType = Types.newParameterizedType(UnwrapOnlyNestedJsonValueInSet.class, returnVal);
else else
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"depth(%d) edgeCollection(%s) not yet supported for @Unwrap", depth, edgeCollection)); "depth(%d) edgeCollection(%s) not yet supported for @Unwrap", depth, edgeCollection));
} else { } else {
parserType = Types.newParameterizedType(ParseJson.class, returnVal); parserType = Types.newParameterizedType(ParseJson.class, returnVal);
} }
return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType); return (Key<? extends Function<HttpResponse, ?>>) Key.get(parserType);
} else if (method.getReturnType().equals(String.class) } else if (method.getReturnType().equals(String.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureStringLiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureStringLiteral)) {
return Key.get(ReturnStringIf2xx.class); return Key.get(ReturnStringIf2xx.class);
} else if (method.getReturnType().equals(URI.class) } else if (method.getReturnType().equals(URI.class)
|| TypeLiteral.get(method.getGenericReturnType()).equals(futureURILiteral)) { || TypeLiteral.get(method.getGenericReturnType()).equals(futureURILiteral)) {
return Key.get(ParseURIFromListOrLocationHeaderIf20x.class); return Key.get(ParseURIFromListOrLocationHeaderIf20x.class);
} else { } else {
throw new IllegalStateException("You must specify a ResponseParser annotation on: " + method.toString()); throw new IllegalStateException("You must specify a ResponseParser annotation on: " + method.toString());
@ -837,7 +838,7 @@ public class RestAnnotationProcessor<T> {
} else { } else {
if (postBinders[0] instanceof org.jclouds.rest.MapBinder) { if (postBinders[0] instanceof org.jclouds.rest.MapBinder) {
throw new IllegalArgumentException("we currently do not support multiple varargs postBinders in: " throw new IllegalArgumentException("we currently do not support multiple varargs postBinders in: "
+ method.getName()); + method.getName());
} }
} }
} else if (arg instanceof org.jclouds.rest.MapBinder) { } else if (arg instanceof org.jclouds.rest.MapBinder) {
@ -847,9 +848,10 @@ public class RestAnnotationProcessor<T> {
} }
} }
} }
MapBinder annotation = method.getAnnotation(MapBinder.class); if (method.isAnnotationPresent(MapBinder.class)) {
if (annotation != null) { return injector.getInstance(method.getAnnotation(MapBinder.class).value());
return injector.getInstance(annotation.value()); } else if (method.isAnnotationPresent(org.jclouds.rest.annotations.Payload.class)) {
return injector.getInstance(BindMapToStringPayload.class);
} }
return null; return null;
} }
@ -858,7 +860,7 @@ public class RestAnnotationProcessor<T> {
public boolean isHttpMethod(Method method) { public boolean isHttpMethod(Method method) {
return method.isAnnotationPresent(Path.class) || getHttpMethods(method) != null return method.isAnnotationPresent(Path.class) || getHttpMethods(method) != null
|| Sets.newHashSet(method.getParameterTypes()).contains(HttpRequest.class); || Sets.newHashSet(method.getParameterTypes()).contains(HttpRequest.class);
} }
public boolean isConstantDeclaration(Method method) { public boolean isConstantDeclaration(Method method) {
@ -887,8 +889,8 @@ public class RestAnnotationProcessor<T> {
Set<String> requests = getHttpMethods(method); Set<String> requests = getHttpMethods(method);
if (requests == null || requests.size() != 1) { if (requests == null || requests.size() != 1) {
throw new IllegalStateException( throw new IllegalStateException(
"You must use at least one, but no more than one http method or pathparam annotation on: " "You must use at least one, but no more than one http method or pathparam annotation on: "
+ method.toString()); + method.toString());
} }
return requests.iterator().next(); return requests.iterator().next();
} }
@ -902,12 +904,12 @@ public class RestAnnotationProcessor<T> {
public GeneratedHttpRequest<T> decorateRequest(GeneratedHttpRequest<T> request) { public GeneratedHttpRequest<T> decorateRequest(GeneratedHttpRequest<T> request) {
OUTER: for (Entry<Integer, Set<Annotation>> entry : filterValues( OUTER: for (Entry<Integer, Set<Annotation>> entry : filterValues(
methodToIndexOfParamToDecoratorParamAnnotation.get(request.getJavaMethod()), methodToIndexOfParamToDecoratorParamAnnotation.get(request.getJavaMethod()),
new Predicate<Set<Annotation>>() { new Predicate<Set<Annotation>>() {
public boolean apply(Set<Annotation> input) { public boolean apply(Set<Annotation> input) {
return input.size() >= 1; return input.size() >= 1;
} }
}).entrySet()) { }).entrySet()) {
boolean shouldBreak = false; boolean shouldBreak = false;
BinderParam payloadAnnotation = (BinderParam) entry.getValue().iterator().next(); BinderParam payloadAnnotation = (BinderParam) entry.getValue().iterator().next();
Binder binder = injector.getInstance(payloadAnnotation.value()); Binder binder = injector.getInstance(payloadAnnotation.value());
@ -943,24 +945,24 @@ public class RestAnnotationProcessor<T> {
} }
public static Map<Integer, Set<Annotation>> indexWithOnlyOneAnnotation(Method method, String description, public static Map<Integer, Set<Annotation>> indexWithOnlyOneAnnotation(Method method, String description,
Map<Method, Map<Integer, Set<Annotation>>> toRefine) { Map<Method, Map<Integer, Set<Annotation>>> toRefine) {
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine); Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine);
if (indexToPayloadAnnotation.size() > 1) { if (indexToPayloadAnnotation.size() > 1) {
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"You must not specify more than one %s annotation on: %s; found %s", description, method.toString(), "You must not specify more than one %s annotation on: %s; found %s", description, method.toString(),
indexToPayloadAnnotation)); indexToPayloadAnnotation));
} }
return indexToPayloadAnnotation; return indexToPayloadAnnotation;
} }
private static Map<Integer, Set<Annotation>> indexWithAtLeastOneAnnotation(Method method, private static Map<Integer, Set<Annotation>> indexWithAtLeastOneAnnotation(Method method,
Map<Method, Map<Integer, Set<Annotation>>> toRefine) { Map<Method, Map<Integer, Set<Annotation>>> toRefine) {
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = filterValues(toRefine.get(method), Map<Integer, Set<Annotation>> indexToPayloadAnnotation = filterValues(toRefine.get(method),
new Predicate<Set<Annotation>>() { new Predicate<Set<Annotation>>() {
public boolean apply(Set<Annotation> input) { public boolean apply(Set<Annotation> input) {
return input.size() == 1; return input.size() == 1;
} }
}); });
return indexToPayloadAnnotation; return indexToPayloadAnnotation;
} }
@ -979,7 +981,7 @@ public class RestAnnotationProcessor<T> {
} else { } else {
if (options[0] instanceof HttpRequestOptions) { if (options[0] instanceof HttpRequestOptions) {
throw new IllegalArgumentException("we currently do not support multiple varargs options in: " throw new IllegalArgumentException("we currently do not support multiple varargs options in: "
+ method.getName()); + method.getName());
} }
} }
} else { } else {
@ -991,7 +993,7 @@ public class RestAnnotationProcessor<T> {
} }
public Multimap<String, String> buildHeaders(Collection<Entry<String, String>> tokenValues, Method method, public Multimap<String, String> buildHeaders(Collection<Entry<String, String>> tokenValues, Method method,
final Object... args) { final Object... args) {
Multimap<String, String> headers = LinkedHashMultimap.create(); Multimap<String, String> headers = LinkedHashMultimap.create();
addHeaderIfAnnotationPresentOnMethod(headers, method, tokenValues); addHeaderIfAnnotationPresentOnMethod(headers, method, tokenValues);
Map<Integer, Set<Annotation>> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations.get(method); Map<Integer, Set<Annotation>> indexToHeaderParam = methodToIndexOfParamToHeaderParamAnnotations.get(method);
@ -1038,7 +1040,7 @@ public class RestAnnotationProcessor<T> {
} }
public void addHeaderIfAnnotationPresentOnMethod(Multimap<String, String> headers, Method method, public void addHeaderIfAnnotationPresentOnMethod(Multimap<String, String> headers, Method method,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
if (declaring.isAnnotationPresent(Headers.class)) { if (declaring.isAnnotationPresent(Headers.class)) {
Headers header = declaring.getAnnotation(Headers.class); Headers header = declaring.getAnnotation(Headers.class);
addHeader(headers, header, tokenValues); addHeader(headers, header, tokenValues);
@ -1050,7 +1052,7 @@ public class RestAnnotationProcessor<T> {
} }
private void addHeader(Multimap<String, String> headers, Headers header, private void addHeader(Multimap<String, String> headers, Headers header,
Collection<Entry<String, String>> tokenValues) { Collection<Entry<String, String>> tokenValues) {
for (int i = 0; i < header.keys().length; i++) { for (int i = 0; i < header.keys().length; i++) {
String value = header.values()[i]; String value = header.values()[i];
value = Strings2.replaceTokens(value, tokenValues); value = Strings2.replaceTokens(value, tokenValues);
@ -1240,7 +1242,7 @@ public class RestAnnotationProcessor<T> {
for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.entrySet()) { for (Entry<Integer, Set<Annotation>> entry : indexToPathParam.entrySet()) {
for (Annotation key : entry.getValue()) { for (Annotation key : entry.getValue()) {
Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey()); Set<Annotation> extractors = indexToParamExtractor.get(entry.getKey());
String paramKey = ((MapPayloadParam) key).value(); String paramKey = ((PayloadParam) key).value();
String paramValue; String paramValue;
if (extractors != null && extractors.size() > 0) { if (extractors != null && extractors.size() > 0) {
ParamParser extractor = (ParamParser) extractors.iterator().next(); ParamParser extractor = (ParamParser) extractors.iterator().next();

View File

@ -42,7 +42,7 @@ import org.jclouds.io.Payload;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
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.MapPayloadParam; 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;
@ -143,7 +143,7 @@ public interface IntegrationTestAsyncClient {
@POST @POST
@Path("/objects/{id}") @Path("/objects/{id}")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
ListenableFuture<String> postJson(@PathParam("id") String id, @MapPayloadParam("key") String toPut); ListenableFuture<String> postJson(@PathParam("id") String id, @PayloadParam("key") String toPut);
@POST @POST
@Path("/objects/{id}/action/{action}") @Path("/objects/{id}/action/{action}")

View File

@ -118,12 +118,12 @@ import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams; import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.annotations.Headers;
import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.MapBinder;
import org.jclouds.rest.annotations.MapPayloadParam;
import org.jclouds.rest.annotations.MapPayloadParams;
import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.MatrixParams;
import org.jclouds.rest.annotations.OverrideRequestFilters; import org.jclouds.rest.annotations.OverrideRequestFilters;
import org.jclouds.rest.annotations.ParamParser; import org.jclouds.rest.annotations.ParamParser;
import org.jclouds.rest.annotations.PartParam; import org.jclouds.rest.annotations.PartParam;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.PayloadParams;
import org.jclouds.rest.annotations.QueryParams; 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;
@ -517,18 +517,25 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
@POST @POST
@Path("/{foo}") @Path("/{foo}")
public void postWithPath(@PathParam("foo") @MapPayloadParam("fooble") String path, MapBinder content); public void postWithPath(@PathParam("foo") @PayloadParam("fooble") String path, MapBinder content);
@POST @POST
@Path("/{foo}") @Path("/{foo}")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
public void postWithMethodBinder(@PathParam("foo") @MapPayloadParam("fooble") String path); public void postWithMethodBinder(@PathParam("foo") @PayloadParam("fooble") String path);
@POST @POST
@Path("/{foo}") @Path("/{foo}")
@MapPayloadParams(keys = "rat", values = "atat") @PayloadParams(keys = "rat", values = "atat")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
public void postWithMethodBinderAndDefaults(@PathParam("foo") @MapPayloadParam("fooble") String path); public void postWithMethodBinderAndDefaults(@PathParam("foo") @PayloadParam("fooble") String path);
@POST
@Path("/{foo}")
@PayloadParams(keys = "rat", values = "atat")
@org.jclouds.rest.annotations.Payload("name {fooble}")
@Produces(MediaType.TEXT_PLAIN)
public void testPayload(@PathParam("foo") @PayloadParam("fooble") String path);
} }
public void testCreatePostRequest() throws SecurityException, NoSuchMethodException, IOException { public void testCreatePostRequest() throws SecurityException, NoSuchMethodException, IOException {
@ -594,6 +601,15 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
assertPayloadEquals(request, "{\"fooble\":\"data\",\"rat\":\"atat\"}", "application/json", false); assertPayloadEquals(request, "{\"fooble\":\"data\",\"rat\":\"atat\"}", "application/json", false);
} }
public void testCreatePostWithPayload() throws SecurityException, NoSuchMethodException, IOException {
Method method = TestPost.class.getMethod("testPayload", String.class);
HttpRequest request = factory(TestPost.class).createRequest(method, "data");
assertRequestLineEquals(request, "POST http://localhost:9999/data HTTP/1.1");
assertNonPayloadHeadersEqual(request, "");
assertPayloadEquals(request, "name data", "text/plain", false);
}
static interface TestMultipartForm { static interface TestMultipartForm {
@POST @POST
void withStringPart(@PartParam(name = "fooble") String path); void withStringPart(@PartParam(name = "fooble") String path);
@ -714,7 +730,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
@PUT @PUT
@Path("/{foo}") @Path("/{foo}")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
void putWithMethodBinder(@PathParam("foo") @MapPayloadParam("fooble") String path); void putWithMethodBinder(@PathParam("foo") @PayloadParam("fooble") String path);
@PUT @PUT
@Path("/{foo}") @Path("/{foo}")
@ -725,7 +741,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
@Path("/{foo}") @Path("/{foo}")
@MapBinder(BindToJsonPayload.class) @MapBinder(BindToJsonPayload.class)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
Wrapper putWithMethodBinderConsumes(@PathParam("foo") @MapPayloadParam("fooble") String path); Wrapper putWithMethodBinderConsumes(@PathParam("foo") @PayloadParam("fooble") String path);
@GET @GET
@Path("/") @Path("/")

View File

@ -26,12 +26,12 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString; import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString; import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString; import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
import org.jclouds.cloudsigma.binders.BindNameToPayload;
import org.jclouds.cloudsigma.binders.BindServerToPlainTextString; import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
import org.jclouds.cloudsigma.domain.Drive; import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData; import org.jclouds.cloudsigma.domain.DriveData;
@ -57,7 +57,8 @@ import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
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.MapPayloadParam; import org.jclouds.rest.annotations.Payload;
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.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
@ -108,8 +109,8 @@ public interface CloudSigmaAsyncClient {
@ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
@Path("/drives/{uuid}/clone") @Path("/drives/{uuid}/clone")
@MapBinder(BindCloneDriveOptionsToPlainTextString.class) @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid, ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName,
@MapPayloadParam("name") String newName, CloneDriveOptions... options); CloneDriveOptions... options);
/** /**
* @see CloudSigmaClient#getProfileInfo * @see CloudSigmaClient#getProfileInfo
@ -258,7 +259,9 @@ public interface CloudSigmaAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
@ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
@Path("/resources/vlan/create") @Path("/resources/vlan/create")
ListenableFuture<VLANInfo> createVLAN(@BinderParam(BindNameToPayload.class) String name); @Payload("name {name}\n")
@Produces(MediaType.TEXT_PLAIN)
ListenableFuture<VLANInfo> createVLAN(@PayloadParam("name") String name);
/** /**
* @see CloudSigmaClient#listVLANInfo * @see CloudSigmaClient#listVLANInfo
@ -283,8 +286,9 @@ public interface CloudSigmaAsyncClient {
@POST @POST
@ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class) @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
@Path("/resources/vlan/{uuid}/set") @Path("/resources/vlan/{uuid}/set")
ListenableFuture<VLANInfo> renameVLAN(@PathParam("uuid") String uuid, @Payload("name {name}\n")
@BinderParam(BindNameToPayload.class) String name); @Produces(MediaType.TEXT_PLAIN)
ListenableFuture<VLANInfo> renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name);
/** /**
* @see CloudSigmaClient#listVLANs * @see CloudSigmaClient#listVLANs

View File

@ -1,44 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.
* ====================================================================
*/
package org.jclouds.cloudsigma.binders;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Singleton;
import javax.ws.rs.core.MediaType;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
/**
*
* @author Adrian Cole
*
*/
@Singleton
public class BindNameToPayload implements Binder {
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
request.setPayload("name " + checkNotNull(payload, "name") + "\n");
request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
return request;
}
}

View File

@ -32,7 +32,7 @@ import javax.ws.rs.QueryParam;
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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
@ -118,8 +118,8 @@ public interface SlicehostAsyncClient {
@Path("/slices.xml") @Path("/slices.xml")
@MapBinder(BindCreateSliceToXmlPayload.class) @MapBinder(BindCreateSliceToXmlPayload.class)
@XMLResponseParser(SliceHandler.class) @XMLResponseParser(SliceHandler.class)
ListenableFuture<Slice> createSlice(@MapPayloadParam("name") String name, @MapPayloadParam("image_id") int imageId, ListenableFuture<Slice> createSlice(@PayloadParam("name") String name, @PayloadParam("image_id") int imageId,
@MapPayloadParam("flavor_id") int flavorId); @PayloadParam("flavor_id") int flavorId);
/** /**
* @see SlicehostClient#rebuildSliceFromImage * @see SlicehostClient#rebuildSliceFromImage

View File

@ -40,7 +40,7 @@ import javax.ws.rs.Produces;
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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
@ -112,8 +112,8 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@MapBinder(AddInternetServiceOptions.class) @MapBinder(AddInternetServiceOptions.class)
@Override @Override
ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI existingIpId, ListenableFuture<? extends InternetService> addInternetServiceToExistingIp(@EndpointParam URI existingIpId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol, @PayloadParam("name") String serviceName, @PayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options); @PayloadParam("port") int port, AddInternetServiceOptions... options);
/** /**
* @see TerremarkVCloudExpressClient#getInternetServicesOnPublicIP * @see TerremarkVCloudExpressClient#getInternetServicesOnPublicIP
@ -174,8 +174,8 @@ public interface TerremarkECloudAsyncClient extends TerremarkVCloudAsyncClient {
@XMLResponseParser(KeyPairHandler.class) @XMLResponseParser(KeyPairHandler.class)
@MapBinder(BindCreateKeyToXmlPayload.class) @MapBinder(BindCreateKeyToXmlPayload.class)
ListenableFuture<? extends KeyPair> generateKeyPairInOrg( ListenableFuture<? extends KeyPair> generateKeyPairInOrg(
@EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, @MapPayloadParam("name") String name, @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, @PayloadParam("name") String name,
@MapPayloadParam("isDefault") boolean makeDefault); @PayloadParam("isDefault") boolean makeDefault);
/** /**
* @see TerremarkECloudClient#getKeyPair * @see TerremarkECloudClient#getKeyPair

View File

@ -36,7 +36,7 @@ import javax.ws.rs.Produces;
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.MapPayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
@ -76,8 +76,8 @@ public interface TerremarkVCloudExpressAsyncClient extends TerremarkVCloudAsyncC
@MapBinder(AddInternetServiceOptions.class) @MapBinder(AddInternetServiceOptions.class)
ListenableFuture<? extends InternetService> addInternetServiceToVDC( ListenableFuture<? extends InternetService> addInternetServiceToVDC(
@EndpointParam(parser = VDCURIToInternetServicesEndpoint.class) URI vDCId, @EndpointParam(parser = VDCURIToInternetServicesEndpoint.class) URI vDCId,
@MapPayloadParam("name") String serviceName, @MapPayloadParam("protocol") Protocol protocol, @PayloadParam("name") String serviceName, @PayloadParam("protocol") Protocol protocol,
@MapPayloadParam("port") int port, AddInternetServiceOptions... options); @PayloadParam("port") int port, AddInternetServiceOptions... options);
/** /**
* @see TerremarkVCloudExpressClient#findKeyPairInOrgNamed * @see TerremarkVCloudExpressClient#findKeyPairInOrgNamed
@ -117,8 +117,8 @@ public interface TerremarkVCloudExpressAsyncClient extends TerremarkVCloudAsyncC
@XMLResponseParser(KeyPairHandler.class) @XMLResponseParser(KeyPairHandler.class)
@MapBinder(BindCreateKeyToXmlPayload.class) @MapBinder(BindCreateKeyToXmlPayload.class)
ListenableFuture<? extends KeyPair> generateKeyPairInOrg( ListenableFuture<? extends KeyPair> generateKeyPairInOrg(
@EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, @MapPayloadParam("name") String name, @EndpointParam(parser = OrgURIToKeysListEndpoint.class) URI org, @PayloadParam("name") String name,
@MapPayloadParam("isDefault") boolean makeDefault); @PayloadParam("isDefault") boolean makeDefault);
/** /**
* @see TerremarkVCloudExpressClient#getKeyPair * @see TerremarkVCloudExpressClient#getKeyPair