Remove async from gogrid

This commit is contained in:
Andrew Bayer 2013-08-02 07:57:07 -07:00
parent a2af31c419
commit d4bf51128e
35 changed files with 509 additions and 992 deletions

View File

@ -18,46 +18,46 @@ package org.jclouds.gogrid;
import java.io.Closeable; import java.io.Closeable;
import org.jclouds.gogrid.services.GridImageClient; import org.jclouds.gogrid.features.GridImageApi;
import org.jclouds.gogrid.services.GridIpClient; import org.jclouds.gogrid.features.GridIpApi;
import org.jclouds.gogrid.services.GridJobClient; import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.gogrid.services.GridLoadBalancerClient; import org.jclouds.gogrid.features.GridLoadBalancerApi;
import org.jclouds.gogrid.services.GridServerClient; import org.jclouds.gogrid.features.GridServerApi;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
/** /**
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
public interface GoGridClient extends Closeable { public interface GoGridApi extends Closeable {
/** /**
* Services with methods, related to managing servers * Services with methods, related to managing servers
*/ */
@Delegate @Delegate
GridServerClient getServerServices(); GridServerApi getServerServices();
/** /**
* Services with methods, related to retrieving jobs * Services with methods, related to retrieving jobs
*/ */
@Delegate @Delegate
GridJobClient getJobServices(); GridJobApi getJobServices();
/** /**
* Services with methods, related to retrieving IP addresses * Services with methods, related to retrieving IP addresses
*/ */
@Delegate @Delegate
GridIpClient getIpServices(); GridIpApi getIpServices();
/** /**
* Services with methods, related to managing load balancers. * Services with methods, related to managing load balancers.
*/ */
@Delegate @Delegate
GridLoadBalancerClient getLoadBalancerServices(); GridLoadBalancerApi getLoadBalancerServices();
/** /**
* Services with methods, related to managing images. * Services with methods, related to managing images.
*/ */
@Delegate @Delegate
GridImageClient getImageServices(); GridImageApi getImageServices();
} }

View File

@ -24,11 +24,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule; import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule;
import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.config.GoGridHttpApiModule;
import org.jclouds.rest.internal.BaseRestApiMetadata; import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -36,16 +35,7 @@ import com.google.inject.Module;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class GoGridApiMetadata extends BaseRestApiMetadata { public class GoGridApiMetadata extends BaseHttpApiMetadata<GoGridApi> {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GoGridClient.class)} as
* {@link GoGridAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<GoGridClient, GoGridAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<GoGridClient, GoGridAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@Override @Override
public Builder toBuilder() { public Builder toBuilder() {
@ -61,17 +51,16 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
} }
public static Properties defaultProperties() { public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties(); Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5"); properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true"); properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties; return properties;
} }
public static class Builder extends BaseRestApiMetadata.Builder<Builder> { public static class Builder extends BaseHttpApiMetadata.Builder<GoGridApi, Builder> {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
protected Builder() { protected Builder() {
super(GoGridClient.class, GoGridAsyncClient.class);
id("gogrid") id("gogrid")
.name("GoGrid API") .name("GoGrid API")
.identityName("API Key") .identityName("API Key")
@ -81,7 +70,7 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.gogrid.com/api") .defaultEndpoint("https://api.gogrid.com/api")
.defaultProperties(GoGridApiMetadata.defaultProperties()) .defaultProperties(GoGridApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class)) .view(typeToken(ComputeServiceContext.class))
.defaultModules(ImmutableSet.<Class<? extends Module>>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class)); .defaultModules(ImmutableSet.<Class<? extends Module>>of(GoGridHttpApiModule.class, GoGridComputeServiceContextModule.class));
} }
@Override @Override

View File

@ -1,66 +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.gogrid;
import java.io.Closeable;
import org.jclouds.gogrid.services.GridImageAsyncClient;
import org.jclouds.gogrid.services.GridIpAsyncClient;
import org.jclouds.gogrid.services.GridJobAsyncClient;
import org.jclouds.gogrid.services.GridLoadBalancerAsyncClient;
import org.jclouds.gogrid.services.GridServerAsyncClient;
import org.jclouds.rest.annotations.Delegate;
/**
* @author Oleksiy Yarmula
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GoGridClient.class)} as
* {@link GoGridAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface GoGridAsyncClient extends Closeable {
/**
* @see GoGridClient#getServerServices()
*/
@Delegate
GridServerAsyncClient getServerServices();
/**
* @see GoGridClient#getJobServices()
*/
@Delegate
GridJobAsyncClient getJobServices();
/**
* @see GoGridClient#getIpServices()
*/
@Delegate
GridIpAsyncClient getIpServices();
/**
* @see GoGridClient#getLoadBalancerServices()
*/
@Delegate
GridLoadBalancerAsyncClient getLoadBalancerServices();
/**
* @see GoGridClient#getImageServices()
*/
@Delegate
GridImageAsyncClient getImageServices();
}

View File

@ -25,7 +25,7 @@ import org.jclouds.rest.Binder;
/** /**
* *
* @see org.jclouds.gogrid.services.GridJobClient#getJobsForObjectName(String) * @see org.jclouds.gogrid.features.GridJobApi#getJobsForObjectName(String)
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */

View File

