diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java
index d795f337cb..76026dba58 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersAsyncClient.java
@@ -32,16 +32,7 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import org.jclouds.http.functions.ReturnFalseOn404;
-import org.jclouds.cloudservers.binders.BindAdminPassToJsonPayload;
import org.jclouds.cloudservers.binders.BindBackupScheduleToJsonPayload;
-import org.jclouds.cloudservers.binders.BindConfirmResizeToJsonPayload;
-import org.jclouds.cloudservers.binders.BindCreateImageToJsonPayload;
-import org.jclouds.cloudservers.binders.BindRebootTypeToJsonPayload;
-import org.jclouds.cloudservers.binders.BindResizeFlavorToJsonPayload;
-import org.jclouds.cloudservers.binders.BindRevertResizeToJsonPayload;
-import org.jclouds.cloudservers.binders.BindServerNameToJsonPayload;
-import org.jclouds.cloudservers.binders.BindSharedIpGroupToJsonPayload;
import org.jclouds.cloudservers.domain.Addresses;
import org.jclouds.cloudservers.domain.BackupSchedule;
import org.jclouds.cloudservers.domain.Flavor;
@@ -53,12 +44,14 @@ import org.jclouds.cloudservers.options.CreateServerOptions;
import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions;
import org.jclouds.cloudservers.options.ListOptions;
import org.jclouds.cloudservers.options.RebuildServerOptions;
+import org.jclouds.http.functions.ReturnFalseOn404;
import org.jclouds.openstack.filters.AddTimestampQuery;
import org.jclouds.openstack.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Endpoint;
import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
@@ -82,8 +75,8 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see
* @author Adrian Cole
*/
-@SkipEncoding( { '/', '=' })
-@RequestFilters( { AuthenticateRequest.class, AddTimestampQuery.class })
+@SkipEncoding({ '/', '=' })
+@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class })
@Endpoint(ServerManagement.class)
public interface CloudServersAsyncClient {
@@ -123,8 +116,9 @@ public interface CloudServersAsyncClient {
@POST
@QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action")
- ListenableFuture rebootServer(@PathParam("id") int id,
- @BinderParam(BindRebootTypeToJsonPayload.class) RebootType rebootType);
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D")
+ ListenableFuture rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType);
/**
* @see CloudServersClient#resizeServer
@@ -132,8 +126,9 @@ public interface CloudServersAsyncClient {
@POST
@QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action")
- ListenableFuture resizeServer(@PathParam("id") int id,
- @BinderParam(BindResizeFlavorToJsonPayload.class) int flavorId);
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D")
+ ListenableFuture resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId);
/**
* @see CloudServersClient#confirmResizeServer
@@ -142,7 +137,8 @@ public interface CloudServersAsyncClient {
@QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action")
@Produces(MediaType.APPLICATION_JSON)
- ListenableFuture confirmResizeServer(@PathParam("id") @BinderParam(BindConfirmResizeToJsonPayload.class) int id);
+ @Payload("{\"confirmResize\":null}")
+ ListenableFuture confirmResizeServer(@PathParam("id") int id);
/**
* @see CloudServersClient#revertResizeServer
@@ -151,7 +147,8 @@ public interface CloudServersAsyncClient {
@QueryParams(keys = "format", values = "json")
@Path("/servers/{id}/action")
@Produces(MediaType.APPLICATION_JSON)
- ListenableFuture revertResizeServer(@PathParam("id") @BinderParam(BindRevertResizeToJsonPayload.class) int id);
+ @Payload("{\"revertResize\":null}")
+ ListenableFuture revertResizeServer(@PathParam("id") int id);
/**
* @see CloudServersClient#createServer
@@ -163,7 +160,7 @@ public interface CloudServersAsyncClient {
@Path("/servers")
@MapBinder(CreateServerOptions.class)
ListenableFuture createServer(@PayloadParam("name") String name, @PayloadParam("imageId") int imageId,
- @PayloadParam("flavorId") int flavorId, CreateServerOptions... options);
+ @PayloadParam("flavorId") int flavorId, CreateServerOptions... options);
/**
* @see CloudServersClient#rebuildServer
@@ -179,10 +176,11 @@ public interface CloudServersAsyncClient {
*/
@PUT
@Path("/servers/{id}/ips/public/{address}")
- @MapBinder(BindSharedIpGroupToJsonPayload.class)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"shareIp\":%7B\"sharedIpGroupId\":{sharedIpGroupId},\"configureServer\":{configureServer}%7D%7D")
ListenableFuture shareIp(@PathParam("address") String addressToShare,
- @PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup,
- @PayloadParam("configureServer") boolean configureServer);
+ @PathParam("id") int serverToTosignBindressTo, @PayloadParam("sharedIpGroupId") int sharedIpGroup,
+ @PayloadParam("configureServer") boolean configureServer);
/**
* @see CloudServersClient#unshareIp
@@ -191,23 +189,25 @@ public interface CloudServersAsyncClient {
@Path("/servers/{id}/ips/public/{address}")
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
ListenableFuture unshareIp(@PathParam("address") String addressToShare,
- @PathParam("id") int serverToTosignBindressTo);
+ @PathParam("id") int serverToTosignBindressTo);
/**
* @see CloudServersClient#changeAdminPass
*/
@PUT
@Path("/servers/{id}")
- ListenableFuture changeAdminPass(@PathParam("id") int id,
- @BinderParam(BindAdminPassToJsonPayload.class) String adminPass);
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"server\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
+ ListenableFuture changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass);
/**
* @see CloudServersClient#renameServer
*/
@PUT
@Path("/servers/{id}")
- ListenableFuture renameServer(@PathParam("id") int id,
- @BinderParam(BindServerNameToJsonPayload.class) String newName);
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D")
+ ListenableFuture renameServer(@PathParam("id") int id, @PayloadParam("name") String newName);
/**
* @see CloudServersClient#listFlavors
@@ -268,10 +268,11 @@ public interface CloudServersAsyncClient {
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
- @MapBinder(BindCreateImageToJsonPayload.class)
@Path("/images")
- ListenableFuture createImageFromServer(@PayloadParam("imageName") String imageName,
- @PayloadParam("serverId") int serverId);
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"image\":%7B\"serverId\":{serverId},\"name\":\"{name}\"%7D%7D")
+ ListenableFuture createImageFromServer(@PayloadParam("name") String imageName,
+ @PayloadParam("serverId") int serverId);
/**
* @see CloudServersClient#listSharedIpGroups
@@ -305,7 +306,7 @@ public interface CloudServersAsyncClient {
@Path("/shared_ip_groups")
@MapBinder(CreateSharedIpGroupOptions.class)
ListenableFuture createSharedIpGroup(@PayloadParam("name") String name,
- CreateSharedIpGroupOptions... options);
+ CreateSharedIpGroupOptions... options);
/**
* @see CloudServersClient#deleteSharedIpGroup
@@ -340,7 +341,7 @@ public interface CloudServersAsyncClient {
@ExceptionParser(ReturnFalseOn404.class)
@Path("/servers/{id}/backup_schedule")
ListenableFuture replaceBackupSchedule(@PathParam("id") int id,
- @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule);
+ @BinderParam(BindBackupScheduleToJsonPayload.class) BackupSchedule backupSchedule);
/**
* @see CloudServersClient#listAddresses
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindAdminPassToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindAdminPassToJsonPayload.java
deleted file mode 100644
index 06d148b0fa..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindAdminPassToJsonPayload.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindAdminPassToJsonPayload extends BindToJsonPayload {
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- throw new IllegalStateException("Change Admin Pass is a PUT operation");
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- checkArgument(toBind instanceof String, "this binder is only valid for Strings!");
- return super.bindToRequest(request,
- ImmutableMap.of("server", ImmutableMap.of("adminPass", checkNotNull(toBind, "adminPass"))));
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindConfirmResizeToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindConfirmResizeToJsonPayload.java
deleted file mode 100644
index 9b3b22c86e..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindConfirmResizeToJsonPayload.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindConfirmResizeToJsonPayload implements Binder {
- @Override
- public R bindToRequest(R request, Object toBind) {
- request.setPayload("{\"confirmResize\":null}");
- return request;
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayload.java
deleted file mode 100644
index bb5e038c2b..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayload.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindCreateImageToJsonPayload extends BindToJsonPayload {
-
- @SuppressWarnings("unused")
- private class CreateImageRequest {
- final int serverId;
- final String name;
-
- private CreateImageRequest(int serverId, String name) {
- this.serverId = serverId;
- this.name = name;
- }
-
- }
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- CreateImageRequest createRequest = new CreateImageRequest(Integer
- .parseInt(checkNotNull(postParams.get("serverId"))), checkNotNull(postParams
- .get("imageName")));
- return super.bindToRequest(request, ImmutableMap.of("image", createRequest));
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- throw new IllegalArgumentException("image is needs parameters");
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayload.java
deleted file mode 100644
index 98902075cc..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayload.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindRebootTypeToJsonPayload extends BindToJsonPayload {
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- throw new IllegalStateException("Reboot doesn't take map parameters");
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- checkArgument(toBind instanceof RebootType, "this binder is only valid for RebootTypes!");
- return super.bindToRequest(request, ImmutableMap.of("reboot", ImmutableMap.of("type", checkNotNull(
- toBind, "type"))));
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindResizeFlavorToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindResizeFlavorToJsonPayload.java
deleted file mode 100644
index 053383552a..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindResizeFlavorToJsonPayload.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindResizeFlavorToJsonPayload extends BindToJsonPayload {
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- throw new IllegalStateException("Resize doesn't take map parameters");
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- checkArgument(toBind instanceof Integer, "this binder is only valid for integers!");
- return super.bindToRequest(request, ImmutableMap.of("resize", ImmutableMap.of("flavorId",
- (Integer) checkNotNull(toBind, "flavorId"))));
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRevertResizeToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRevertResizeToJsonPayload.java
deleted file mode 100644
index 86dd21172e..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindRevertResizeToJsonPayload.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.Binder;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindRevertResizeToJsonPayload implements Binder {
- @Override
- public R bindToRequest(R request, Object toBind) {
- request.setPayload("{\"revertResize\":null}");
- return request;
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayload.java
deleted file mode 100644
index 0519e131b5..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayload.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindServerNameToJsonPayload extends BindToJsonPayload {
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- throw new IllegalStateException("Change Server Name is a PUT operation");
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- checkArgument(toBind instanceof String, "this binder is only valid for Strings!");
- return super.bindToRequest(request, ImmutableMap.of("server", ImmutableMap.of("name", checkNotNull(
- toBind, "name"))));
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindSharedIpGroupToJsonPayload.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindSharedIpGroupToJsonPayload.java
deleted file mode 100644
index 332d667e96..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/binders/BindSharedIpGroupToJsonPayload.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-@Singleton
-public class BindSharedIpGroupToJsonPayload extends BindToJsonPayload {
-
- @SuppressWarnings("unused")
- private class ShareIpRequest {
- final int sharedIpGroupId;
- Boolean configureServer;
-
- private ShareIpRequest(int sharedIpGroupId) {
- this.sharedIpGroupId = sharedIpGroupId;
- }
-
- }
-
- @Override
- public R bindToRequest(R request, Map postParams) {
- ShareIpRequest createRequest = new ShareIpRequest(Integer.parseInt(checkNotNull(postParams
- .get("sharedIpGroupId"))));
- if (Boolean.parseBoolean(checkNotNull(postParams.get("configureServer")))) {
- createRequest.configureServer = new Boolean(true);
- }
- return super.bindToRequest(request, ImmutableMap.of("shareIp", createRequest));
- }
-
- @Override
- public R bindToRequest(R request, Object toBind) {
- throw new IllegalStateException("shareIp is needs parameters");
- }
-}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/BackupSchedule.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/BackupSchedule.java
index e8d8df6af2..0c63c4f588 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/BackupSchedule.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/domain/BackupSchedule.java
@@ -65,7 +65,7 @@ public class BackupSchedule {
@Override
public String toString() {
- return "BackupSchedule [daily=" + daily + ", enabled=" + enabled + ", weekly=" + weekly + "]";
+ return "[daily=" + daily + ", enabled=" + enabled + ", weekly=" + weekly + "]";
}
@Override
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
index a625496ea4..2f05652bbb 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
@@ -85,17 +85,17 @@ import com.google.inject.TypeLiteral;
public class CloudServersAsyncClientTest extends RestClientTest {
private static final Class extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
private static final Class extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
- .getClass();
+ .getClass();
public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createServer", String.class, int.class, int.class,
- createServerOptionsVarargsClass);
+ createServerOptionsVarargsClass);
HttpRequest request = processor.createRequest(method, "ralphie", 2, 1);
assertRequestLineEquals(request, "POST http://serverManagementUrl/servers?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1}}",
- "application/json", false);
+ "application/json", false);
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
@@ -107,14 +107,14 @@ public class CloudServersAsyncClientTest extends RestClientTest createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[] {}
- .getClass();
+ .getClass();
public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("createSharedIpGroup", String.class,
- createSharedIpGroupOptionsVarargsClass);
+ createSharedIpGroupOptionsVarargsClass);
HttpRequest request = processor.createRequest(method, "ralphie");
assertRequestLineEquals(request, "POST http://serverManagementUrl/shared_ip_groups?format=json HTTP/1.1");
@@ -650,13 +651,13 @@ public class CloudServersAsyncClientTest extends RestClientTest rebuildServerOptionsVarargsClass = new RebuildServerOptions[] {}
- .getClass();
+ .getClass();
public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException {
Method method = CloudServersAsyncClient.class.getMethod("rebuildServer", int.class,
- rebuildServerOptionsVarargsClass);
+ rebuildServerOptionsVarargsClass);
HttpRequest request = processor.createRequest(method, 3);
assertRequestLineEquals(request, "POST http://serverManagementUrl/servers/3/action?format=json HTTP/1.1");
@@ -778,7 +779,7 @@ public class CloudServersAsyncClientTest extends RestClientTest
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.File;
-import java.net.URI;
-
-import javax.ws.rs.HttpMethod;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindAdminPassToJsonPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindAdminPassToJsonPayloadTest {
-
- Injector injector = Guice.createInjector(new GsonModule());
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testPostIsIncorrect() {
- BindAdminPassToJsonPayload binder = new BindAdminPassToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, ImmutableMap.of("adminPass", "foo"));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testMustBeString() {
- BindAdminPassToJsonPayload binder = new BindAdminPassToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, new File("foo"));
- }
-
- @Test
- public void testCorrect() {
- BindAdminPassToJsonPayload binder = new BindAdminPassToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, "foo");
- assertEquals("{\"server\":{\"adminPass\":\"foo\"}}", request.getPayload().getRawContent());
- }
-
- @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
- public void testNullIsBad() {
- BindAdminPassToJsonPayload binder = new BindAdminPassToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, null);
- }
-}
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayloadTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayloadTest.java
deleted file mode 100644
index e2244b0d90..0000000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindCreateImageToJsonPayloadTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.File;
-import java.net.URI;
-
-import javax.ws.rs.HttpMethod;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindCreateImageToJsonPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindCreateImageToJsonPayloadTest {
-
- Injector injector = Guice.createInjector(new GsonModule());
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testMustBeMap() {
- BindCreateImageToJsonPayload binder = new BindCreateImageToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, new File("foo"));
- }
-
- @Test
- public void testCorrect() {
- BindCreateImageToJsonPayload binder = new BindCreateImageToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, ImmutableMap.of("imageName", "foo", "serverId", "2"));
- assertEquals("{\"image\":{\"serverId\":2,\"name\":\"foo\"}}", request.getPayload()
- .getRawContent());
- }
-
- @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
- public void testNullIsBad() {
- BindCreateImageToJsonPayload binder = new BindCreateImageToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, null);
- }
-}
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayloadTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayloadTest.java
deleted file mode 100644
index 29d845f8d2..0000000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindRebootTypeToJsonPayloadTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.File;
-import java.net.URI;
-
-import javax.ws.rs.HttpMethod;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindRebootTypeToJsonPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindRebootTypeToJsonPayloadTest {
-
- Injector injector = Guice.createInjector(new GsonModule());
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testPostIsIncorrect() {
- BindRebootTypeToJsonPayload binder = new BindRebootTypeToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, ImmutableMap.of("adminPass", "foo"));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testMustBeRebootType() {
- BindRebootTypeToJsonPayload binder = new BindRebootTypeToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, new File("foo"));
- }
-
- @Test
- public void testHard() {
- BindRebootTypeToJsonPayload binder = new BindRebootTypeToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, RebootType.HARD);
- assertEquals("{\"reboot\":{\"type\":\"HARD\"}}", request.getPayload().getRawContent());
- }
-
- @Test
- public void testSoft() {
- BindRebootTypeToJsonPayload binder = new BindRebootTypeToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, RebootType.SOFT);
- assertEquals("{\"reboot\":{\"type\":\"SOFT\"}}", request.getPayload().getRawContent());
- }
-
- @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
- public void testNullIsBad() {
- BindRebootTypeToJsonPayload binder = new BindRebootTypeToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, null);
- }
-}
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayloadTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayloadTest.java
deleted file mode 100644
index 26b897e940..0000000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/binders/BindServerNameToJsonPayloadTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- *
- * Copyright (C) 2010 Cloud Conscious, LLC.
- *
- * ====================================================================
- * 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.cloudservers.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.File;
-import java.net.URI;
-
-import javax.ws.rs.HttpMethod;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindServerNameToJsonPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindServerNameToJsonPayloadTest {
-
- Injector injector = Guice.createInjector(new GsonModule());
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testPostIsIncorrect() {
- BindServerNameToJsonPayload binder = new BindServerNameToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, ImmutableMap.of("name", "foo"));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testMustBeString() {
- BindServerNameToJsonPayload binder = new BindServerNameToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
- binder.bindToRequest(request, new File("foo"));
- }
-
- @Test
- public void testCorrect() {
- BindServerNameToJsonPayload binder = new BindServerNameToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, "foo");
- assertEquals("{\"server\":{\"name\":\"foo\"}}", request.getPayload().getRawContent());
- }
-
- @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
- public void testNullIsBad() {
- BindServerNameToJsonPayload binder = new BindServerNameToJsonPayload();
- injector.injectMembers(binder);
- HttpRequest request = new HttpRequest(HttpMethod.PUT, URI.create("http://localhost"));
- binder.bindToRequest(request, null);
- }
-}
diff --git a/core/src/main/java/org/jclouds/rest/annotations/Payload.java b/core/src/main/java/org/jclouds/rest/annotations/Payload.java
index 45c42dccf4..5edd78ee5c 100644
--- a/core/src/main/java/org/jclouds/rest/annotations/Payload.java
+++ b/core/src/main/java/org/jclouds/rest/annotations/Payload.java
@@ -37,6 +37,8 @@ import javax.ws.rs.Path;
public @interface Payload {
/**
+ * Note that if you'd like curly braces literally in the payload, urlencode them first.
+ *
* @see Path#value()
* @see PayloadParam
*/
diff --git a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java
index 45fce9dc7d..445dfa2f9a 100644
--- a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java
+++ b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java
@@ -49,11 +49,16 @@ public class BindMapToStringPayload implements MapBinder {
@SuppressWarnings("unchecked")
@Override
public R bindToRequest(R request, Map postParams) {
- GeneratedHttpRequest> r = GeneratedHttpRequest.class.cast( request);
- UriBuilder builder = uriBuilders.get();
- builder.path(r.getJavaMethod().getAnnotation(Payload.class).value());
- URI fake = builder.buildFromMap(postParams);
- return (R) request.toBuilder().payload(Payloads.newStringPayload(fake.getPath())).build();
+ GeneratedHttpRequest> r = GeneratedHttpRequest.class.cast(request);
+ String payload = r.getJavaMethod().getAnnotation(Payload.class).value();
+ if (postParams.size() > 0) {
+ UriBuilder builder = uriBuilders.get();
+ builder.uri(URI.create("http://test/"));
+ builder.path(payload);
+ URI fake = builder.buildFromMap(postParams);
+ payload = fake.getPath().substring(1);
+ }
+ return (R) request.toBuilder().payload(Payloads.newStringPayload(payload)).build();
}
@Override