You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/02 16:57:57 UTC
[04/10] git commit: Removed async from cloudsigma
Removed async from cloudsigma
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/1a6071ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/1a6071ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/1a6071ab
Branch: refs/heads/master
Commit: 1a6071ab9294a1bf06eb62d7320470e4575fc74e
Parents: a9cb3cf
Author: Andrew Bayer <an...@gmail.com>
Authored: Fri Aug 2 07:56:31 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Fri Aug 2 07:57:41 2013 -0700
----------------------------------------------------------------------
.../org/jclouds/cloudsigma/CloudSigmaApi.java | 448 +++++++++++++
.../cloudsigma/CloudSigmaApiMetadata.java | 21 +-
.../cloudsigma/CloudSigmaAsyncClient.java | 352 ----------
.../jclouds/cloudsigma/CloudSigmaClient.java | 304 ---------
.../CloudSigmaComputeServiceAdapter.java | 9 +-
.../CloudSigmaComputeServiceContextModule.java | 6 +-
.../config/CloudSigmaRestClientModule.java | 7 +-
.../cloudsigma/predicates/DriveClaimed.java | 6 +-
.../org/jclouds/cloudsigma/util/Servers.java | 3 +-
.../jclouds/cloudsigma/CloudSigmaApiTest.java | 646 +++++++++++++++++++
.../cloudsigma/CloudSigmaAsyncClientTest.java | 646 -------------------
.../cloudsigma/CloudSigmaClientLiveTest.java | 6 +-
.../CloudSigmaZurichComputeServiceLiveTest.java | 6 +-
13 files changed, 1118 insertions(+), 1342 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
new file mode 100644
index 0000000..42ffd5e
--- /dev/null
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
@@ -0,0 +1,448 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+import java.io.Closeable;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.ProfileInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.domain.StaticIPInfo;
+import org.jclouds.cloudsigma.domain.VLANInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
+import org.jclouds.cloudsigma.functions.SplitNewlines;
+import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * Provides synchronous access to CloudSigma via their REST API.
+ * <p/>
+ *
+ * @see <a href="http://cloudsigma.com/en/platform-details/the-api" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Consumes(MediaType.TEXT_PLAIN)
+public interface CloudSigmaApi extends Closeable {
+
+ /**
+ * list of drive uuids that are in the library
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/standard/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardDrives();
+
+ /**
+ * list of cd uuids that are in the library
+ *
+ * @return or empty set if no cds are found
+ */
+ @GET
+ @Path("/drives/standard/cd/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardCds();
+
+ /**
+ * list of image uuids that are in the library
+ *
+ * @return or empty set if no images are found
+ */
+ @GET
+ @Path("/drives/standard/img/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardImages();
+
+ /**
+ * Clone an existing drive. By default, the size is the same as the source
+ *
+ * @param sourceUuid
+ * source to clone
+ * @param newName
+ * name of the resulting drive
+ * @param options
+ * options to control size
+ * @return new drive
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/clone")
+ @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
+ DriveInfo cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName,
+ CloneDriveOptions... options);
+
+ /**
+ * Get profile info
+ *
+ * @return info or null, if not found
+ */
+ @GET
+ @Path("/profile/info")
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class)
+ ProfileInfo getProfileInfo();
+
+ /**
+ * Get all drives info
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
+ Set<DriveInfo> listDriveInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/info")
+ DriveInfo getDriveInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new drive
+ *
+ * @param createDrive
+ * required parameters: name, size
+ * @return newly created drive
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/create")
+ DriveInfo createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
+
+ /**
+ * set extra drive data
+ *
+ * @param uuid
+ * what drive to change
+ * @param createDrive
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/set")
+ DriveInfo setDriveData(@PathParam("uuid") String uuid,
+ @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive);
+
+ /**
+ * create a new server
+ *
+ * @param createServer
+ * @return newly created server
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/create")
+ ServerInfo createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
+
+ /**
+ * Get all servers info
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
+ Set<ServerInfo> listServerInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/info")
+ ServerInfo getServerInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * set server configuration
+ *
+ * @param uuid
+ * what server to change
+ * @param setServer
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/set")
+ ServerInfo setServerConfiguration(@PathParam("uuid") String uuid,
+ @BinderParam(BindServerToPlainTextString.class) Server setServer);
+
+ /**
+ * list of server uuids in your account
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listServers();
+
+ /**
+ * Destroy a server
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/servers/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Start a server
+ *
+ * @param uuid
+ * what to start
+ */
+ @POST
+ @Path("/servers/{uuid}/start")
+ void startServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Stop a server
+ * <p/>
+ * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
+ * status if it is persistent and is automatically destroyed otherwise.
+ *
+ * @param uuid
+ * what to stop
+ */
+ @POST
+ @Path("/servers/{uuid}/stop")
+ void stopServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Shutdown a server
+ * <p/>
+ * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
+ * persistent and is automatically destroyed otherwise.
+ * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
+ * ACPI power button signal.
+ *
+ * @param uuid
+ * what to shutdown
+ */
+ @POST
+ @Path("/servers/{uuid}/shutdown")
+ void shutdownServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Reset a server
+ *
+ * @param uuid
+ * what to reset
+ */
+ @POST
+ @Path("/servers/{uuid}/reset")
+ void resetServer(@PathParam("uuid") String uuid);
+
+ /**
+ * list of drive uuids in your account
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listDrives();
+
+ /**
+ * Destroy a drive
+ *
+ * @param uuid
+ * what to delete
+ */
+ @GET
+ @Path("/drives/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyDrive(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new vlan
+ *
+ * @param name
+ * @return newly created vlan
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/create")
+ @Payload("name {name}\n")
+ @Produces(MediaType.TEXT_PLAIN)
+ VLANInfo createVLAN(@PayloadParam("name") String name);
+
+ /**
+ * Get all vlans info
+ *
+ * @return or empty set if no vlans are found
+ */
+ @GET
+ @Path("/resources/vlan/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class)
+ Set<VLANInfo> listVLANInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/{uuid}/info")
+ VLANInfo getVLANInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * set vlan configuration
+ *
+ * @param uuid
+ * what vlan to change
+ * @param name
+ * what the new name is
+ * @return new data
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/{uuid}/set")
+ @Payload("name {name}\n")
+ @Produces(MediaType.TEXT_PLAIN)
+ VLANInfo renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name);
+
+ /**
+ * list of vlan uuids in your account
+ *
+ * @return or empty set if no vlans are found
+ */
+ @GET
+ @Path("/resources/vlan/list")
+ @ResponseParser(SplitNewlinesAndReturnSecondField.class)
+ Set<String> listVLANs();
+
+ /**
+ * Destroy a vlan
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/resources/vlan/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyVLAN(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new ip
+ *
+ * @return newly created ip
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
+ @Path("/resources/ip/create")
+ StaticIPInfo createStaticIP();
+
+ /**
+ * Get all ips info
+ *
+ * @return or empty set if no ips are found
+ */
+ @GET
+ @Path("/resources/ip/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class)
+ Set<StaticIPInfo> listStaticIPInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
+ @Path("/resources/ip/{uuid}/info")
+ StaticIPInfo getStaticIPInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * list of ip uuids in your account
+ *
+ * @return or empty set if no ips are found
+ */
+ @GET
+ @Path("/resources/ip/list")
+ @ResponseParser(SplitNewlinesAndReturnSecondField.class)
+ Set<String> listStaticIPs();
+
+ /**
+ * Destroy a ip
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/resources/ip/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyStaticIP(@PathParam("uuid") String uuid);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
index eea93cb..22fb6cf 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
@@ -26,10 +26,9 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -37,17 +36,9 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
+public class CloudSigmaApiMetadata extends BaseHttpApiMetadata<CloudSigmaApi> {
+
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
- * {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -62,7 +53,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
// passwords are set post-boot, so auth failures are possible
// from a race condition applying the password set script
@@ -72,11 +63,9 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<CloudSigmaApi, Builder> {
- @SuppressWarnings("deprecation")
protected Builder() {
- super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
id("cloudsigma")
.name("CloudSigma API")
.identityName("Email")
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
deleted file mode 100644
index ca5ddb8..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
-import org.jclouds.cloudsigma.domain.Drive;
-import org.jclouds.cloudsigma.domain.DriveData;
-import org.jclouds.cloudsigma.domain.DriveInfo;
-import org.jclouds.cloudsigma.domain.ProfileInfo;
-import org.jclouds.cloudsigma.domain.Server;
-import org.jclouds.cloudsigma.domain.ServerInfo;
-import org.jclouds.cloudsigma.domain.StaticIPInfo;
-import org.jclouds.cloudsigma.domain.VLANInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
-import org.jclouds.cloudsigma.functions.SplitNewlines;
-import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
-import org.jclouds.cloudsigma.options.CloneDriveOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.Payload;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to CloudSigma via their REST API.
- * <p/>
- *
- * @see CloudSigmaClient
- * @see <a href="http://cloudsigma.com/en/platform-details/the-api" />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
- * {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@RequestFilters(BasicAuthentication.class)
-@Consumes(MediaType.TEXT_PLAIN)
-public interface CloudSigmaAsyncClient extends Closeable {
-
- /**
- * @see CloudSigmaClient#listStandardDrives
- */
- @GET
- @Path("/drives/standard/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardDrives();
-
- /**
- * @see CloudSigmaClient#listStandardCds
- */
- @GET
- @Path("/drives/standard/cd/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardCds();
-
- /**
- * @see CloudSigmaClient#listStandardImages
- */
- @GET
- @Path("/drives/standard/img/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardImages();
-
- /**
- * @see CloudSigmaClient#cloneDrive
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/clone")
- @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
- ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName,
- CloneDriveOptions... options);
-
- /**
- * @see CloudSigmaClient#getProfileInfo
- */
- @GET
- @Path("/profile/info")
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class)
- ListenableFuture<ProfileInfo> getProfileInfo();
-
- /**
- * @see CloudSigmaClient#listDriveInfo
- */
- @GET
- @Path("/drives/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
- ListenableFuture<Set<DriveInfo>> listDriveInfo();
-
- /**
- * @see CloudSigmaClient#getDriveInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/info")
- ListenableFuture<DriveInfo> getDriveInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createDrive
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/create")
- ListenableFuture<DriveInfo> createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
-
- /**
- * @see CloudSigmaClient#setDriveData
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/set")
- ListenableFuture<DriveInfo> setDriveData(@PathParam("uuid") String uuid,
- @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive);
-
- /**
- * @see CloudSigmaClient#createServer
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/create")
- ListenableFuture<ServerInfo> createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
-
- /**
- * @see CloudSigmaClient#listServerInfo
- */
- @GET
- @Path("/servers/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
- ListenableFuture<Set<ServerInfo>> listServerInfo();
-
- /**
- * @see CloudSigmaClient#getServerInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/info")
- ListenableFuture<ServerInfo> getServerInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#setServerConfiguration
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/set")
- ListenableFuture<ServerInfo> setServerConfiguration(@PathParam("uuid") String uuid,
- @BinderParam(BindServerToPlainTextString.class) Server setServer);
-
- /**
- * @see CloudSigmaClient#listServers
- */
- @GET
- @Path("/servers/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listServers();
-
- /**
- * @see CloudSigmaClient#destroyServer
- */
- @GET
- @Path("/servers/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#startServer
- */
- @POST
- @Path("/servers/{uuid}/start")
- ListenableFuture<Void> startServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#stopServer
- */
- @POST
- @Path("/servers/{uuid}/stop")
- ListenableFuture<Void> stopServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#shutdownServer
- */
- @POST
- @Path("/servers/{uuid}/shutdown")
- ListenableFuture<Void> shutdownServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#resetServer
- */
- @POST
- @Path("/servers/{uuid}/reset")
- ListenableFuture<Void> resetServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#listDrives
- */
- @GET
- @Path("/drives/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listDrives();
-
- /**
- * @see CloudSigmaClient#destroyDrive
- */
- @GET
- @Path("/drives/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyDrive(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createVLAN
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/create")
- @Payload("name {name}\n")
- @Produces(MediaType.TEXT_PLAIN)
- ListenableFuture<VLANInfo> createVLAN(@PayloadParam("name") String name);
-
- /**
- * @see CloudSigmaClient#listVLANInfo
- */
- @GET
- @Path("/resources/vlan/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class)
- ListenableFuture<Set<VLANInfo>> listVLANInfo();
-
- /**
- * @see CloudSigmaClient#getVLANInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/{uuid}/info")
- ListenableFuture<VLANInfo> getVLANInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#setVLANConfiguration
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/{uuid}/set")
- @Payload("name {name}\n")
- @Produces(MediaType.TEXT_PLAIN)
- ListenableFuture<VLANInfo> renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name);
-
- /**
- * @see CloudSigmaClient#listVLANs
- */
- @GET
- @Path("/resources/vlan/list")
- @ResponseParser(SplitNewlinesAndReturnSecondField.class)
- ListenableFuture<Set<String>> listVLANs();
-
- /**
- * @see CloudSigmaClient#destroyVLAN
- */
- @GET
- @Path("/resources/vlan/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyVLAN(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createStaticIP
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
- @Path("/resources/ip/create")
- ListenableFuture<StaticIPInfo> createStaticIP();
-
- /**
- * @see CloudSigmaClient#listStaticIPInfo
- */
- @GET
- @Path("/resources/ip/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class)
- ListenableFuture<Set<StaticIPInfo>> listStaticIPInfo();
-
- /**
- * @see CloudSigmaClient#getStaticIPInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
- @Path("/resources/ip/{uuid}/info")
- ListenableFuture<StaticIPInfo> getStaticIPInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#listStaticIPs
- */
- @GET
- @Path("/resources/ip/list")
- @ResponseParser(SplitNewlinesAndReturnSecondField.class)
- ListenableFuture<Set<String>> listStaticIPs();
-
- /**
- * @see CloudSigmaClient#destroyStaticIP
- */
- @GET
- @Path("/resources/ip/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyStaticIP(@PathParam("uuid") String uuid);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
deleted file mode 100644
index b57095f..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import org.jclouds.cloudsigma.domain.Drive;
-import org.jclouds.cloudsigma.domain.DriveData;
-import org.jclouds.cloudsigma.domain.DriveInfo;
-import org.jclouds.cloudsigma.domain.ProfileInfo;
-import org.jclouds.cloudsigma.domain.Server;
-import org.jclouds.cloudsigma.domain.ServerInfo;
-import org.jclouds.cloudsigma.domain.StaticIPInfo;
-import org.jclouds.cloudsigma.domain.VLANInfo;
-import org.jclouds.cloudsigma.options.CloneDriveOptions;
-
-/**
- * Provides synchronous access to CloudSigma.
- * <p/>
- *
- * @see CloudSigmaAsyncClient
- * @see <a href="TODO: insert URL of cloudsigma documentation" />
- * @author Adrian Cole
- */
-public interface CloudSigmaClient extends Closeable {
-
- /**
- * Get profile info
- *
- * @return info or null, if not found
- */
- ProfileInfo getProfileInfo();
-
- /**
- * list of server uuids in your account
- *
- * @return or empty set if no servers are found
- */
- Set<String> listServers();
-
- /**
- * Get all servers info
- *
- * @return or empty set if no servers are found
- */
- Set<? extends ServerInfo> listServerInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- ServerInfo getServerInfo(String uuid);
-
- /**
- * create a new server
- *
- * @param server
- * @return newly created server
- */
- ServerInfo createServer(Server server);
-
- /**
- * set server configuration
- *
- * @param uuid
- * what server to change
- * @param serverData
- * what values to change
- * @return new data
- */
- ServerInfo setServerConfiguration(String uuid, Server server);
-
- /**
- * Destroy a server
- *
- * @param uuid
- * what to destroy
- */
- void destroyServer(String uuid);
-
- /**
- * Start a server
- *
- * @param uuid
- * what to start
- */
- void startServer(String uuid);
-
- /**
- * Stop a server
- * <p/>
- * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
- * status if it is persistent and is automatically destroyed otherwise.
- *
- * @param uuid
- * what to stop
- */
- void stopServer(String uuid);
-
- /**
- * Shutdown a server
- * <p/>
- * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
- * persistent and is automatically destroyed otherwise.
- * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
- * ACPI power button signal.
- *
- * @param uuid
- * what to shutdown
- */
- void shutdownServer(String uuid);
-
- /**
- * Reset a server
- *
- * @param uuid
- * what to reset
- */
- void resetServer(String uuid);
-
- /**
- * list of drive uuids in your account
- *
- * @return or empty set if no drives are found
- */
- Set<String> listDrives();
-
- /**
- * Get all drives info
- *
- * @return or empty set if no drives are found
- */
- Set<? extends DriveInfo> listDriveInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- DriveInfo getDriveInfo(String uuid);
-
- /**
- * create a new drive
- *
- * @param createDrive
- * required parameters: name, size
- * @return newly created drive
- */
- DriveInfo createDrive(Drive createDrive);
-
- /**
- * set extra drive data
- *
- * @param uuid
- * what drive to change
- * @param driveData
- * what values to change
- * @return new data
- */
- DriveInfo setDriveData(String uuid, DriveData driveData);
-
- /**
- * Destroy a drive
- *
- * @param uuid
- * what to delete
- */
- void destroyDrive(String uuid);
-
- /**
- * list of drive uuids that are in the library
- *
- * @return or empty set if no drives are found
- */
- Set<String> listStandardDrives();
-
- /**
- * list of cd uuids that are in the library
- *
- * @return or empty set if no cds are found
- */
- Set<String> listStandardCds();
-
- /**
- * list of image uuids that are in the library
- *
- * @return or empty set if no images are found
- */
- Set<String> listStandardImages();
-
- /**
- * Clone an existing drive. By default, the size is the same as the source
- *
- * @param sourceUuid
- * source to clone
- * @param newName
- * name of the resulting drive
- * @param options
- * options to control size
- * @return new drive
- */
- DriveInfo cloneDrive(String sourceUuid, String newName, CloneDriveOptions... options);
-
- /**
- * list of vlan uuids in your account
- *
- * @return or empty set if no vlans are found
- */
- Set<String> listVLANs();
-
- /**
- * Get all vlans info
- *
- * @return or empty set if no vlans are found
- */
- Set<? extends VLANInfo> listVLANInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- VLANInfo getVLANInfo(String uuid);
-
- /**
- * create a new vlan
- *
- * @param vlan
- * @return newly created vlan
- */
- VLANInfo createVLAN(String name);
-
- /**
- * set vlan configuration
- *
- * @param uuid
- * what vlan to change
- * @param newName
- * what the new name is
- * @return new data
- */
- VLANInfo renameVLAN(String uuid, String newName);
-
- /**
- * Destroy a vlan
- *
- * @param uuid
- * what to destroy
- */
- void destroyVLAN(String uuid);
-
- /**
- * list of ip uuids in your account
- *
- * @return or empty set if no ips are found
- */
- Set<String> listStaticIPs();
-
- /**
- * Get all ips info
- *
- * @return or empty set if no ips are found
- */
- Set<? extends StaticIPInfo> listStaticIPInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- StaticIPInfo getStaticIPInfo(String uuid);
-
- /**
- * create a new ip
- *
- * @return newly created ip
- */
- StaticIPInfo createStaticIP();
-
- /**
- * Destroy a ip
- *
- * @param uuid
- * what to destroy
- */
- void destroyStaticIP(String uuid);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
index 10c8e26..51240ff 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
@@ -28,7 +28,7 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions;
import org.jclouds.cloudsigma.domain.AffinityType;
import org.jclouds.cloudsigma.domain.Device;
@@ -62,14 +62,13 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.UncheckedExecutionException;
/**
- * defines the connection between the {@link CloudSigmaClient} implementation
+ * defines the connection between the {@link org.jclouds.cloudsigma.CloudSigmaApi} implementation
* and the jclouds {@link ComputeService}
*
*/
@@ -85,7 +84,7 @@ public class CloudSigmaComputeServiceAdapter implements
}
});
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
private final Predicate<DriveInfo> driveNotClaimed;
private final String defaultVncPassword;
private final LoadingCache<String, DriveInfo> cache;
@@ -96,7 +95,7 @@ public class CloudSigmaComputeServiceAdapter implements
protected Logger logger = Logger.NULL;
@Inject
- public CloudSigmaComputeServiceAdapter(CloudSigmaClient client, Predicate<DriveInfo> driveNotClaimed,
+ public CloudSigmaComputeServiceAdapter(CloudSigmaApi client, Predicate<DriveInfo> driveNotClaimed,
@Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
LoadingCache<String, DriveInfo> cache, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
this.client = checkNotNull(client, "client");
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
index f16a15e..d9ddeac 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
@@ -22,7 +22,7 @@ import static org.jclouds.util.Predicates2.retry;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl;
import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName;
@@ -97,10 +97,10 @@ public class CloudSigmaComputeServiceContextModule extends
@Singleton
public static class GetDrive extends CacheLoader<String, DriveInfo> {
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
@Inject
- public GetDrive(CloudSigmaClient client) {
+ public GetDrive(CloudSigmaApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
index fd62d8a..3773fa3 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
@@ -19,8 +19,7 @@ package org.jclouds.cloudsigma.config;
import java.util.List;
import java.util.Map;
-import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.domain.Device;
import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData;
@@ -42,7 +41,7 @@ import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
+import org.jclouds.rest.config.HttpApiModule;
import com.google.common.base.Function;
import com.google.inject.TypeLiteral;
@@ -53,7 +52,7 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole
*/
@ConfiguresRestClient
-public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {
+public class CloudSigmaRestClientModule extends HttpApiModule<CloudSigmaApi> {
@Override
protected void bindErrorHandlers() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
index 3f7aa03..210c2ef 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
@@ -22,7 +22,7 @@ import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.logging.Logger;
@@ -35,13 +35,13 @@ import com.google.common.base.Predicate;
@Singleton
public class DriveClaimed implements Predicate<DriveInfo> {
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public DriveClaimed(CloudSigmaClient client) {
+ public DriveClaimed(CloudSigmaApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
index 62a59a3..768f515 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
@@ -16,7 +16,6 @@
*/
package org.jclouds.cloudsigma.util;
-import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.cloudsigma.domain.IDEDevice;
import org.jclouds.cloudsigma.domain.Model;
import org.jclouds.cloudsigma.domain.NIC;
@@ -69,7 +68,7 @@ public class Servers {
/**
* Takes the input server and changes its primary ip to a new address. To make this happen,
- * you'll need to invoke {@link CloudSigmaClient#setServerConfiguration}
+ * you'll need to invoke {@link org.jclouds.cloudsigma.CloudSigmaApi#setServerConfiguration}
*
* @param in
* server to change
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
new file mode 100644
index 0000000..24c0c4d
--- /dev/null
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
@@ -0,0 +1,646 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
+import org.jclouds.cloudsigma.domain.CreateDriveRequest;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
+import org.jclouds.cloudsigma.functions.SplitNewlines;
+import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code CloudSigmaApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "CloudSigmaApiTest")
+public class CloudSigmaApiTest extends BaseAsyncClientTest<CloudSigmaApi> {
+
+ public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getProfileInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToProfileInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardDrives");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardCds");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardImages");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listDriveInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getDriveInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createDrive", Drive.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l)
+ .build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class,
+ CloneDriveOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name newname", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class,
+ CloneDriveOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname",
+ new CloneDriveOptions().size(1024l)));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name newname\nsize 1024", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "setDriveData", String.class, DriveData.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", new DriveData.Builder().name("foo").size(10000l)
+ .use(ImmutableList.of("production", "candy")).build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listServers");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listServerInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getServerInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createServer", Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "setServerConfiguration", String.class, Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "startServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "stopServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "shutdownServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "resetServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listDrives");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyDrive", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listVLANs");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listVLANInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getVLANInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createVLAN", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("poohbear"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "renameVLAN", String.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "poohbear"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyVLAN", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStaticIPs");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStaticIPInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getStaticIPInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createStaticIP");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyStaticIP", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new CloudSigmaApiMetadata();
+ }
+
+}