@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.compute.suppliers.GoGridHardwareSupplier; import org.jclouds.gogrid.compute.suppliers.GoGridHardwareSupplier;
import org.jclouds.gogrid.domain.Ip; import org.jclouds.gogrid.domain.Ip;
import org.jclouds.gogrid.domain.IpType; import org.jclouds.gogrid.domain.IpType;
@ -48,12 +48,11 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
/** /**
* defines the connection between the {@link GoGridClient} implementation and the jclouds * defines the connection between the {@link org.jclouds.gogrid.GoGridApi} implementation and the jclouds
* {@link ComputeService} * {@link ComputeService}
* *
*/ */
@ -63,13 +62,13 @@ public class GoGridComputeServiceAdapter implements ComputeServiceAdapter<Server
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
private final GoGridClient client; private final GoGridApi client;
private final Function<Hardware, String> sizeToRam; private final Function<Hardware, String> sizeToRam;
private final Predicate<Server> serverLatestJobCompleted; private final Predicate<Server> serverLatestJobCompleted;
private final Predicate<Server> serverLatestJobCompletedShort; private final Predicate<Server> serverLatestJobCompletedShort;
@Inject @Inject
protected GoGridComputeServiceAdapter(GoGridClient client, Function<Hardware, String> sizeToRam, Timeouts timeouts) { protected GoGridComputeServiceAdapter(GoGridApi client, Function<Hardware, String> sizeToRam, Timeouts timeouts) {
this.client = checkNotNull(client, "client"); this.client = checkNotNull(client, "client");
this.sizeToRam = checkNotNull(sizeToRam, "sizeToRam"); this.sizeToRam = checkNotNull(sizeToRam, "sizeToRam");
this.serverLatestJobCompleted = retry(new ServerLatestJobCompleted(client.getJobServices()), this.serverLatestJobCompleted = retry(new ServerLatestJobCompleted(client.getJobServices()),

View File

@ -18,37 +18,24 @@ package org.jclouds.gogrid.config;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.gogrid.GoGridAsyncClient; import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.GoGridClient;
import org.jclouds.gogrid.handlers.GoGridErrorHandler; import org.jclouds.gogrid.handlers.GoGridErrorHandler;
import org.jclouds.gogrid.location.GoGridDefaultLocationSupplier; import org.jclouds.gogrid.location.GoGridDefaultLocationSupplier;
import org.jclouds.gogrid.services.GridImageAsyncClient;
import org.jclouds.gogrid.services.GridImageClient;
import org.jclouds.gogrid.services.GridIpAsyncClient;
import org.jclouds.gogrid.services.GridIpClient;
import org.jclouds.gogrid.services.GridJobAsyncClient;
import org.jclouds.gogrid.services.GridJobClient;
import org.jclouds.gogrid.services.GridLoadBalancerAsyncClient;
import org.jclouds.gogrid.services.GridLoadBalancerClient;
import org.jclouds.gogrid.services.GridServerAsyncClient;
import org.jclouds.gogrid.services.GridServerClient;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.HttpApiModule;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Scopes; import com.google.inject.Scopes;
@ -59,18 +46,7 @@ import com.google.inject.Scopes;
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@ConfiguresRestClient @ConfiguresRestClient
public class GoGridRestClientModule extends RestClientModule<GoGridClient, GoGridAsyncClient> { public class GoGridHttpApiModule extends HttpApiModule<GoGridApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
.put(GridServerClient.class, GridServerAsyncClient.class)//
.put(GridJobClient.class, GridJobAsyncClient.class)//
.put(GridIpClient.class, GridIpAsyncClient.class)//
.put(GridLoadBalancerClient.class, GridLoadBalancerAsyncClient.class)//
.put(GridImageClient.class, GridImageAsyncClient.class)//
.build();
public GoGridRestClientModule() {
super(DELEGATE_MAP);
}
@Provides @Provides
@TimeStamp @TimeStamp

View File

@ -27,7 +27,7 @@ package org.jclouds.gogrid.domain;
* <li>Restart</li> * <li>Restart</li>
* </ul> * </ul>
* *
* @see org.jclouds.gogrid.services.GridServerClient#power(String, PowerCommand) * @see org.jclouds.gogrid.features.GridServerApi#power(String, PowerCommand)
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.server.power" /> * @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.server.power" />
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION; import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY; import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
@ -30,7 +30,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks;
import org.jclouds.gogrid.binders.BindIdsToQueryParams; import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams; import org.jclouds.gogrid.binders.BindNamesToQueryParams;
import org.jclouds.gogrid.domain.Option; import org.jclouds.gogrid.domain.Option;
@ -47,81 +47,123 @@ import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/** /**
* Manages the server images
*
* @see <a
* href="http://wiki.gogrid.com/wiki/index.php/API#Server_Image_Methods"/>
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@RequestFilters(SharedKeyLiteAuthentication.class) @RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "{jclouds.api-version}") @QueryParams(keys = VERSION, values = "{jclouds.api-version}")
public interface GridImageAsyncClient { public interface GridImageApi {
/** /**
* @see GridImageClient#getImageList * Returns all server images.
*
* @param options
* options to narrow the search down
* @return server images found
*/ */
@GET @GET
@ResponseParser(ParseImageListFromJsonResponse.class) @ResponseParser(ParseImageListFromJsonResponse.class)
@Path("/grid/image/list") @Path("/grid/image/list")
ListenableFuture<Set<ServerImage>> getImageList(GetImageListOptions... options); Set<ServerImage> getImageList(GetImageListOptions... options);
/** /**
* @see GridImageClient#getImagesById * Returns images, found by specified ids
*
* @param ids
* the ids that match existing images
* @return images found
*/ */
@GET @GET
@ResponseParser(ParseImageListFromJsonResponse.class) @ResponseParser(ParseImageListFromJsonResponse.class)
@Path("/grid/image/get") @Path("/grid/image/get")
ListenableFuture<Set<ServerImage>> getImagesById(@BinderParam(BindIdsToQueryParams.class) Long... ids); Set<ServerImage> getImagesById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
/** /**
* @see GridImageClient#getImagesByName * Returns images, found by specified names
*
* @param names
* the names that march existing images
* @return images found
*/ */
@GET @GET
@ResponseParser(ParseImageListFromJsonResponse.class) @ResponseParser(ParseImageListFromJsonResponse.class)
@Path("/grid/image/get") @Path("/grid/image/get")
ListenableFuture<Set<ServerImage>> getImagesByName(@BinderParam(BindNamesToQueryParams.class) String... names); Set<ServerImage> getImagesByName(@BinderParam(BindNamesToQueryParams.class) String... names);
/** /**
* @see GridImageClient#editImageDescription * Edits an existing image
*
* @param idOrName
* id or name of the existing image
* @param newDescription
* description to replace the current one
* @return edited server image
*/ */
@GET @GET
@ResponseParser(ParseImageFromJsonResponse.class) @ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/edit") @Path("/grid/image/edit")
ListenableFuture<ServerImage> editImageDescription(@QueryParam(IMAGE_KEY) String idOrName, ServerImage editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
@QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription); @QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription);
/** /**
* @see GridImageClient#editImageFriendlyName * Edits an existing image
*
* @param idOrName
* id or name of the existing image
* @param newFriendlyName
* friendly name to replace the current one
* @return edited server image
*/ */
@GET @GET
@ResponseParser(ParseImageFromJsonResponse.class) @ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/edit") @Path("/grid/image/edit")
ListenableFuture<ServerImage> editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName, ServerImage editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName); @QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName);
/** /**
* @see GridImageClient#getDatacenters * Retrieves the list of supported Datacenters to save images in. The objects
* will have datacenter ID, name and description. In most cases, id or name
* will be used for {@link #getImageList}.
*
* @return supported datacenters
*/ */
@GET @GET
@ResponseParser(ParseOptionsFromJsonResponse.class) @ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list") @Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "datacenter") @QueryParams(keys = LOOKUP_LIST_KEY, values = "datacenter")
ListenableFuture<Set<Option>> getDatacenters(); Set<Option> getDatacenters();
/** /**
* @see GridImageClient#deleteById(Long) * Deletes an existing image
*
* @param id
* id of the existing image
*/ */
@GET @GET
@ResponseParser(ParseImageFromJsonResponse.class) @ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/delete") @Path("/grid/image/delete")
@Fallback(NullOnNotFoundOr404.class) @Fallback(Fallbacks.NullOnNotFoundOr404.class)
ListenableFuture<ServerImage> deleteById(@QueryParam(ID_KEY) long id); ServerImage deleteById(@QueryParam(ID_KEY) long id);
/** /**
* @see GridImageClient#saveImageFromServer * This call will save a private (visible to only you) server image to your
* library of available images. The image will be saved from an existing
* server.
*
* @param idOrName
* id or name of the existing server
* @param friendlyName
* friendly name of the image
* @return saved server image
*/ */
@GET @GET
@ResponseParser(ParseImageFromJsonResponse.class) @ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/save") @Path("/grid/image/save")
ListenableFuture<ServerImage> saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName, ServerImage saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName,
@QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName, SaveImageOptions... options); @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName, SaveImageOptions... options);
} }

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION; import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_STATE_KEY; import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_STATE_KEY;
@ -36,59 +36,72 @@ import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/** /**
* @see org.jclouds.gogrid.services.GridImageClient
*
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@RequestFilters(SharedKeyLiteAuthentication.class) @RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "{jclouds.api-version}") @QueryParams(keys = VERSION, values = "{jclouds.api-version}")
public interface GridIpAsyncClient { public interface GridIpApi {
/** /**
* @see GridIpClient#getIpList(org.jclouds.gogrid.options.GetIpListOptions...) * Returns all IPs in the system that match the options
*
* @param options
* options to narrow the search down
* @return IPs found by the search
*/ */
@GET @GET
@ResponseParser(ParseIpListFromJsonResponse.class) @ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list") @Path("/grid/ip/list")
ListenableFuture<Set<Ip>> getIpList(GetIpListOptions... options); Set<Ip> getIpList(GetIpListOptions... options);
/** /**
* @see org.jclouds.gogrid.services.GridIpClient#getUnassignedIpList() * Returns the list of unassigned IPs.
*
* NOTE: this returns both public and private IPs!
*
* @return unassigned IPs
*/ */
@GET @GET
@ResponseParser(ParseIpListFromJsonResponse.class) @ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list") @Path("/grid/ip/list")
@QueryParams(keys = IP_STATE_KEY, values = "Unassigned") @QueryParams(keys = IP_STATE_KEY, values = "Unassigned")
ListenableFuture<Set<Ip>> getUnassignedIpList(); Set<Ip> getUnassignedIpList();
/** /**
* @see org.jclouds.gogrid.services.GridIpClient#getUnassignedPublicIpList() * Returns the list of unassigned public IPs.
*
* @return unassigned public IPs
*/ */
@GET @GET
@ResponseParser(ParseIpListFromJsonResponse.class) @ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list") @Path("/grid/ip/list")
@QueryParams(keys = { IP_STATE_KEY, IP_TYPE_KEY }, values = { "Unassigned", "Public" }) @QueryParams(keys = { IP_STATE_KEY, IP_TYPE_KEY }, values = { "Unassigned", "Public" })
ListenableFuture<Set<Ip>> getUnassignedPublicIpList(); Set<Ip> getUnassignedPublicIpList();
/** /**
* @see org.jclouds.gogrid.services.GridIpClient#getAssignedIpList() * Returns the list of assigned IPs
*
* NOTE: this returns both public and private IPs!
*
* @return assigned IPs
*/ */
@GET @GET
@ResponseParser(ParseIpListFromJsonResponse.class) @ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list") @Path("/grid/ip/list")
@QueryParams(keys = IP_STATE_KEY, values = "Assigned") @QueryParams(keys = IP_STATE_KEY, values = "Assigned")
ListenableFuture<Set<Ip>> getAssignedIpList(); Set<Ip> getAssignedIpList();
/** /**
* Retrieves the list of supported Datacenters to retrieve ips from. The objects will have
* datacenter ID, name and description. In most cases, id or name will be used for
* {@link #addServer}.
* *
* @see org.jclouds.gogrid.services.GridIpClient#getDatacenters * @return supported datacenters
*/ */
@GET @GET
@ResponseParser(ParseOptionsFromJsonResponse.class) @ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list") @Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "ip.datacenter") @QueryParams(keys = LOOKUP_LIST_KEY, values = "ip.datacenter")
ListenableFuture<Set<Option>> getDatacenters(); Set<Option> getDatacenters();
} }

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION; import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
@ -34,38 +34,60 @@ import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/** /**
* Manages the customer's jobs.
*
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API#Job_Methods" />
*
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@RequestFilters(SharedKeyLiteAuthentication.class) @RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "{jclouds.api-version}") @QueryParams(keys = VERSION, values = "{jclouds.api-version}")
public interface GridJobAsyncClient { public interface GridJobApi {
/** /**
* @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...) * Returns all jobs found. The resulting set may be narrowed down by providing
* {@link GetJobListOptions}.
*
* By default, the result is <=100 items from the date range of 4 weeks ago to now.
*
* NOTE: this method results in a big volume of data in response
*
* @return jobs found by request
*/ */
@GET @GET
@ResponseParser(ParseJobListFromJsonResponse.class) @ResponseParser(ParseJobListFromJsonResponse.class)
@Path("/grid/job/list") @Path("/grid/job/list")
ListenableFuture<Set<Job>> getJobList(GetJobListOptions... options); Set<Job> getJobList(GetJobListOptions... options);
/** /**
* @see GridJobClient#getJobsForObjectName(String) * Returns jobs found for an object with a provided name.
*
* Usually, in GoGrid a name will uniquely identify the object, or, as the docs state, some API
* methods will cause errors.
*
* @param objectName
* name of the object
* @return found jobs for the object
*/ */
@GET @GET
@ResponseParser(ParseJobListFromJsonResponse.class) @ResponseParser(ParseJobListFromJsonResponse.class)
@Path("/grid/job/list") @Path("/grid/job/list")
ListenableFuture<Set<Job>> getJobsForObjectName( Set<Job> getJobsForObjectName(
@BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName); @BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName);
/** /**
* @see GridJobClient#getJobsById * Returns jobs for the corresponding id(s).
*
* NOTE: there is a 1:1 relation between a job and its ID.
*
* @param ids
* ids for the jobs
* @return jobs found by the ids
*/ */
@GET @GET
@ResponseParser(ParseJobListFromJsonResponse.class) @ResponseParser(ParseJobListFromJsonResponse.class)
@Path("/grid/job/get") @Path("/grid/job/get")
ListenableFuture<Set<Job>> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids); Set<Job> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids);
} }

