You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ev...@apache.org on 2014/11/18 21:21:13 UTC
[4/6] jclouds git commit: JCLOUDS-716: Remove Rackspace First-Gen
Cloud Servers
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
deleted file mode 100644
index 938699e..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateServerOptions.java
+++ /dev/null
@@ -1,239 +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.cloudservers.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.io.BaseEncoding.base64;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.inject.Inject;
-
-import org.jclouds.cloudservers.domain.Addresses;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.MapBinder;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-/**
- *
- * @author Adrian Cole
- *
- */
-public class CreateServerOptions implements MapBinder {
- @Inject
- private BindToJsonPayload jsonBinder;
-
- static class File {
- private final String path;
- private final String contents;
-
- public File(String path, byte[] contents) {
- this.path = checkNotNull(path, "path");
- this.contents = base64().encode(checkNotNull(contents, "contents"));
- checkArgument(path.getBytes().length < 255, String.format(
- "maximum length of path is 255 bytes. Path specified %s is %d bytes", path, path.getBytes().length));
- checkArgument(contents.length < 10 * 1024, String.format(
- "maximum size of the file is 10KB. Contents specified is %d bytes", contents.length));
- }
-
- public String getContents() {
- return contents;
- }
-
- public String getPath() {
- return path;
- }
-
- }
-
- @SuppressWarnings("unused")
- private static class ServerRequest {
- final String name;
- final int imageId;
- final int flavorId;
- Map<String, String> metadata;
- List<File> personality;
- Integer sharedIpGroupId;
- Addresses addresses;
-
- private ServerRequest(String name, int imageId, int flavorId) {
- this.name = name;
- this.imageId = imageId;
- this.flavorId = flavorId;
- }
-
- }
-
- private Map<String, String> metadata = Maps.newHashMap();
- private List<File> files = Lists.newArrayList();
- private Integer sharedIpGroupId;
- private String publicIp;
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present").toString(),
- Integer.parseInt(checkNotNull(postParams.get("imageId"), "imageId parameter not present").toString()),
- Integer.parseInt(checkNotNull(postParams.get("flavorId"), "flavorId parameter not present").toString()));
- if (metadata.size() > 0)
- server.metadata = metadata;
- if (files.size() > 0)
- server.personality = files;
- if (sharedIpGroupId != null)
- server.sharedIpGroupId = this.sharedIpGroupId;
- if (publicIp != null) {
- server.addresses = Addresses.builder().publicAddresses(ImmutableSet.of(publicIp)).build();
- }
- return bindToRequest(request, ImmutableMap.of("server", server));
- }
-
- /**
- * You may further customize a cloud server by injecting data into the file system of the cloud
- * server itself. This is useful, for example, for inserting ssh keys, setting configuration
- * files, or storing data that you want to retrieve from within the instance itself. It is
- * intended to provide a minimal amount of launch-time personalization. If significant
- * customization is required, a custom image should be created. The max size of the file path
- * data is 255 bytes while the max size of the file contents is 10KB. Note that the file contents
- * should be encoded as a Base64 string and the 10KB limit refers to the number of bytes in the
- * decoded data not the number of characters in the encoded data. The maximum number of file
- * path/content pairs that can be supplied is 5. Any existing files that match the specified file
- * will be renamed to include the extension bak followed by a time stamp. For example, the file
- * /etc/passwd will be backed up as /etc/passwd.bak.1246036261.5785. All files will have root and
- * the root group as owner and group owner, respectively and will allow user and group read
- * access only (-r--r-----).
- */
- public CreateServerOptions withFile(String path, byte[] contents) {
- checkState(files.size() < 5, "maximum number of files allowed is 5");
- files.add(new File(path, contents));
- return this;
- }
-
- /**
- * A shared IP group is a collection of servers that can share IPs with other members of the
- * group. Any server in a group can share one or more public IPs with any other server in the
- * group. With the exception of the first server in a shared IP group, servers must be launched
- * into shared IP groups. A server may only be a member of one shared IP group.
- *
- * <p/>
- * Servers in the same shared IP group can share public IPs for various high availability and
- * load balancing configurations. To launch an HA server, include the optional sharedIpGroupId
- * element and the server will be launched into that shared IP group.
- * <p />
- *
- * Note: sharedIpGroupId is an optional parameter and for optimal performance, should ONLY be
- * specified when intending to share IPs between servers.
- *
- * @see #withSharedIp(String)
- */
- public CreateServerOptions withSharedIpGroup(int id) {
- checkArgument(id > 0, "id must be positive or zero. was: " + id);
- this.sharedIpGroupId = id;
- return this;
- }
-
- /**
- * Custom cloud server metadata can also be supplied at launch time. This metadata is stored in
- * the API system where it is retrievable by querying the API for server status. The maximum size
- * of the metadata key and value is each 255 bytes and the maximum number of key-value pairs that
- * can be supplied per server is 5.
- */
- public CreateServerOptions withMetadata(Map<String, String> metadata) {
- checkNotNull(metadata, "metadata");
- checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values. You specified: "
- + metadata.size());
- for (Entry<String, String> entry : metadata.entrySet()) {
- checkArgument(entry.getKey().getBytes().length < 255, String.format(
- "maximum length of metadata key is 255 bytes. Key specified %s is %d bytes", entry.getKey(), entry
- .getKey().getBytes().length));
- checkArgument(entry.getKey().getBytes().length < 255, String.format(
- "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes", entry
- .getKey(), entry.getValue(), entry.getValue().getBytes().length));
- }
- this.metadata = metadata;
- return this;
- }
-
- /**
- * Public IP addresses can be shared across multiple servers for use in various high availability
- * scenarios. When an IP address is shared to another server, the cloud network restrictions are
- * modified to allow each server to listen to and respond on that IP address (you may optionally
- * specify that the target server network configuration be modified). Shared IP addresses can be
- * used with many standard heartbeat facilities (e.g. keepalived) that monitor for failure and
- * manage IP failover.
- *
- * <p/>
- * If you intend to use a shared IP on the server being created and have no need for a separate
- * public IP address, you may launch the server into a shared IP group and specify an IP address
- * from that shared IP group to be used as its public IP. You can accomplish this by specifying
- * the public shared IP address in your request. This is optional and is only valid if
- * sharedIpGroupId is also supplied.
- */
- public CreateServerOptions withSharedIp(String publicIp) {
- checkState(sharedIpGroupId != null, "sharedIp is invalid unless a shared ip group is specified.");
- this.publicIp = checkNotNull(publicIp, "ip");
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see CreateServerOptions#withFile(String,byte[])
- */
- public static CreateServerOptions withFile(String path, byte[] contents) {
- CreateServerOptions options = new CreateServerOptions();
- return options.withFile(path, contents);
- }
-
- /**
- * @see CreateServerOptions#withSharedIpGroup(int)
- */
- public static CreateServerOptions withSharedIpGroup(int id) {
- CreateServerOptions options = new CreateServerOptions();
- return options.withSharedIpGroup(id);
- }
-
- /**
- * @see CreateServerOptions#withMetadata(Map<String, String>)
- */
- public static CreateServerOptions withMetadata(Map<String, String> metadata) {
- CreateServerOptions options = new CreateServerOptions();
- return options.withMetadata(metadata);
- }
-
- /**
- * @see CreateServerOptions#withSharedIp(String)
- */
- public static CreateServerOptions withSharedIp(String publicIp) {
- CreateServerOptions options = new CreateServerOptions();
- return options.withSharedIp(publicIp);
- }
-
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object input) {
- return jsonBinder.bindToRequest(request, input);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
deleted file mode 100644
index 101329f..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/CreateSharedIpGroupOptions.java
+++ /dev/null
@@ -1,90 +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.cloudservers.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.rest.MapBinder;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- *
- *
- * @author Adrian Cole
- *
- */
-public class CreateSharedIpGroupOptions implements MapBinder {
- @Inject
- private BindToJsonPayload jsonBinder;
-
- Integer serverId;
-
- @SuppressWarnings("unused")
- private static class SharedIpGroupRequest {
- final String name;
- Integer server;
-
- private SharedIpGroupRequest(String name, @Nullable Integer serverId) {
- this.name = name;
- this.server = serverId;
- }
-
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- SharedIpGroupRequest createRequest = new SharedIpGroupRequest(checkNotNull(postParams.get("name")).toString(), serverId);
- return jsonBinder.bindToRequest(request, ImmutableMap.of("sharedIpGroup", createRequest));
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
- throw new IllegalStateException("CreateSharedIpGroup is a POST operation");
- }
-
- /**
- *
- * @param id
- * of the server to include with this request.
- */
- public CreateSharedIpGroupOptions withServer(int id) {
- checkArgument(id > 0, "server id must be a positive number");
- this.serverId = id;
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see CreateSharedIpGroupOptions#withServer(int)
- */
- public static CreateSharedIpGroupOptions withServer(int id) {
- CreateSharedIpGroupOptions options = new CreateSharedIpGroupOptions();
- return options.withServer(id);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java
deleted file mode 100644
index 8ec328b..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/ListOptions.java
+++ /dev/null
@@ -1,107 +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.cloudservers.options;
-
-import java.util.Date;
-
-import org.jclouds.openstack.options.BaseListOptions;
-
-/**
- * Options used to control the amount of detail in the request.
- *
- * @see BaseListOptions
- * @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
- * @author Adrian Cole
- */
-public class ListOptions extends BaseListOptions {
-
- public static final ListOptions NONE = new ListOptions();
-
- /**
- * unless used, only the name and id will be returned per row.
- *
- * @return
- */
- public ListOptions withDetails() {
- this.pathSuffix = "/detail";
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ListOptions changesSince(Date ifModifiedSince) {
- super.changesSince(ifModifiedSince);
- return this;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ListOptions maxResults(int limit) {
- super.maxResults(limit);
- return this;
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ListOptions startAt(long offset) {
- super.startAt(offset);
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see ListOptions#withDetails()
- */
- public static ListOptions withDetails() {
- ListOptions options = new ListOptions();
- return options.withDetails();
- }
-
- /**
- * @see BaseListOptions#startAt(long)
- */
- public static ListOptions startAt(long prefix) {
- ListOptions options = new ListOptions();
- return options.startAt(prefix);
- }
-
- /**
- * @see BaseListOptions#maxResults(long)
- */
- public static ListOptions maxResults(int maxKeys) {
- ListOptions options = new ListOptions();
- return options.maxResults(maxKeys);
- }
-
- /**
- * @see BaseListOptions#changesSince(Date)
- */
- public static ListOptions changesSince(Date since) {
- ListOptions options = new ListOptions();
- return options.changesSince(since);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
deleted file mode 100644
index a6c0657..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/options/RebuildServerOptions.java
+++ /dev/null
@@ -1,77 +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.cloudservers.options;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.MapBinder;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-
-/**
- *
- *
- * @author Adrian Cole
- *
- */
-public class RebuildServerOptions implements MapBinder {
- @Inject
- private BindToJsonPayload jsonBinder;
- Integer imageId;
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- Map<String, Integer> image = Maps.newHashMap();
- if (imageId != null)
- image.put("imageId", imageId);
- return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
- throw new IllegalStateException("RebuildServer is a POST operation");
- }
-
- /**
- *
- * @param id
- * of the image to rebuild the server with.
- */
- public RebuildServerOptions withImage(int id) {
- checkArgument(id > 0, "server id must be a positive number");
- this.imageId = id;
- return this;
- }
-
- public static class Builder {
-
- /**
- * @see RebuildServerOptions#withImage(int)
- */
- public static RebuildServerOptions withImage(int id) {
- RebuildServerOptions options = new RebuildServerOptions();
- return options.withImage(id);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
deleted file mode 100644
index 4fba7a4..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerActive.java
+++ /dev/null
@@ -1,64 +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.cloudservers.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a task succeeds.
- *
- * @author Adrian Cole
- */
-@Singleton
-public class ServerActive implements Predicate<Server> {
-
- private final CloudServersClient client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public ServerActive(CloudServersClient client) {
- this.client = client;
- }
-
- public boolean apply(Server server) {
- logger.trace("looking for state on server %s", checkNotNull(server, "server"));
- server = refresh(server);
- if (server == null)
- return false;
- logger.trace("%s: looking for server state %s: currently: %s", server.getId(),
- ServerStatus.ACTIVE, server.getStatus());
- return server.getStatus() == ServerStatus.ACTIVE;
- }
-
- private Server refresh(Server server) {
- return client.getServer(server.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
deleted file mode 100644
index 69cdc53..0000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/predicates/ServerDeleted.java
+++ /dev/null
@@ -1,64 +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.cloudservers.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.annotation.Resource;
-import javax.inject.Singleton;
-
-import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.logging.Logger;
-
-import com.google.common.base.Predicate;
-import com.google.inject.Inject;
-
-/**
- *
- * Tests to see if a task succeeds.
- *
- * @author Adrian Cole
- */
-@Singleton
-public class ServerDeleted implements Predicate<Server> {
-
- private final CloudServersClient client;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public ServerDeleted(CloudServersClient client) {
- this.client = client;
- }
-
- public boolean apply(Server server) {
- logger.trace("looking for state on server %s", checkNotNull(server, "server"));
- server = refresh(server);
- if (server == null)
- return true;
- logger.trace("%s: looking for server state %s: currently: %s", server.getId(),
- ServerStatus.DELETED, server.getStatus());
- return server.getStatus() == ServerStatus.DELETED;
- }
-
- private Server refresh(Server server) {
- return client.getServer(server.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
deleted file mode 100644
index 417ed21..0000000
--- a/apis/cloudservers/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.cloudservers.CloudServersApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
deleted file mode 100644
index 2024dea..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
+++ /dev/null
@@ -1,32 +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.cloudservers;
-
-import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
-public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest {
-
- public CloudServersApiMetadataTest() {
- super(new CloudServersApiMetadata());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
deleted file mode 100644
index 297f10a..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
+++ /dev/null
@@ -1,904 +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.cloudservers;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withMetadata;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
-import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.changesSince;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails;
-import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage;
-import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.inject.Singleton;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudservers.config.CloudServersRestClientModule;
-import org.jclouds.cloudservers.domain.BackupSchedule;
-import org.jclouds.cloudservers.domain.DailyBackup;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.jclouds.cloudservers.domain.WeeklyBackup;
-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.domain.Credentials;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.http.functions.ReturnTrueIf2xx;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.openstack.filters.AddTimestampQuery;
-import org.jclouds.openstack.filters.AuthenticateRequest;
-import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth;
-import org.jclouds.openstack.keystone.v1_1.domain.Auth;
-import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
-import org.jclouds.rest.ConfiguresRestClient;
-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.ImmutableMap;
-import com.google.common.reflect.Invokable;
-import com.google.inject.Module;
-import com.google.inject.Provides;
-/**
- * Tests behavior of {@code CloudServersAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
-public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServersAsyncClient> {
-
- public void testCreateServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withSharedIpGroup(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCreateServerWithFile() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor
- .createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1, withFile("/etc/jclouds", "foo".getBytes())));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(
- request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"personality\":[{\"path\":\"/etc/jclouds\",\"contents\":\"Zm9v\"}]}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithMetadata() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
- withMetadata(ImmutableMap.of("foo", "bar"))));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"metadata\":{\"foo\":\"bar\"}}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateServerWithIpGroupAndSharedIp() throws IOException, SecurityException, NoSuchMethodException,
- UnknownHostException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createServer", String.class, int.class, int.class,
- CreateServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2, 1,
- withSharedIpGroup(2).withSharedIp("127.0.0.1")));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(
- request,
- "{\"server\":{\"name\":\"ralphie\",\"imageId\":2,\"flavorId\":1,\"sharedIpGroupId\":2,\"addresses\":{\"public\":[\"127.0.0.1\"]}}}",
- "application/json", false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "deleteImage", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testLimits() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getLimits");
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/limits?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListServers() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- Date now = new Date(10000000l);
-
- public void testListServersOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListServersDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listServers", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFlavorsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listFlavors", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetFlavor() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getFlavor", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/flavors/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImages() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListImagesDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listImages", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getImage", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "deleteServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testShareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class,
- boolean.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":false}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testShareIpConfig() throws IOException, SecurityException, NoSuchMethodException, UnknownHostException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "shareIp", String.class, int.class, int.class,
- boolean.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, true));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testUnshareIpNoConfig() throws IOException, SecurityException, NoSuchMethodException,
- UnknownHostException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "unshareIp", String.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("127.0.0.1", 2, 3, false));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public/127.0.0.1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(request);
-
- }
-
- public void testReplaceBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "replaceBackupSchedule", int.class, BackupSchedule.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, BackupSchedule.builder().weekly(WeeklyBackup.MONDAY)
- .daily(DailyBackup.H_0800_1000).enabled(true).build()));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request,
- "{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
-
- }
-
- public void testDeleteBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "deleteBackupSchedule", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
-
- }
-
- public void testChangeAdminPass() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "changeAdminPass", int.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"server\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testChangeServerName() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "renameServer", int.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, "foo"));
-
- assertRequestLineEquals(request, "PUT https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testListSharedIpGroups() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsDetail() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails()));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListSharedIpGroupsDetailOptions() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listSharedIpGroups", ListOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(withDetails().changesSince(now).maxResults(1).startAt(2)));
-
- assertRequestLineEquals(request,
- "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/detail?format=json&changes-since=10000&limit=1&offset=2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getSharedIpGroup", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testCreateSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class,
- CreateSharedIpGroupOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie"));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testCreateSharedIpGroupWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createSharedIpGroup", String.class,
- CreateSharedIpGroupOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", withServer(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"sharedIpGroup\":{\"name\":\"ralphie\",\"server\":2}}",
- MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteSharedIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "deleteSharedIpGroup", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "DELETE https://lon.servers.api.rackspacecloud.com/v1.0/10001786/shared_ip_groups/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, FalseOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testListPublicAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listPublicAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/public?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListPrivateAddresses() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "listPrivateAddresses", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/ips/private?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListBackupSchedule() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "getBackupSchedule", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "GET https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/backup_schedule?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testCreateImageWithIpGroup() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "createImageFromServer", String.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("ralphie", 2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
- assertPayloadEquals(request, "{\"image\":{\"serverId\":2,\"name\":\"ralphie\"}}", MediaType.APPLICATION_JSON,
- false);
-
- assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testRebuildServer() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "rebuildServer", int.class,
- RebuildServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testRebuildServerWithImage() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "rebuildServer", int.class,
- RebuildServerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(3, withImage(2)));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/3/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"rebuild\":{\"imageId\":2}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testReboot() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "rebootServer", int.class, RebootType.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, RebootType.HARD));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testResize() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "resizeServer", int.class, int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, 3));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
-
- }
-
- public void testConfirmResize() throws IOException, IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "confirmResizeServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testRevertResize() throws IOException, SecurityException, NoSuchMethodException {
- Invokable<?, ?> method = method(CloudServersAsyncClient.class, "revertResizeServer", int.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2));
-
- assertRequestLineEquals(request, "POST https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/2/action?format=json HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 2);
- assertEquals(request.getFilters().get(0).getClass(), AuthenticateRequest.class);
- assertEquals(request.getFilters().get(1).getClass(), AddTimestampQuery.class);
-
- }
-
- @Override
- protected Module createModule() {
- return new TestCloudServersRestClientModule();
- }
-
- @ConfiguresRestClient
- protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
-
- @Provides
- @Singleton
- GetAuth provideGetAuth() {
- return new GetAuth(null) {
- @Override
- public Auth load(Credentials in) {
- return new ParseAuthTest().expected();
- }
- };
- }
-
- }
-
- protected String provider = "cloudservers";
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new CloudServersApiMetadata();
- }
-
- @Override
- protected Properties setupProperties() {
- Properties overrides = new Properties();
- overrides.setProperty(PROPERTY_REGIONS, "US");
- overrides.setProperty(PROPERTY_API_VERSION, "1");
- overrides.setProperty(provider + ".endpoint", "https://auth");
- return overrides;
- }
-}