Updated names for add/remove in GleSYS IP client.

This commit is contained in:
Mattias Holmqvist 2012-01-07 23:37:28 +01:00
parent 948a004b60
commit ad2c2a03e0
3 changed files with 61 additions and 61 deletions

View File

@ -64,8 +64,8 @@ public interface IpAsyncClient {
*/ */
@POST @POST
@Path("/ip/add/format/json") @Path("/ip/add/format/json")
ListenableFuture<Void> add(@FormParam("serverid") String serverId, ListenableFuture<Void> addIpToServer(@FormParam("ipaddress") String ipAddress,
@FormParam("ipaddress") String ipAddress); @FormParam("serverid") String serverId);
/** /**
@ -75,7 +75,7 @@ public interface IpAsyncClient {
*/ */
@POST @POST
@Path("/ip/remove/format/json") @Path("/ip/remove/format/json")
ListenableFuture<Void> remove(@FormParam("ipaddress") String ipAddress, ListenableFuture<Void> removeIpFromServer(@FormParam("ipaddress") String ipAddress,
@FormParam("serverid") String serverId); @FormParam("serverid") String serverId);

View File

@ -35,61 +35,60 @@ import java.util.concurrent.TimeUnit;
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface IpClient { public interface IpClient {
/** /**
* Take a free IP address and add it to this account. You can list free IP addresses with the function listFree(). * Take a free IP address and add it to this account. You can list free IP addresses with the function listFree().
* Once your free IP on this account you can add it to a server with the add() function. * Once your free IP on this account you can add it to a server with the add() function.
* *
* @param ipAddress * @param ipAddress
* @return */
*/ void take(String ipAddress);
void take(String ipAddress);
/** /**
* Return an unused IP address to the pool of free ips. If the IP address is allocated to a server, * Return an unused IP address to the pool of free ips. If the IP address is allocated to a server,
* it must first be removed by calling remove(ipAddress) before it can be released. * it must first be removed by calling remove(ipAddress) before it can be released.
* *
* @param ipAddress the IP address to be released * @param ipAddress the IP address to be released
*/ */
void release(String ipAddress); void release(String ipAddress);
/** /**
* Add an IP address to an server. The IP has to be free, but reserved to this account. You are able to list such addresses * Add an IP address to an server. The IP has to be free, but reserved to this account. You are able to list such addresses
* with listOwn() and reserve an address for this account by using take(). To find free ips you can use ip/listfree * with listOwn() and reserve an address for this account by using take(). To find free ips you can use ip/listfree
* ip to an Xen-server you have to configure the server yourself, unless the ip was added during the c * ip to an Xen-server you have to configure the server yourself, unless the ip was added during the c
* server (server/create). You can get detailed information such as gateway and netmask using the ip * server (server/create). You can get detailed information such as gateway and netmask using the ip
* *
* @param serverId the server to add the IP address to * @param ipAddress the IP address to remove
* @param ipAddress the IP address to remove * @param serverId the server to add the IP address to
*/ */
void add(String serverId, String ipAddress); void addIpToServer(String ipAddress, String serverId);
/** /**
* Remove an IP address from a server. This does not release it back to GleSYS pool of free ips. The address will be * Remove an IP address from a server. This does not release it back to GleSYS pool of free ips. The address will be
* kept on the account so that you can use it for other servers or the same server at a later time. To completely remove * kept on the account so that you can use it for other servers or the same server at a later time. To completely remove
* the IP address from this account, use the function release(). * the IP address from this account, use the function release().
* *
* @param ipAddress the IP address to remove * @param ipAddress the IP address to remove
* @param serverId the server to remove the IP address from * @param serverId the server to remove the IP address from
*/ */
void remove(String ipAddress, String serverId); void removeIpFromServer(String ipAddress, String serverId);
/** /**
* Get a set of all IP addresses that are available and not used on any account or server. * Get a set of all IP addresses that are available and not used on any account or server.
* *
* @param ipversion "4" or "6", for IPV4 or IPV6, respectively * @param ipversion "4" or "6", for IPV4 or IPV6, respectively
* @param datacenter the datacenter * @param datacenter the datacenter
* @param platform the platform * @param platform the platform
* @return a set of free IP addresses * @return a set of free IP addresses
*/ */
Set<String> listFree(String ipversion, String datacenter, String platform); Set<String> listFree(String ipversion, String datacenter, String platform);
/** /**
* Get details about the given IP address such as gateway and netmask. Different details are available * Get details about the given IP address such as gateway and netmask. Different details are available
* on different platforms. * on different platforms.
* *
* @param ipAddress the ip address * @param ipAddress the ip address
* @return details about the given IP address * @return details about the given IP address
*/ */
IpDetails getIpDetails(String ipAddress); IpDetails getIpDetails(String ipAddress);
} }

View File

@ -180,12 +180,12 @@ public class IpClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build()) "Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
.payload(newUrlEncodedFormPayload( .payload(newUrlEncodedFormPayload(
ImmutableMultimap.<String, String>builder() ImmutableMultimap.<String, String>builder()
.put("serverid", "vz1946889") .put("ipaddress", "31.192.227.37")
.put("ipaddress", "31.192.227.37").build())).build(), .put("serverid", "vz1946889").build())).build(),
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getIpClient(); .getIpClient();
client.add("vz1946889", "31.192.227.37"); client.addIpToServer("31.192.227.37", "vz1946889");
} }
public void testAddWhenResponseIs4xxThrowsHttpException() { public void testAddWhenResponseIs4xxThrowsHttpException() {
@ -196,13 +196,14 @@ public class IpClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
"Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build()) "Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build())
.payload(newUrlEncodedFormPayload( .payload(newUrlEncodedFormPayload(
ImmutableMultimap.<String, String>builder() ImmutableMultimap.<String, String>builder()
.put("ipaddress", "31.192.227.37")
.put("serverid", "vz1946889") .put("serverid", "vz1946889")
.put("ipaddress", "31.192.227.37").build())).build(), .build())).build(),
HttpResponse.builder().statusCode(400).build()) HttpResponse.builder().statusCode(400).build())
.getIpClient(); .getIpClient();
try { try {
client.add("vz1946889", "31.192.227.37"); client.addIpToServer("31.192.227.37", "vz1946889");
fail(); fail();
} catch (HttpResponseException e) { } catch (HttpResponseException e) {
// Expected // Expected
@ -222,7 +223,7 @@ public class IpClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
HttpResponse.builder().statusCode(200).build()) HttpResponse.builder().statusCode(200).build())
.getIpClient(); .getIpClient();
client.remove("31.192.227.37", "vz1946889"); client.removeIpFromServer("31.192.227.37", "vz1946889");
} }
public void testRemoveWhenResponseIs4xxThrowsHttpException() { public void testRemoveWhenResponseIs4xxThrowsHttpException() {
@ -239,7 +240,7 @@ public class IpClientExpectTest extends BaseRestClientExpectTest<GleSYSClient> {
.getIpClient(); .getIpClient();
try { try {
client.remove("31.192.227.37", "vz1946889"); client.removeIpFromServer("31.192.227.37", "vz1946889");
fail(); fail();
} catch (HttpResponseException e) { } catch (HttpResponseException e) {
// Expected // Expected