View File

@ -14,25 +14,53 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
import org.jclouds.gogrid.binders.BindRealIpPortPairsToQueryParams;
import org.jclouds.gogrid.binders.BindVirtualIpPortPairToQueryParams;
import org.jclouds.gogrid.domain.IpPortPair; import org.jclouds.gogrid.domain.IpPortPair;
import org.jclouds.gogrid.domain.LoadBalancer; import org.jclouds.gogrid.domain.LoadBalancer;
import org.jclouds.gogrid.domain.Option; import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
import org.jclouds.gogrid.options.AddLoadBalancerOptions; import org.jclouds.gogrid.options.AddLoadBalancerOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
/** /**
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
public interface GridLoadBalancerClient { @RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
public interface GridLoadBalancerApi {
/** /**
* Returns all load balancers found for the current user. * Returns all load balancers found for the current user.
* *
* @return load balancers found * @return load balancers found
*/ */
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/list")
Set<LoadBalancer> getLoadBalancerList(); Set<LoadBalancer> getLoadBalancerList();
/** /**
@ -44,7 +72,11 @@ public interface GridLoadBalancerClient {
* to get the load balancers * to get the load balancers
* @return load balancer(s) matching the name(s) * @return load balancer(s) matching the name(s)
*/ */
Set<LoadBalancer> getLoadBalancersByName(String... names); @GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
Set<LoadBalancer> getLoadBalancersByName(
@BinderParam(BindNamesToQueryParams.class) String... names);
/** /**
* Returns the load balancer(s) by unique id(s). * Returns the load balancer(s) by unique id(s).
@ -55,7 +87,11 @@ public interface GridLoadBalancerClient {
* to get the load balancers * to get the load balancers
* @return load balancer(s) matching the ids * @return load balancer(s) matching the ids
*/ */
Set<LoadBalancer> getLoadBalancersById(Long... ids); @GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
Set<LoadBalancer> getLoadBalancersById(
@BinderParam(BindIdsToQueryParams.class) Long... ids);
/** /**
* Creates a load balancer with given properties. * Creates a load balancer with given properties.
@ -73,32 +109,45 @@ public interface GridLoadBalancerClient {
* strategy, or description. * strategy, or description.
* @return created load balancer object * @return created load balancer object
*/ */
LoadBalancer addLoadBalancer(String name, IpPortPair virtualIp, List<IpPortPair> realIps, @GET
AddLoadBalancerOptions... options); @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/add")
LoadBalancer addLoadBalancer(@QueryParam(NAME_KEY) String name,
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/** /**
* Edits the existing load balancer to change the real IP mapping. * Edits the existing load balancer to change the real IP mapping.
* *
* @param id * @param name
* id of the existing load balancer * id of the existing load balancer
* @param realIps * @param realIps
* real IPs to bind the virtual IP to, with IP address set in * real IPs to bind the virtual IP to, with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port} * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
* @return edited object * @return edited object
*/ */
LoadBalancer editLoadBalancer(long id, List<IpPortPair> realIps); @GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
LoadBalancer editLoadBalancerNamed(@QueryParam(NAME_KEY) String name,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/** /**
* Edits the existing load balancer to change the real IP mapping. * Edits the existing load balancer to change the real IP mapping.
* *
* @param name * @param id
* name of the existing load balancer * name of the existing load balancer
* @param realIps * @param realIps
* real IPs to bind the virtual IP to, with IP address set in * real IPs to bind the virtual IP to, with IP address set in
* {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port} * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
* @return edited object * @return edited object
*/ */
LoadBalancer editLoadBalancerNamed(String name, List<IpPortPair> realIps); @GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
LoadBalancer editLoadBalancer(@QueryParam(ID_KEY) long id,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/** /**
* Deletes the load balancer by Id * Deletes the load balancer by Id
@ -107,7 +156,10 @@ public interface GridLoadBalancerClient {
* id of the load balancer to delete * id of the load balancer to delete
* @return load balancer before the command is executed * @return load balancer before the command is executed
*/ */
LoadBalancer deleteById(Long id); @GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
LoadBalancer deleteById(@QueryParam(ID_KEY) Long id);
/** /**
* Deletes the load balancer by name; * Deletes the load balancer by name;
@ -120,7 +172,10 @@ public interface GridLoadBalancerClient {
* *
* @return load balancer before the command is executed * @return load balancer before the command is executed
*/ */
LoadBalancer deleteByName(String name); @GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
LoadBalancer deleteByName(@QueryParam(NAME_KEY) String name);
/** /**
* Retrieves the list of supported Datacenters to launch servers into. The objects will have * Retrieves the list of supported Datacenters to launch servers into. The objects will have
@ -129,6 +184,10 @@ public interface GridLoadBalancerClient {
* *
* @return supported datacenters * @return supported datacenters
*/ */
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "loadbalancer.datacenter")
Set<Option> getDatacenters(); Set<Option> getDatacenters();
} }

