mirror of https://github.com/apache/jclouds.git
Issue 125:payload binder
This commit is contained in:
parent
37fc5505ff
commit
4627a91195
|
@ -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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
|
@ -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();
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
|
|
@ -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,7 +169,7 @@ 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();
|
||||||
|
@ -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);
|
||||||
|
@ -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));
|
||||||
|
@ -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,8 +716,8 @@ 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(),
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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}")
|
||||||
|
|
|
@ -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("/")
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue