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

View File

@ -24,11 +24,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule;
import org.jclouds.gogrid.config.GoGridRestClientModule;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import org.jclouds.gogrid.config.GoGridHttpApiModule;
import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@ -36,17 +35,8 @@ import com.google.inject.Module;
*
* @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
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@ -61,17 +51,16 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
public static class Builder extends BaseHttpApiMetadata.Builder<GoGridApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(GoGridClient.class, GoGridAsyncClient.class);
id("gogrid")
.name("GoGrid API")
.identityName("API Key")
@ -81,7 +70,7 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.gogrid.com/api")
.defaultProperties(GoGridApiMetadata.defaultProperties())
.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

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
*/

View File

@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
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.domain.Ip;
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.Throwables;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
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}
*
*/
@ -63,13 +62,13 @@ public class GoGridComputeServiceAdapter implements ComputeServiceAdapter<Server
@Resource
protected Logger logger = Logger.NULL;
private final GoGridClient client;
private final GoGridApi client;
private final Function<Hardware, String> sizeToRam;
private final Predicate<Server> serverLatestJobCompleted;
private final Predicate<Server> serverLatestJobCompletedShort;
@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.sizeToRam = checkNotNull(sizeToRam, "sizeToRam");
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 java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.inject.Named;
import org.jclouds.date.TimeStamp;
import org.jclouds.gogrid.GoGridAsyncClient;
import org.jclouds.gogrid.GoGridClient;
import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.handlers.GoGridErrorHandler;
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.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
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.Suppliers;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Provides;
import com.google.inject.Scopes;
@ -59,18 +46,7 @@ import com.google.inject.Scopes;
* @author Oleksiy Yarmula
*/
@ConfiguresRestClient
public class GoGridRestClientModule extends RestClientModule<GoGridClient, GoGridAsyncClient> {
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);
}
public class GoGridHttpApiModule extends HttpApiModule<GoGridApi> {
@Provides
@TimeStamp

View File

@ -27,7 +27,7 @@ package org.jclouds.gogrid.domain;
* <li>Restart</li>
* </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" />
*
* @author Oleksiy Yarmula

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* 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;
@ -30,7 +30,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
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.BindNamesToQueryParams;
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.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
*/
@RequestFilters(SharedKeyLiteAuthentication.class)
@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
@ResponseParser(ParseImageListFromJsonResponse.class)
@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
@ResponseParser(ParseImageListFromJsonResponse.class)
@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
@ResponseParser(ParseImageListFromJsonResponse.class)
@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
@ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/edit")
ListenableFuture<ServerImage> editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
@QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription);
ServerImage editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
@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
@ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/edit")
ListenableFuture<ServerImage> editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName);
ServerImage editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
@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
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@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
@ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/delete")
@Fallback(NullOnNotFoundOr404.class)
ListenableFuture<ServerImage> deleteById(@QueryParam(ID_KEY) long id);
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
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
@ResponseParser(ParseImageFromJsonResponse.class)
@Path("/grid/image/save")
ListenableFuture<ServerImage> saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName,
@QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName, SaveImageOptions... options);
ServerImage saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName,
@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
* 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.IP_STATE_KEY;
@ -36,59 +36,72 @@ 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;
/**
* @see org.jclouds.gogrid.services.GridImageClient
*
* @author Oleksiy Yarmula
*/
@RequestFilters(SharedKeyLiteAuthentication.class)
@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
@ResponseParser(ParseIpListFromJsonResponse.class)
@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
@ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list")
@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
@ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list")
@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
@ResponseParser(ParseIpListFromJsonResponse.class)
@Path("/grid/ip/list")
@QueryParams(keys = IP_STATE_KEY, values = "Assigned")
ListenableFuture<Set<Ip>> getAssignedIpList();
Set<Ip> getAssignedIpList();
/**
*
* @see org.jclouds.gogrid.services.GridIpClient#getDatacenters
* 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
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@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
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
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.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
*/
@RequestFilters(SharedKeyLiteAuthentication.class)
@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
@ResponseParser(ParseJobListFromJsonResponse.class)
@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
@ResponseParser(ParseJobListFromJsonResponse.class)
@Path("/grid/job/list")
ListenableFuture<Set<Job>> getJobsForObjectName(
@BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName);
Set<Job> getJobsForObjectName(
@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
@ResponseParser(ParseJobListFromJsonResponse.class)
@Path("/grid/job/get")
ListenableFuture<Set<Job>> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids);
Set<Job> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids);
}

View File

@ -14,52 +14,88 @@
* See the License for the specific language governing permissions and
* 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.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;
/**
* @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.
*
*
* @return load balancers found
*/
@GET
@ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
@Path("/grid/loadbalancer/list")
Set<LoadBalancer> getLoadBalancerList();
/**
* Returns the load balancer(s) by unique name(s).
*
*
* Given a name or a set of names, finds one or multiple load balancers.
*
*
* @param names
* to get the load balancers
* @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).
*
*
* Given an id or a set of ids, finds one or multiple load balancers.
*
*
* @param ids
* to get the load balancers
* @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.
*
*
* @param name
* name of the load balancer
* @param virtualIp
@ -73,62 +109,85 @@ public interface GridLoadBalancerClient {
* strategy, or description.
* @return created load balancer object
*/
LoadBalancer addLoadBalancer(String name, IpPortPair virtualIp, List<IpPortPair> realIps,
AddLoadBalancerOptions... options);
@GET
@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.
*
* @param id
*
* @param name
* id of the existing load balancer
* @param realIps
* 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}
* @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.
*
* @param name
*
* @param id
* name of the existing load balancer
* @param realIps
* 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}
* @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
*
*
* @param id
* id of the load balancer to delete
* @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;
*
*
* NOTE: Using this parameter may generate an error if one or more load balancers share a
* non-unique name.
*
*
* @param name
* name of the load balancer to be deleted
*
*
* @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
* datacenter ID, name and description. In most cases, id or name will be used for
* {@link #addLoadBalancer}.
*
*
* @return supported datacenters
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "loadbalancer.datacenter")
Set<Option> getDatacenters();
}

View File

@ -14,78 +14,128 @@
* See the License for the specific language governing permissions and
* 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.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.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;
/**
* Provides synchronous access to GoGrid.
* <p/>
*
* @see GridServerAsyncClient
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
*
* @author Adrian Cole
* @author Oleksiy Yarmula
*/
public interface GridServerClient {
@RequestFilters(SharedKeyLiteAuthentication.class)
@QueryParams(keys = VERSION, values = "1.6")
public interface GridServerApi {
/**
* Returns the list of all servers.
*
*
* The result can be narrowed down by providing the options.
*
*
* @param getServerListOptions
* options to narrow down the result
* @return servers found by the request
*/
@GET
@SelectJson("list")
@Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
@Path("/grid/server/list")
Set<Server> getServerList(GetServerListOptions... getServerListOptions);
/**
* Returns the server(s) by unique name(s).
*
*
* Given a name or a set of names, finds one or multiple servers.
*
*
* @param names
* to get the servers
* @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).
*
*
* Given an id or a set of ids, finds one or multiple servers.
*
*
* @param ids
* to get the servers
* @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.
*
*
* @return map <String server name => Credentials>
*/
@GET
@ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
@Path("/support/password/list")
Map<String, Credentials> getServerCredentialsList();
/**
*
*
* @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
*
*
* @param name
* name of the server
* @param image
@ -98,102 +148,149 @@ public interface GridServerClient {
* options to make it a sandbox instance or/and description
* @return created server
*/
Server addServer(String name, String image, String ram, String ip,
AddServerOptions... addServerOptions);
@GET
@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}
*
*
* @param idOrName
* id or name of the server to apply the command
* @param power
* new desired state
* @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
*
*
* @param id
* id of the server to delete
* @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;
*
*
* NOTE: Using this parameter may generate an error if one or more servers
* share a non-unique name.
*
*
* @param name
* name of the server to be deleted
*
*
* @return server before the command is executed
*/
Server deleteByName(String name);
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/delete")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
Server deleteByName(@QueryParam(NAME_KEY) String name);
/**
* Retrieves the list of supported RAM configurations. The objects will have
* RAM ID, name and description. In most cases, id or name will be used for
* {@link #addServer}.
*
* To see how RAM maps to CPU and disk space (as of March 2010), see
* {@link org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule#provideSizeToRam}
* .
*
* @return supported ram sizes
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
Set<Option> getRamSizes();
/**
* Retrieves the list of supported server types, for example Web/App Server and Database Server. In most cases, id
* or name will be used for {@link #editServerType}.
*
* @return supported server types
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
Set<Option> getTypes();
/**
* Retrieves the list of supported Datacenters to launch servers into. The
* objects will have datacenter ID, name and description. In most cases, id
* or name will be used for {@link #addServer}.
*
* @return supported datacenters
*/
@GET
@ResponseParser(ParseOptionsFromJsonResponse.class)
@Path("/common/lookup/list")
@QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
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
*/
Server editServerDescription(long id, String newDescription);
@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 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
* @param ram
* 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
* RAM ID, name and description. In most cases, id or name will be used for
* {@link #addServer}.
*
* To see how RAM maps to CPU and disk space (as of March 2010), see
* {@link org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule#provideSizeToRam}
* .
*
* @return supported ram sizes
*/
Set<Option> getRamSizes();
@GET
@SelectJson("list")
@OnlyElement
@Path("/grid/server/edit")
Server editServerRam(@QueryParam("id") long id,
@QueryParam("server.ram") String ram);
/**
* Retrieves the list of supported server types, for example Web/App Server and Database Server. In most cases, id
* or name will be used for {@link #editServerType}.
*
* @return supported server types
* Edits an existing server
*
* @param id
* id of the existing server
* @param newType
* type to replace the current one
* @return edited server
*/
Set<Option> getTypes();
/**
* Retrieves the list of supported Datacenters to launch servers into. 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();
}
@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.
*
* @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"/>
*
* @author Oleksiy Yarmula

View File

@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.LoadBalancer;
import org.jclouds.gogrid.services.GridJobClient;
import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger;
import com.google.common.base.Predicate;
@ -38,13 +38,13 @@ import com.google.inject.Inject;
@Singleton
public class LoadBalancerLatestJobCompleted implements Predicate<LoadBalancer> {
protected GridJobClient jobClient;
protected GridJobApi jobClient;
@Resource
protected Logger logger = Logger.NULL;
@Inject
public LoadBalancerLatestJobCompleted(GridJobClient jobClient) {
public LoadBalancerLatestJobCompleted(GridJobApi 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.JobState;
import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.services.GridJobClient;
import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger;
import com.google.common.base.Predicate;
@ -44,13 +44,13 @@ import com.google.inject.Inject;
@Singleton
public class ServerLatestJobCompleted implements Predicate<Server> {
protected GridJobClient jobClient;
protected GridJobApi jobClient;
@Resource
protected Logger logger = Logger.NULL;
@Inject
public ServerLatestJobCompleted(GridJobClient jobClient) {
public ServerLatestJobCompleted(GridJobApi 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.util.concurrent.ExecutionException;
import org.jclouds.gogrid.services.BaseGoGridAsyncClientTest;
import org.jclouds.gogrid.features.BaseGoGridApiTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Tests behavior of {@code GoGridAsyncClient}
* Tests behavior of {@code GoGridApi}
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GoGridAsyncClientTest")
public class GoGridAsyncClientTest extends BaseGoGridAsyncClientTest<GoGridAsyncClient> {
@Test(groups = "unit", testName = "GoGridApiTest")
public class GoGridApiTest extends BaseGoGridApiTest<GoGridApi> {
private GoGridAsyncClient asyncClient;
private GoGridClient syncClient;
private GoGridApi syncClient;
public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException,
ExecutionException {
@ -44,20 +43,10 @@ public class GoGridAsyncClientTest extends BaseGoGridAsyncClientTest<GoGridAsync
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
@Override
protected void setupFactory() throws IOException {
super.setupFactory();
asyncClient = injector.getInstance(GoGridAsyncClient.class);
syncClient = injector.getInstance(GoGridClient.class);
syncClient = injector.getInstance(GoGridApi.class);
}
}

View File

@ -72,7 +72,7 @@ import com.google.inject.Guice;
* @author Oleksiy Yarmula
*/
@Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled")
public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridClient> {
public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridApi> {
public GoGridLiveTestDisabled() {
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.NodeMetadata;
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.predicates.ServerLatestJobCompleted;
import org.jclouds.sshj.config.SshjSshClientModule;
@ -68,7 +68,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public void testResizeRam() throws Exception {
String group = this.group + "ram";
GoGridClient api = view.utils().injector().getInstance(GoGridClient.class);
GoGridApi api = view.utils().injector().getInstance(GoGridApi.class);
try {
client.destroyNodesMatching(inGroup(group));
} catch (Exception e) {

View File

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

View File

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

View File

@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
import org.jclouds.date.TimeStamp;
import org.jclouds.gogrid.GoGridClient;
import org.jclouds.gogrid.config.GoGridRestClientModule;
import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.config.GoGridHttpApiModule;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
@ -29,14 +29,14 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoGridClient> {
public class BaseGoGridHttpApiExpectTest extends BaseRestClientExpectTest<GoGridApi> {
public BaseGoGridRestClientExpectTest() {
public BaseGoGridHttpApiExpectTest() {
provider = "gogrid";
}
@ConfiguresRestClient
protected static final class TestGoGridRestClientModule extends GoGridRestClientModule {
protected static final class TestGoGridHttpApiModule extends GoGridHttpApiModule {
@Override
protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
@ -46,6 +46,6 @@ public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoG
@Override
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
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
import static java.util.concurrent.TimeUnit.SECONDS;
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
// surefire
@Test(groups = "unit", testName = "GridImageClientLiveTest")
public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
@Test(groups = "unit", testName = "GridImageApiLiveTest")
public class GridImageApiLiveTest extends BaseGoGridApiLiveTest {
public void testListImages() throws Exception {
Set<ServerImage> response = api.getImageServices().getImageList();

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
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.reflect.Invokable;
/**
* Tests behavior of {@code GridImageAsyncClient}
* Tests behavior of {@code GridImageApi}
*
* @author Oleksiy Yarmula
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", testName = "GridImageAsyncClientTest")
public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImageAsyncClient> {
@Test(groups = "unit", testName = "GridImageApiTest")
public class GridImageApiTest extends BaseGoGridApiTest<GridImageApi> {
@Test
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(
method, ImmutableList.<Object> of(
new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE)
@ -72,7 +72,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test
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"));
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
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"));
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
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"));
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
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));
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
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);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName"));
@ -173,7 +173,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImag
@Test
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);
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName",
new SaveImageOptions().withDescription("fooy")));

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
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.reflect.Invokable;
/**
* Tests behavior of {@code GridIpAsyncClient}
* Tests behavior of {@code GridIpApi}
*
* @author Oleksiy Yarmula
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridIpAsyncClientTest")
public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsyncClient> {
@Test(groups = "unit", testName = "GridIpApiTest")
public class GridIpApiTest extends BaseGoGridApiTest<GridIpApi> {
@Test
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()
.onlyUnassigned().onlyWithType(IpType.PUBLIC)));
@ -64,7 +64,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsync
@Test
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());
assertRequestLineEquals(httpRequest,

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
import static org.testng.Assert.assertEquals;
@ -31,8 +31,8 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridJobClientLiveTest")
public class GridJobClientLiveTest extends BaseGoGridClientLiveTest {
@Test(groups = "unit", testName = "GridJobApiLiveTest")
public class GridJobApiLiveTest extends BaseGoGridApiLiveTest {
public void testListJobs() throws Exception {
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
* 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.reflect.Reflection2.method;
@ -33,17 +33,17 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.reflect.Invokable;
/**
* Tests behavior of {@code GridJobAsyncClient}
* Tests behavior of {@code GridJobApi}
*
* @author Oleksiy Yarmula
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridJobAsyncClientTest")
public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsyncClient> {
@Test(groups = "unit", testName = "GridJobApiTest")
public class GridJobApiTest extends BaseGoGridApiTest<GridJobApi> {
@Test
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
.createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
.onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING)));
@ -71,7 +71,7 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsy
@Test
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());
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
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"));
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
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));
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
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
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.reflect.Invokable;
/**
* Tests behavior of {@code GridLoadBalancerAsyncClient}
* Tests behavior of {@code GridLoadBalancerApi}
*
* @author Oleksiy Yarmula
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridLoadBalancerAsyncClientTest")
public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<GridLoadBalancerAsyncClient> {
@Test(groups = "unit", testName = "GridLoadBalancerApiTest")
public class GridLoadBalancerApiTest extends BaseGoGridApiTest<GridLoadBalancerApi> {
@Test
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());
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
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);
GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt",
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
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(
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())));
@ -134,7 +134,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test
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(
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())));
@ -161,7 +161,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test
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(
"My Load Balancer", "My Load Balancer 2"));
@ -186,7 +186,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<G
@Test
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));
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
* limitations under the License.
*/
package org.jclouds.gogrid.services;
package org.jclouds.gogrid.features;
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.reflect.Invokable;
/**
* Tests behavior of {@code GridServerAsyncClient}
* Tests behavior of {@code GridServerApi}
*
* @author Oleksiy Yarmula, Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "GridServerAsyncClientTest")
public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridServerAsyncClient> {
@Test(groups = "unit", testName = "GridServerApiTest")
public class GridServerApiTest extends BaseGoGridApiTest<GridServerApi> {
@Test
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(
new GetServerListOptions.Builder().onlySandboxServers()));
@ -66,7 +66,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test
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"));
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
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));
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
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",
PowerCommand.RESTART));
@ -132,7 +132,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test
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"));
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
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());
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
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));
assertRequestLineEquals(httpRequest,
@ -192,7 +192,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test
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());
assertRequestLineEquals(httpRequest,
@ -207,7 +207,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridSer
@Test
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"));
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
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"));
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
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"));
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
* 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.assertTrue;
@ -22,7 +22,7 @@ import static org.testng.Assert.fail;
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.GetServerListOptions;
import org.jclouds.gogrid.parse.ParseServerListTest;
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "GridServerClientExpectTest")
public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
public class GridServerClientExpectTest extends BaseGoGridHttpApiExpectTest {
HttpRequest addServer = HttpRequest.builder().method("GET")
.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(
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")
.toString(), new ParseServerTest().expected().toString());
@ -75,7 +75,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
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",
"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(
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()
.expected().toString());
@ -104,7 +104,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload(
payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
GoGridClient clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
GoGridApi clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty());
}
@ -117,7 +117,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
GoGridClient clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
assertEquals(clientWhenGridServersExist.getServerServices().getServerList(
new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest()
@ -132,7 +132,7 @@ public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload(
payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
GoGridClient clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
GoGridApi clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
try {
clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
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.JobState;
import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.services.GridJobClient;
import org.jclouds.gogrid.features.GridJobApi;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -46,7 +46,7 @@ public class ServerLatestJobCompletedTest {
Job job = createMock(Job.class);
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));
replay(job);