View File

@ -14,28 +14,58 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
import org.jclouds.gogrid.domain.Option; import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.domain.PowerCommand; import org.jclouds.gogrid.domain.PowerCommand;
import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
import org.jclouds.gogrid.options.AddServerOptions; import org.jclouds.gogrid.options.AddServerOptions;
import org.jclouds.gogrid.options.GetServerListOptions; import org.jclouds.gogrid.options.GetServerListOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
/** /**
* Provides synchronous access to GoGrid. * Provides synchronous access to GoGrid.
* <p/> * <p/>
* *
* @see GridServerAsyncClient
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API" /> * @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
* *
* @author Adrian Cole * @author Adrian Cole
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
public interface GridServerClient { @RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "1.6")
public interface GridServerApi {
/** /**
* Returns the list of all servers. * Returns the list of all servers.
@ -46,6 +76,10 @@ public interface GridServerClient {
* options to narrow down the result * options to narrow down the result
* @return servers found by the request * @return servers found by the request
*/ */
@GET
@SelectJson("list")
@Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
@Path("/grid/server/list")
Set<Server> getServerList(GetServerListOptions... getServerListOptions); Set<Server> getServerList(GetServerListOptions... getServerListOptions);
/** /**
@ -57,7 +91,12 @@ public interface GridServerClient {
* to get the servers * to get the servers
* @return server(s) matching the name(s) * @return server(s) matching the name(s)
*/ */
Set<Server> getServersByName(String... names); @GET
@SelectJson("list")
@Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
@Path("/grid/server/get")
Set<Server> getServersByName(
@BinderParam(BindNamesToQueryParams.class) String... names);
/** /**
* Returns the server(s) by unique id(s). * Returns the server(s) by unique id(s).
@ -68,20 +107,31 @@ public interface GridServerClient {
* to get the servers * to get the servers
* @return server(s) matching the ids * @return server(s) matching the ids
*/ */
Set<Server> getServersById(long... ids); @GET
@SelectJson("list")
@Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
@Path("/grid/server/get")
Set<Server> getServersById(
@BinderParam(BindIdsToQueryParams.class) long... ids);
/** /**
* Returns a map of running servers' names to the log in credentials. * Returns a map of running servers' names to the log in credentials.
* *
* @return map <String server name => Credentials> * @return map <String server name => Credentials>
*/ */
@GET
@ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
@Path("/support/password/list")
Map<String, Credentials> getServerCredentialsList(); Map<String, Credentials> getServerCredentialsList();
/** /**
* *
* @return the login user and password of a server, or null if none found * @return the login user and password of a server, or null if none found
*/ */
Credentials getServerCredentials(long id); @GET
@ResponseParser(ParseCredentialsFromJsonResponse.class)
@Path("/support/grid/password/get")
Credentials getServerCredentials(@QueryParam("id") long id);
/** /**
* Adds a server with specified attributes * Adds a server with specified attributes
@ -98,8 +148,13 @@ public interface GridServerClient {
* options to make it a sandbox instance or/and description * options to make it a sandbox instance or/and description
* @return created server * @return created server
*/ */
Server addServer(String name, String image, String ram, String ip, @GET
AddServerOptions... addServerOptions); @SelectJson("list")
@OnlyElement
@Path("/grid/server/add")
Server addServer(@QueryParam(NAME_KEY) String name,
@QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
@QueryParam(IP_KEY) String ip, AddServerOptions... addServerOptions);
/** /**
* Changes the server's state according to {@link PowerCommand} * Changes the server's state according to {@link PowerCommand}
@ -110,7 +165,13 @@ public interface GridServerClient {
* new desired state * new desired state
* @return server immediately after applying the command * @return server immediately after applying the command
*/ */
Server power(String idOrName, PowerCommand power); @GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/power")
Server power(
@QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName,
@QueryParam(POWER_KEY) PowerCommand power);
/** /**
* Deletes the server by Id * Deletes the server by Id
@ -119,7 +180,12 @@ public interface GridServerClient {
* id of the server to delete * id of the server to delete
* @return server before the command is executed * @return server before the command is executed
*/ */
Server deleteById(long id); @GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/delete")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
Server deleteById(@QueryParam(ID_KEY) long id);
/** /**
* Deletes the server by name; * Deletes the server by name;
@ -132,40 +198,12 @@ public interface GridServerClient {
* *
* @return server before the command is executed * @return server before the command is executed
*/ */
Server deleteByName(String name); @GET
@SelectJson("list")
/** @OnlyElement
* Edits an existing server @Path("/grid/server/delete")
* @Fallback(Fallbacks.NullOnNotFoundOr404.class)
* @param id Server deleteByName(@QueryParam(NAME_KEY) String name);
* id of the existing server
* @param newDescription
* description to replace the current one
* @return edited server
*/
Server editServerDescription(long id, String newDescription);
/**
* Edits an existing server
*
* @param id
* id of the existing server
* @param idOrNameOfType
* type to replace the current one
* @return edited server
*/
Server editServerType(long id, String idOrNameOfType);
/**
* Edits an existing server
*
* @param id
* id of the existing server
* @param idOrNameOfRam
* ram to replace the current one
* @return edited server
*/
Server editServerRam(long id, String idOrNameOfRam);
/** /**
* Retrieves the list of supported RAM configurations. The objects will have * Retrieves the list of supported RAM configurations. The objects will have
@ -178,6 +216,10 @@ public interface GridServerClient {
* *
* @return supported ram sizes * @return supported ram sizes
*/ */
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
Set<Option> getRamSizes(); Set<Option> getRamSizes();
/** /**
@ -186,6 +228,10 @@ public interface GridServerClient {
* *
* @return supported server types * @return supported server types
*/ */
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
Set<Option> getTypes(); Set<Option> getTypes();
/** /**
@ -195,5 +241,56 @@ public interface GridServerClient {
* *
* @return supported datacenters * @return supported datacenters
*/ */
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
Set<Option> getDatacenters(); Set<Option> getDatacenters();
}
/**
* Edits an existing server
*
* @param id
* id of the existing server
* @param newDescription
* description to replace the current one
* @return edited server
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
Server editServerDescription(@QueryParam("id") long id,
@QueryParam("description") String newDescription);
/**
* Edits an existing server
*
* @param id
* id of the existing server
* @param ram
* ram to replace the current one
* @return edited server
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
Server editServerRam(@QueryParam("id") long id,
@QueryParam("server.ram") String ram);
/**
* Edits an existing server
*
* @param id
* id of the existing server
* @param newType
* type to replace the current one
* @return edited server
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
Server editServerType(@QueryParam("id") long id,
@QueryParam("server.type") String newType);}

View File

@ -28,7 +28,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
/** /**
* Optional parameters for adding a load balancer. * Optional parameters for adding a load balancer.
* *
* @see org.jclouds.gogrid.services.GridLoadBalancerClient#addLoadBalancer * @see org.jclouds.gogrid.features.GridLoadBalancerApi#addLoadBalancer
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.loadbalancer.add"/> * @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.loadbalancer.add"/>
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula

View File

@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.gogrid.domain.Job; import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState; import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.LoadBalancer; import org.jclouds.gogrid.domain.LoadBalancer;
import org.jclouds.gogrid.services.GridJobClient; import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -38,13 +38,13 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class LoadBalancerLatestJobCompleted implements Predicate<LoadBalancer> { public class LoadBalancerLatestJobCompleted implements Predicate<LoadBalancer> {
protected GridJobClient jobClient; protected GridJobApi jobClient;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public LoadBalancerLatestJobCompleted(GridJobClient jobClient) { public LoadBalancerLatestJobCompleted(GridJobApi jobClient) {
this.jobClient = jobClient; this.jobClient = jobClient;
} }

View File

@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.gogrid.domain.Job; import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState; import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.services.GridJobClient; import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -44,13 +44,13 @@ import com.google.inject.Inject;
@Singleton @Singleton
public class ServerLatestJobCompleted implements Predicate<Server> { public class ServerLatestJobCompleted implements Predicate<Server> {
protected GridJobClient jobClient; protected GridJobApi jobClient;
@Resource @Resource
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
@Inject @Inject
public ServerLatestJobCompleted(GridJobClient jobClient) { public ServerLatestJobCompleted(GridJobApi jobClient) {
this.jobClient = jobClient; this.jobClient = jobClient;
} }

View File

@ -1,111 +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.gogrid.services;
import java.util.Set;
import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.domain.ServerImage;
import org.jclouds.gogrid.options.GetImageListOptions;
import org.jclouds.gogrid.options.SaveImageOptions;
/**
* Manages the server images
*
* @see <a
* href="http://wiki.gogrid.com/wiki/index.php/API#Server_Image_Methods"/>
* @author Oleksiy Yarmula
*/
public interface GridImageClient {
/**
* Deletes an existing image
*
* @param id
* id of the existing image
*/
ServerImage deleteById(long id);
/**
* This call will save a private (visible to only you) server image to your
* library of available images. The image will be saved from an existing
* server.
*
* @param idOrName
* id or name of the existing server
* @param friendlyName
* friendly name of the image
* @return saved server image
*/
ServerImage saveImageFromServer(String friendlyName, String idOrName, SaveImageOptions... options);
/**
* Returns all server images.
*
* @param options
* options to narrow the search down
* @return server images found
*/
Set<ServerImage> getImageList(GetImageListOptions... options);
/**
* Returns images, found by specified ids
*
* @param ids
* the ids that match existing images
* @return images found
*/
Set<ServerImage> getImagesById(Long... ids);
/**
* Returns images, found by specified names
*
* @param names
* the names that march existing images
* @return images found
*/
Set<ServerImage> getImagesByName(String... names);
/**
* Edits an existing image
*
* @param idOrName
* id or name of the existing image
* @param newDescription
* description to replace the current one
* @return edited server image
*/
ServerImage editImageDescription(String idOrName, String newDescription);
/**
* Edits an existing image
*
* @param idOrName
* id or name of the existing image
* @param newFriendlyName
* friendly name to replace the current one
* @return edited server image
*/
ServerImage editImageFriendlyName(String idOrName, String newFriendlyName);
/**
* Retrieves the list of supported Datacenters to save images in. The objects
* will have datacenter ID, name and description. In most cases, id or name
* will be used for {@link #getImageList}.
*
* @return supported datacenters
*/
Set<Option> getDatacenters();
}

View File

@ -1,71 +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.gogrid.services;
import java.util.Set;
import org.jclouds.gogrid.domain.Ip;
import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.options.GetIpListOptions;
/**
* @author Oleksiy Yarmula
*/
public interface GridIpClient {
/**
* Returns all IPs in the system that match the options
*
* @param options
* options to narrow the search down
* @return IPs found by the search
*/
Set<Ip> getIpList(GetIpListOptions... options);
/**
* Returns the list of unassigned IPs.
*
* NOTE: this returns both public and private IPs!
*
* @return unassigned IPs
*/
Set<Ip> getUnassignedIpList();
/**
* Returns the list of unassigned public IPs.
*
* @return unassigned public IPs
*/
Set<Ip> getUnassignedPublicIpList();
/**
* Returns the list of assigned IPs
*
* NOTE: this returns both public and private IPs!
*
* @return assigned IPs
*/
Set<Ip> getAssignedIpList();
/**
* Retrieves the list of supported Datacenters to retrieve ips from. The objects will have
* datacenter ID, name and description. In most cases, id or name will be used for
* {@link #addServer}.
*
* @return supported datacenters
*/
Set<Option> getDatacenters();
}

View File

@ -1,67 +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.gogrid.services;
import java.util.Set;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.options.GetJobListOptions;
/**
* Manages the customer's jobs.
*
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API#Job_Methods" />
*
* @author Oleksiy Yarmula
*/
public interface GridJobClient {
/**
* Returns all jobs found. The resulting set may be narrowed down by providing
* {@link GetJobListOptions}.
*
* By default, the result is <=100 items from the date range of 4 weeks ago to now.
*
* NOTE: this method results in a big volume of data in response
*
* @return jobs found by request
*/
Set<Job> getJobList(GetJobListOptions... options);
/**
* Returns jobs found for an object with a provided name.
*
* Usually, in GoGrid a name will uniquely identify the object, or, as the docs state, some API
* methods will cause errors.
*
* @param serverName
* name of the object
* @return found jobs for the object
*/
Set<Job> getJobsForObjectName(String serverName);
/**
* Returns jobs for the corresponding id(s).
*
* NOTE: there is a 1:1 relation between a job and its ID.
*
* @param ids
* ids for the jobs
* @return jobs found by the ids
*/
Set<Job> getJobsById(long... ids);
}

View File

@ -1,136 +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.gogrid.services;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import java.util.List;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
import org.jclouds.gogrid.binders.BindRealIpPortPairsToQueryParams;
import org.jclouds.gogrid.binders.BindVirtualIpPortPairToQueryParams;
import org.jclouds.gogrid.domain.IpPortPair;
import org.jclouds.gogrid.domain.LoadBalancer;
import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import com.google.common.util.concurrent.ListenableFuture;
/**
* @author Oleksiy Yarmula
*/
@RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
public interface GridLoadBalancerAsyncClient {
/**
* @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...)
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/list")
ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
/**
* @see GridLoadBalancerClient#getLoadBalancersByName
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersByName(
@BinderParam(BindNamesToQueryParams.class) String... names);
/**
* @see GridLoadBalancerClient#getLoadBalancersById
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/get")
ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(
@BinderParam(BindIdsToQueryParams.class) Long... ids);
/**
* @see GridLoadBalancerClient#addLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/add")
ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam(NAME_KEY) String name,
@BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
/**
* @see GridLoadBalancerClient#editLoadBalancerNamed
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
ListenableFuture<LoadBalancer> editLoadBalancerNamed(@QueryParam(NAME_KEY) String name,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/**
* @see GridLoadBalancerClient#editLoadBalancer
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/edit")
ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam(ID_KEY) long id,
@BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
/**
* @see GridLoadBalancerClient#
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteById(@QueryParam(ID_KEY) Long id);
/**
* @see GridLoadBalancerClient#
*/
@GET
@ResponseParser(ParseLoadBalancerFromJsonResponse.class)
@Path("/grid/loadbalancer/delete")
ListenableFuture<LoadBalancer> deleteByName(@QueryParam(NAME_KEY) String name);
/**
* @see GridLoadBalancerClient#getDatacenters
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "loadbalancer.datacenter")
ListenableFuture<Set<Option>> getDatacenters();
}

View File

@ -1,218 +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.gogrid.services;
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
import java.util.Map;
import java.util.Set;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.domain.Credentials;
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
import org.jclouds.gogrid.binders.BindNamesToQueryParams;
import org.jclouds.gogrid.domain.Option;
import org.jclouds.gogrid.domain.PowerCommand;
import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
import org.jclouds.gogrid.options.AddServerOptions;
import org.jclouds.gogrid.options.GetServerListOptions;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.OnlyElement;
import org.jclouds.rest.annotations.QueryParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SelectJson;
import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides asynchronous access to GoGrid via their REST API.
* <p/>
*
* @see GridServerClient
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
* @author Adrian Cole
* @author Oleksiy Yarmula
*/
@RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "1.6")
public interface GridServerAsyncClient {
/**
* @see GridServerClient#getServerList(org.jclouds.gogrid.options.GetServerListOptions...)
*/
@GET
@SelectJson("list")
@Fallback(EmptySetOnNotFoundOr404.class)
@Path("/grid/server/list")
ListenableFuture<Set<Server>> getServerList(GetServerListOptions... getServerListOptions);
/**
* @see GridServerClient#getServersByName(String...)
*/
@GET
@SelectJson("list")
@Fallback(EmptySetOnNotFoundOr404.class)
@Path("/grid/server/get")
ListenableFuture<Set<Server>> getServersByName(
@BinderParam(BindNamesToQueryParams.class) String... names);
/**
* @see GridServerClient#getServersById(Long...)
*/
@GET
@SelectJson("list")
@Fallback(EmptySetOnNotFoundOr404.class)
@Path("/grid/server/get")
ListenableFuture<Set<Server>> getServersById(
@BinderParam(BindIdsToQueryParams.class) long... ids);
/**
* @see GridServerClient#getServerCredentialsList
*/
@GET
@ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
@Path("/support/password/list")
ListenableFuture<Map<String, Credentials>> getServerCredentialsList();
/**
* @see GridServerClient#getServerCredentials
*/
@GET
@ResponseParser(ParseCredentialsFromJsonResponse.class)
@Path("/support/grid/password/get")
ListenableFuture<Credentials> getServerCredentials(@QueryParam("id") long id);
/**
* @see GridServerClient#addServer(String, String, String, String,
* org.jclouds.gogrid.options.AddServerOptions...)
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/add")
ListenableFuture<Server> addServer(@QueryParam(NAME_KEY) String name,
@QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
@QueryParam(IP_KEY) String ip, AddServerOptions... addServerOptions);
/**
* @see GridServerClient#power(String, org.jclouds.gogrid.domain.PowerCommand)
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/power")
ListenableFuture<Server> power(
@QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName,
@QueryParam(POWER_KEY) PowerCommand power);
/**
* @see GridServerClient#deleteById(Long)
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/delete")
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<Server> deleteById(@QueryParam(ID_KEY) long id);
/**
* @see GridServerClient#deleteByName(String)
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/delete")
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<Server> deleteByName(@QueryParam(NAME_KEY) String name);
/**
* @see GridServerClient#getRamSizes
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
ListenableFuture<Set<Option>> getRamSizes();
/**
* @see GridServerClient#getTypes
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
ListenableFuture<Set<Option>> getTypes();
/**
* @see GridServerClient#getDatacenters
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
ListenableFuture<Set<Option>> getDatacenters();
/**
* @see GridServerClient#editServerDescription
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
ListenableFuture<Server> editServerDescription(@QueryParam("id") long id,
@QueryParam("description") String newDescription);
/**
* @see GridServerClient#editServerRam
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
ListenableFuture<Server> editServerRam(@QueryParam("id") long id,
@QueryParam("server.ram") String ram);
/**
* @see GridServerClient#editServerType
*/
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
ListenableFuture<Server> editServerType(@QueryParam("id") long id,
@QueryParam("server.type") String newType);
}

View File

@ -19,21 +19,20 @@ package org.jclouds.gogrid;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import org.jclouds.gogrid.services.BaseGoGridAsyncClientTest; import org.jclouds.gogrid.features.BaseGoGridApiTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code GoGridAsyncClient} * Tests behavior of {@code GoGridApi}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GoGridAsyncClientTest") @Test(groups = "unit", testName = "GoGridApiTest")
public class GoGridAsyncClientTest extends BaseGoGridAsyncClientTest<GoGridAsyncClient> { public class GoGridApiTest extends BaseGoGridApiTest<GoGridApi> {
private GoGridAsyncClient asyncClient; private GoGridApi syncClient;
private GoGridClient syncClient;
public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException,
ExecutionException { ExecutionException {
@ -44,20 +43,10 @@ public class GoGridAsyncClientTest extends BaseGoGridAsyncClientTest<GoGridAsync
assert syncClient.getServerServices() != null; assert syncClient.getServerServices() != null;
} }
public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException,
ExecutionException {
assert asyncClient.getImageServices() != null;
assert asyncClient.getIpServices() != null;
assert asyncClient.getJobServices() != null;
assert asyncClient.getLoadBalancerServices() != null;
assert asyncClient.getServerServices() != null;
}
@BeforeClass @BeforeClass
@Override @Override
protected void setupFactory() throws IOException { protected void setupFactory() throws IOException {
super.setupFactory(); super.setupFactory();
asyncClient = injector.getInstance(GoGridAsyncClient.class); syncClient = injector.getInstance(GoGridApi.class);
syncClient = injector.getInstance(GoGridClient.class);
} }
} }

View File

@ -72,7 +72,7 @@ import com.google.inject.Guice;
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
@Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled") @Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled")
public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridClient> { public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridApi> {
public GoGridLiveTestDisabled() { public GoGridLiveTestDisabled() {
provider = "gogrid"; provider = "gogrid";

View File

@ -28,7 +28,7 @@ import static org.testng.Assert.assertNotNull;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest; import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted; import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
@ -68,7 +68,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public void testResizeRam() throws Exception { public void testResizeRam() throws Exception {
String group = this.group + "ram"; String group = this.group + "ram";
GoGridClient api = view.utils().injector().getInstance(GoGridClient.class); GoGridApi api = view.utils().injector().getInstance(GoGridApi.class);
try { try {
client.destroyNodesMatching(inGroup(group)); client.destroyNodesMatching(inGroup(group));
} catch (Exception e) { } catch (Exception e) {

View File

@ -14,20 +14,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.GoGridApi;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
* Tests behavior of {@code GoGridClient} * Tests behavior of {@code GoGridApi}
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest") @Test(groups = "live", singleThreaded = true, testName = "BaseGoGridApiLiveTest")
public class BaseGoGridClientLiveTest extends BaseApiLiveTest<GoGridClient> { public class BaseGoGridApiLiveTest extends BaseApiLiveTest<GoGridApi> {
public BaseGoGridClientLiveTest() { public BaseGoGridApiLiveTest() {
provider = "gogrid"; provider = "gogrid";
} }
} }

View File

@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.gogrid.GoGridProviderMetadata; import org.jclouds.gogrid.GoGridProviderMetadata;
import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.config.GoGridHttpApiModule;
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication; import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.ProviderMetadata;
@ -36,7 +36,7 @@ import com.google.inject.Module;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit") @Test(groups = "unit")
public abstract class BaseGoGridAsyncClientTest<T> extends BaseAsyncClientTest<T> { public abstract class BaseGoGridApiTest<T> extends BaseAsyncClientTest<T> {
@Override @Override
protected void checkFilters(HttpRequest request) { protected void checkFilters(HttpRequest request) {
assertEquals(request.getFilters().size(), 1); assertEquals(request.getFilters().size(), 1);
@ -44,7 +44,7 @@ public abstract class BaseGoGridAsyncClientTest<T> extends BaseAsyncClientTest<T
} }
@ConfiguresRestClient @ConfiguresRestClient
protected static final class TestGoGridRestClientModule extends GoGridRestClientModule { protected static final class TestGoGridHttpApiModule extends GoGridHttpApiModule {
@Override @Override
protected void configure() { protected void configure() {
super.configure(); super.configure();
@ -58,7 +58,7 @@ public abstract class BaseGoGridAsyncClientTest<T> extends BaseAsyncClientTest<T
@Override @Override
protected Module createModule() { protected Module createModule() {
return new TestGoGridRestClientModule(); return new TestGoGridHttpApiModule();
} }
@Override @Override

View File

@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.config.GoGridRestClientModule; import org.jclouds.gogrid.config.GoGridHttpApiModule;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.jclouds.rest.internal.BaseRestClientExpectTest;
@ -29,14 +29,14 @@ import com.google.inject.Module;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoGridClient> { public class BaseGoGridHttpApiExpectTest extends BaseRestClientExpectTest<GoGridApi> {
public BaseGoGridRestClientExpectTest() { public BaseGoGridHttpApiExpectTest() {
provider = "gogrid"; provider = "gogrid";
} }
@ConfiguresRestClient @ConfiguresRestClient
protected static final class TestGoGridRestClientModule extends GoGridRestClientModule { protected static final class TestGoGridHttpApiModule extends GoGridHttpApiModule {
@Override @Override
protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) { protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
@ -46,6 +46,6 @@ public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoG
@Override @Override
protected Module createModule() { protected Module createModule() {
return new TestGoGridRestClientModule(); return new TestGoGridHttpApiModule();
} }
} }

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.util.Predicates2.retry; import static org.jclouds.util.Predicates2.retry;
@ -45,8 +45,8 @@ import com.google.common.collect.Iterables;
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during // NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire // surefire
@Test(groups = "unit", testName = "GridImageClientLiveTest") @Test(groups = "unit", testName = "GridImageApiLiveTest")
public class GridImageClientLiveTest extends BaseGoGridClientLiveTest { public class GridImageApiLiveTest extends BaseGoGridApiLiveTest {
public void testListImages() throws Exception { public void testListImages() throws Exception {
Set<ServerImage> response = api.getImageServices().getImageList(); Set<ServerImage> response = api.getImageServices().getImageList();

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.reflect.Reflection2.method;
@ -34,18 +34,18 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable; import com.google.common.reflect.Invokable;
/** /**
* Tests behavior of {@code GridImageAsyncClient} * Tests behavior of {@code GridImageApi}
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during // NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire // surefire
@Test(groups = "unit", testName = "GridImageAsyncClientTest") @Test(groups = "unit", testName = "GridImageApiTest")
public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImageAsyncClient> { public class GridImageApiTest extends BaseGoGridApiTest<GridImageApi> {
@Test @Test
public void testGetImageListWithOptions() throws NoSuchMethodException, IOException { public void testGetImageListWithOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImageList", GetImageListOptions[].class); Invokable<?, ?> method = method(GridImageApi.class, "getImageList", GetImageListOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest( GeneratedHttpRequest httpRequest = processor.createRequest(
method, ImmutableList.<Object> of( method, ImmutableList.<Object> of(
new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE) new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE)
@ -72,7 +72,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testGetImagesByName() throws NoSuchMethodException, IOException { public void testGetImagesByName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImagesByName", String[].class); Invokable<?, ?> method = method(GridImageApi.class, "getImagesByName", String[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name1", "name2")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name1", "name2"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
@ -95,7 +95,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testEditImageDescription() throws NoSuchMethodException, IOException { public void testEditImageDescription() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageDescription", String.class, String.class); Invokable<?, ?> method = method(GridImageApi.class, "editImageDescription", String.class, String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newDesc")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newDesc"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
@ -118,7 +118,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testEditImageFriendlyName() throws NoSuchMethodException, IOException { public void testEditImageFriendlyName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageFriendlyName", String.class, String.class); Invokable<?, ?> method = method(GridImageApi.class, "editImageFriendlyName", String.class, String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newFriendlyName")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newFriendlyName"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
@ -142,7 +142,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testDeleteById() throws NoSuchMethodException, IOException { public void testDeleteById() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "deleteById", long.class); Invokable<?, ?> method = method(GridImageApi.class, "deleteById", long.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l)); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1"); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1");
@ -156,7 +156,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testSaveImageFromServerNoOptions() throws NoSuchMethodException, IOException { public void testSaveImageFromServerNoOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class, Invokable<?, ?> method = method(GridImageApi.class, "saveImageFromServer", String.class, String.class,
SaveImageOptions[].class); SaveImageOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName"));
@ -173,7 +173,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test @Test
public void testSaveImageOptions() throws NoSuchMethodException, IOException { public void testSaveImageOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class, Invokable<?, ?> method = method(GridImageApi.class, "saveImageFromServer", String.class, String.class,
SaveImageOptions[].class); SaveImageOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName", GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName",
new SaveImageOptions().withDescription("fooy"))); new SaveImageOptions().withDescription("fooy")));

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.reflect.Reflection2.method;
@ -30,17 +30,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable; import com.google.common.reflect.Invokable;
/** /**
* Tests behavior of {@code GridIpAsyncClient} * Tests behavior of {@code GridIpApi}
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridIpAsyncClientTest") @Test(groups = "unit", testName = "GridIpApiTest")
public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsyncClient> { public class GridIpApiTest extends BaseGoGridApiTest<GridIpApi> {
@Test @Test
public void testGetIpListWithOptions() throws NoSuchMethodException, IOException { public void testGetIpListWithOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridIpAsyncClient.class, "getIpList", GetIpListOptions[].class); Invokable<?, ?> method = method(GridIpApi.class, "getIpList", GetIpListOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(new GetIpListOptions() GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(new GetIpListOptions()
.onlyUnassigned().onlyWithType(IpType.PUBLIC))); .onlyUnassigned().onlyWithType(IpType.PUBLIC)));
@ -64,7 +64,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsync
@Test @Test
public void testGetAssignedIpList() throws NoSuchMethodException, IOException { public void testGetAssignedIpList() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridIpAsyncClient.class, "getAssignedIpList"); Invokable<?, ?> method = method(GridIpApi.class, "getAssignedIpList");
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -31,8 +31,8 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole * @author Adrian Cole
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridJobClientLiveTest") @Test(groups = "unit", testName = "GridJobApiLiveTest")
public class GridJobClientLiveTest extends BaseGoGridClientLiveTest { public class GridJobApiLiveTest extends BaseGoGridApiLiveTest {
public void testListJobs() throws Exception { public void testListJobs() throws Exception {
Set<Job> response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10)); Set<Job> response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10));

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate; import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate;
import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.reflect.Reflection2.method;
@ -33,17 +33,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable; import com.google.common.reflect.Invokable;
/** /**
* Tests behavior of {@code GridJobAsyncClient} * Tests behavior of {@code GridJobApi}
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridJobAsyncClientTest") @Test(groups = "unit", testName = "GridJobApiTest")
public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsyncClient> { public class GridJobApiTest extends BaseGoGridApiTest<GridJobApi> {
@Test @Test
public void testGetJobListWithOptions() throws NoSuchMethodException, IOException { public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class); Invokable<?, ?> method = method(GridJobApi.class, "getJobList", GetJobListOptions[].class);
GeneratedHttpRequest httpRequest = processor GeneratedHttpRequest httpRequest = processor
.createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L)) .createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
.onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING))); .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING)));
@ -71,7 +71,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsy
@Test @Test
public void testGetJobListNoOptions() throws NoSuchMethodException, IOException { public void testGetJobListNoOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class); Invokable<?, ?> method = method(GridJobApi.class, "getJobList", GetJobListOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1"); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1");
@ -81,7 +81,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsy
@Test @Test
public void testGetJobsForServerName() throws NoSuchMethodException, IOException { public void testGetJobsForServerName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsForObjectName", String.class); Invokable<?, ?> method = method(GridJobApi.class, "getJobsForObjectName", String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("MyServer")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("MyServer"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
@ -104,7 +104,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsy
@Test @Test
public void testGetJobsById() throws NoSuchMethodException, IOException { public void testGetJobsById() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsById", long[].class); Invokable<?, ?> method = method(GridJobApi.class, "getJobsById", long[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L, 456L)); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L, 456L));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.reflect.Reflection2.method;
@ -36,17 +36,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable; import com.google.common.reflect.Invokable;
/** /**
* Tests behavior of {@code GridLoadBalancerAsyncClient} * Tests behavior of {@code GridLoadBalancerApi}
* *
* @author Oleksiy Yarmula * @author Oleksiy Yarmula
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridLoadBalancerAsyncClientTest") @Test(groups = "unit", testName = "GridLoadBalancerApiTest")
public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<GridLoadBalancerAsyncClient> { public class GridLoadBalancerApiTest extends BaseGoGridApiTest<GridLoadBalancerApi> {
@Test @Test
public void testGetLoadBalancerList() throws NoSuchMethodException, IOException { public void testGetLoadBalancerList() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancerList"); Invokable<?, ?> method = method(GridLoadBalancerApi.class, "getLoadBalancerList");
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1"); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1");
@ -83,7 +83,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test @Test
public void testAddLoadBalancer() throws NoSuchMethodException, IOException { public void testAddLoadBalancer() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "addLoadBalancer", String.class, IpPortPair.class, Invokable<?, ?> method = method(GridLoadBalancerApi.class, "addLoadBalancer", String.class, IpPortPair.class,
List.class, AddLoadBalancerOptions[].class); List.class, AddLoadBalancerOptions[].class);
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt",
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(),
@ -107,7 +107,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test @Test
public void testEditLoadBalancer() throws NoSuchMethodException, IOException { public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancer", long.class, List.class); Invokable<?, ?> method = method(GridLoadBalancerApi.class, "editLoadBalancer", long.class, List.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1l, ImmutableList.of( GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1l, ImmutableList.of(
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
@ -134,7 +134,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test @Test
public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException { public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancerNamed", String.class, List.class); Invokable<?, ?> method = method(GridLoadBalancerApi.class, "editLoadBalancerNamed", String.class, List.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", ImmutableList.of( GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", ImmutableList.of(
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(), IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()))); IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
@ -161,7 +161,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test @Test
public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException { public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancersByName", String[].class); Invokable<?, ?> method = method(GridLoadBalancerApi.class, "getLoadBalancersByName", String[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of( GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
"My Load Balancer", "My Load Balancer 2")); "My Load Balancer", "My Load Balancer 2"));
@ -186,7 +186,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test @Test
public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException { public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "deleteById", Long.class); Invokable<?, ?> method = method(GridLoadBalancerApi.class, "deleteById", Long.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(55L)); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(55L));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.jclouds.reflect.Reflection2.method; import static org.jclouds.reflect.Reflection2.method;
@ -33,17 +33,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable; import com.google.common.reflect.Invokable;
/** /**
* Tests behavior of {@code GridServerAsyncClient} * Tests behavior of {@code GridServerApi}
* *
* @author Oleksiy Yarmula, Adrian Cole * @author Oleksiy Yarmula, Adrian Cole
*/ */
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridServerAsyncClientTest") @Test(groups = "unit", testName = "GridServerApiTest")
public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridServerAsyncClient> { public class GridServerApiTest extends BaseGoGridApiTest<GridServerApi> {
@Test @Test
public void testGetServerListWithOptions() throws NoSuchMethodException, IOException { public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServerList", GetServerListOptions[].class); Invokable<?, ?> method = method(GridServerApi.class, "getServerList", GetServerListOptions[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of( GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
new GetServerListOptions.Builder().onlySandboxServers())); new GetServerListOptions.Builder().onlySandboxServers()));
@ -66,7 +66,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testGetServersByName() throws NoSuchMethodException, IOException { public void testGetServersByName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServersByName", String[].class); Invokable<?, ?> method = method(GridServerApi.class, "getServersByName", String[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("server1")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("server1"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1"); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1");
@ -87,7 +87,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testGetServersById() throws NoSuchMethodException, IOException { public void testGetServersById() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServersById", long[].class); Invokable<?, ?> method = method(GridServerApi.class, "getServersById", long[].class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L)); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1"); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1");
@ -109,7 +109,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testPowerServer() throws NoSuchMethodException, IOException { public void testPowerServer() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "power", String.class, PowerCommand.class); Invokable<?, ?> method = method(GridServerApi.class, "power", String.class, PowerCommand.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer", GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer",
PowerCommand.RESTART)); PowerCommand.RESTART));
@ -132,7 +132,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testDeleteByName() throws NoSuchMethodException, IOException { public void testDeleteByName() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "deleteByName", String.class); Invokable<?, ?> method = method(GridServerApi.class, "deleteByName", String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
@ -154,7 +154,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testGetRamSizes() throws NoSuchMethodException, IOException { public void testGetRamSizes() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getRamSizes"); Invokable<?, ?> method = method(GridServerApi.class, "getRamSizes");
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram " assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram "
@ -177,7 +177,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testServerCredentials() throws NoSuchMethodException, IOException { public void testServerCredentials() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServerCredentials", long.class); Invokable<?, ?> method = method(GridServerApi.class, "getServerCredentials", long.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1)); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1));
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
@ -192,7 +192,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testTypes() throws NoSuchMethodException, IOException { public void testTypes() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "getTypes"); Invokable<?, ?> method = method(GridServerApi.class, "getTypes");
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
assertRequestLineEquals(httpRequest, assertRequestLineEquals(httpRequest,
@ -207,7 +207,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testEditServerDescription() throws NoSuchMethodException, IOException { public void testEditServerDescription() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerDescription", long.class, String.class); Invokable<?, ?> method = method(GridServerApi.class, "editServerDescription", long.class, String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "newDesc")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "newDesc"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
@ -229,7 +229,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testEditServerRam() throws NoSuchMethodException, IOException { public void testEditServerRam() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerRam", long.class, String.class); Invokable<?, ?> method = method(GridServerApi.class, "editServerRam", long.class, String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "1GB")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "1GB"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
@ -251,7 +251,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test @Test
public void testEditServerType() throws NoSuchMethodException, IOException { public void testEditServerType() throws NoSuchMethodException, IOException {
Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerType", long.class, String.class); Invokable<?, ?> method = method(GridServerApi.class, "editServerType", long.class, String.class);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "web")); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "web"));
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.jclouds.gogrid.services; package org.jclouds.gogrid.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@ -22,7 +22,7 @@ import static org.testng.Assert.fail;
import java.net.URI; import java.net.URI;
import org.jclouds.gogrid.GoGridClient; import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.options.AddServerOptions; import org.jclouds.gogrid.options.AddServerOptions;
import org.jclouds.gogrid.options.GetServerListOptions; import org.jclouds.gogrid.options.GetServerListOptions;
import org.jclouds.gogrid.parse.ParseServerListTest; import org.jclouds.gogrid.parse.ParseServerListTest;
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "unit", testName = "GridServerClientExpectTest") @Test(groups = "unit", testName = "GridServerClientExpectTest")
public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest { public class GridServerClientExpectTest extends BaseGoGridHttpApiExpectTest {
HttpRequest addServer = HttpRequest.builder().method("GET") HttpRequest addServer = HttpRequest.builder().method("GET")
.endpoint("https://api.gogrid.com/api/grid/server/add") .endpoint("https://api.gogrid.com/api/grid/server/add")
@ -53,7 +53,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build(); payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
GoGridClient addServerWorked = requestSendsResponse(addServer, listGridServersResponse); GoGridApi addServerWorked = requestSendsResponse(addServer, listGridServersResponse);
assertEquals(addServerWorked.getServerServices().addServer("serverName", "img55", "memory", "127.0.0.1") assertEquals(addServerWorked.getServerServices().addServer("serverName", "img55", "memory", "127.0.0.1")
.toString(), new ParseServerTest().expected().toString()); .toString(), new ParseServerTest().expected().toString());
@ -75,7 +75,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build(); payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
GoGridClient addServerWithOptionsWorked = requestSendsResponse(addServerOptions, listGridServersResponse); GoGridApi addServerWithOptionsWorked = requestSendsResponse(addServerOptions, listGridServersResponse);
assertEquals(addServerWithOptionsWorked.getServerServices().addServer("serverName", "img55", "memory", assertEquals(addServerWithOptionsWorked.getServerServices().addServer("serverName", "img55", "memory",
"127.0.0.1", new AddServerOptions().asSandboxType().withDescription("fooy")).toString(), "127.0.0.1", new AddServerOptions().asSandboxType().withDescription("fooy")).toString(),
@ -90,7 +90,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build(); payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
GoGridClient clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse); GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
assertEquals(clientWhenGridServersExist.getServerServices().getServerList().toString(), new ParseServerListTest() assertEquals(clientWhenGridServersExist.getServerServices().getServerList().toString(), new ParseServerListTest()
.expected().toString()); .expected().toString());
@ -104,7 +104,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload(
payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build(); payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
GoGridClient clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse); GoGridApi clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty()); assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty());
} }
@ -117,7 +117,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build(); payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
GoGridClient clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse); GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
assertEquals(clientWhenGridServersExist.getServerServices().getServerList( assertEquals(clientWhenGridServersExist.getServerServices().getServerList(
new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest() new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest()
@ -132,7 +132,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload( HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload(
payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build(); payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
GoGridClient clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse); GoGridApi clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
try { try {
clientWhenGridServersNotFound.getServerServices().getServerCredentials(11); clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
fail("should have failed"); fail("should have failed");

View File

@ -25,7 +25,7 @@ import static org.testng.Assert.assertTrue;
import org.jclouds.gogrid.domain.Job; import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState; import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.Server; import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.services.GridJobClient; import org.jclouds.gogrid.features.GridJobApi;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -46,7 +46,7 @@ public class ServerLatestJobCompletedTest {
Job job = createMock(Job.class); Job job = createMock(Job.class);
expect(job.getCurrentState()).andReturn(JobState.SUCCEEDED); expect(job.getCurrentState()).andReturn(JobState.SUCCEEDED);
GridJobClient client = createMock(GridJobClient.class); GridJobApi client = createMock(GridJobApi.class);
expect(client.getJobList(latestJobForObjectByName(serverName))).andReturn(ImmutableSet.<Job> of(job)); expect(client.getJobList(latestJobForObjectByName(serverName))).andReturn(ImmutableSet.<Job> of(job));
replay(job); replay(job);