From d4bf51128e9e67f6d9be6cd87c65fa7511074002 Mon Sep 17 00:00:00 2001 From: Andrew Bayer Date: Fri, 2 Aug 2013 07:57:07 -0700 Subject: [PATCH] Remove async from gogrid --- .../{GoGridClient.java => GoGridApi.java} | 22 +- .../org/jclouds/gogrid/GoGridApiMetadata.java | 23 +- .../org/jclouds/gogrid/GoGridAsyncClient.java | 66 ----- ...ObjectNameToGetJobsRequestQueryParams.java | 2 +- .../strategy/GoGridComputeServiceAdapter.java | 9 +- ...ntModule.java => GoGridHttpApiModule.java} | 30 +-- .../jclouds/gogrid/domain/PowerCommand.java | 2 +- .../GridImageApi.java} | 92 +++++-- .../GridIpApi.java} | 47 ++-- .../GridJobApi.java} | 44 +++- .../GridLoadBalancerApi.java} | 109 ++++++-- .../GridServerApi.java} | 239 ++++++++++++------ .../options/AddLoadBalancerOptions.java | 2 +- .../LoadBalancerLatestJobCompleted.java | 6 +- .../predicates/ServerLatestJobCompleted.java | 6 +- .../gogrid/services/GridImageClient.java | 111 -------- .../jclouds/gogrid/services/GridIpClient.java | 71 ------ .../gogrid/services/GridJobClient.java | 67 ----- .../services/GridLoadBalancerAsyncClient.java | 136 ---------- .../services/GridServerAsyncClient.java | 218 ---------------- ...syncClientTest.java => GoGridApiTest.java} | 23 +- .../gogrid/GoGridLiveTestDisabled.java | 2 +- .../compute/GoGridComputeServiceLiveTest.java | 4 +- .../BaseGoGridApiLiveTest.java} | 12 +- .../BaseGoGridApiTest.java} | 10 +- .../BaseGoGridHttpApiExpectTest.java} | 14 +- .../GridImageApiLiveTest.java} | 6 +- .../GridImageApiTest.java} | 22 +- .../GridIpApiTest.java} | 12 +- .../GridJobApiLiveTest.java} | 6 +- .../GridJobApiTest.java} | 16 +- .../GridLoadBalancerApiTest.java} | 20 +- .../GridServerApiTest.java} | 30 +-- .../GridServerClientExpectTest.java | 18 +- .../ServerLatestJobCompletedTest.java | 4 +- 35 files changed, 509 insertions(+), 992 deletions(-) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{GoGridClient.java => GoGridApi.java} (72%) delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java rename providers/gogrid/src/main/java/org/jclouds/gogrid/config/{GoGridRestClientModule.java => GoGridHttpApiModule.java} (67%) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{services/GridImageAsyncClient.java => features/GridImageApi.java} (54%) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{services/GridIpAsyncClient.java => features/GridIpApi.java} (71%) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{services/GridJobAsyncClient.java => features/GridJobApi.java} (60%) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{services/GridLoadBalancerClient.java => features/GridLoadBalancerApi.java} (53%) rename providers/gogrid/src/main/java/org/jclouds/gogrid/{services/GridServerClient.java => features/GridServerApi.java} (51%) delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpClient.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobClient.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java delete mode 100644 providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java rename providers/gogrid/src/test/java/org/jclouds/gogrid/{GoGridAsyncClientTest.java => GoGridApiTest.java} (65%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/BaseGoGridClientLiveTest.java => features/BaseGoGridApiLiveTest.java} (79%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/BaseGoGridAsyncClientTest.java => features/BaseGoGridApiTest.java} (86%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/BaseGoGridRestClientExpectTest.java => features/BaseGoGridHttpApiExpectTest.java} (76%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridImageClientLiveTest.java => features/GridImageApiLiveTest.java} (96%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridImageAsyncClientTest.java => features/GridImageApiTest.java} (89%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridIpAsyncClientTest.java => features/GridIpApiTest.java} (89%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridJobClientLiveTest.java => features/GridJobApiLiveTest.java} (92%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridJobAsyncClientTest.java => features/GridJobApiTest.java} (89%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridLoadBalancerAsyncClientTest.java => features/GridLoadBalancerApiTest.java} (91%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services/GridServerAsyncClientTest.java => features/GridServerApiTest.java} (90%) rename providers/gogrid/src/test/java/org/jclouds/gogrid/{services => features}/GridServerClientExpectTest.java (90%) diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java similarity index 72% rename from providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java rename to providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java index fac22054c8..a2ef544d75 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java @@ -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(); } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java index 53ec0b8fc7..20af47b977 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java @@ -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 { - /** - * @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> CONTEXT_TOKEN = new TypeToken>() { - 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 { + public static class Builder extends BaseHttpApiMetadata.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.>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class)); + .defaultModules(ImmutableSet.>of(GoGridHttpApiModule.class, GoGridComputeServiceContextModule.class)); } @Override diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java deleted file mode 100644 index 91b321e37c..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java +++ /dev/null @@ -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(); - -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java index d8861ef469..0b38085bd2 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java @@ -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 */ diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java index 837fa719d8..2087845e7d 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java @@ -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 sizeToRam; private final Predicate serverLatestJobCompleted; private final Predicate serverLatestJobCompletedShort; @Inject - protected GoGridComputeServiceAdapter(GoGridClient client, Function sizeToRam, Timeouts timeouts) { + protected GoGridComputeServiceAdapter(GoGridApi client, Function sizeToRam, Timeouts timeouts) { this.client = checkNotNull(client, "client"); this.sizeToRam = checkNotNull(sizeToRam, "sizeToRam"); this.serverLatestJobCompleted = retry(new ServerLatestJobCompleted(client.getJobServices()), diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java similarity index 67% rename from providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java rename to providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java index d9bc670bb6..7585583e0e 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java @@ -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 { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., 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 { @Provides @TimeStamp diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java index 9b0313bd53..c77d578fe9 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java @@ -27,7 +27,7 @@ package org.jclouds.gogrid.domain; *
  • Restart
  • * * - * @see org.jclouds.gogrid.services.GridServerClient#power(String, PowerCommand) + * @see org.jclouds.gogrid.features.GridServerApi#power(String, PowerCommand) * @see * * @author Oleksiy Yarmula diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java similarity index 54% rename from providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java rename to providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java index 779a60d934..517c2c65ec 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java @@ -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 * @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> getImageList(GetImageListOptions... options); + Set 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> getImagesById(@BinderParam(BindIdsToQueryParams.class) Long... ids); + Set 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> getImagesByName(@BinderParam(BindNamesToQueryParams.class) String... names); + Set 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 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 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> getDatacenters(); + Set + * * @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> getJobList(GetJobListOptions... options); + Set 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> getJobsForObjectName( - @BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName); + Set 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> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids); + Set getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids); } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java similarity index 53% rename from providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java rename to providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java index a5abd42141..5dcf9785ec 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java @@ -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 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 getLoadBalancersByName(String... names); + @GET + @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) + @Path("/grid/loadbalancer/get") + Set 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 getLoadBalancersById(Long... ids); + @GET + @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) + @Path("/grid/loadbalancer/get") + Set 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 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 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 realIps); + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/edit") + LoadBalancer editLoadBalancerNamed(@QueryParam(NAME_KEY) String name, + @BinderParam(BindRealIpPortPairsToQueryParams.class) List 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 realIps); + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/edit") + LoadBalancer editLoadBalancer(@QueryParam(ID_KEY) long id, + @BinderParam(BindRealIpPortPairsToQueryParams.class) List 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

    * - * @see GridServerAsyncClient * @see * * @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 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 getServersByName(String... names); + @GET + @SelectJson("list") + @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class) + @Path("/grid/server/get") + Set 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 getServersById(long... ids); + @GET + @SelectJson("list") + @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class) + @Path("/grid/server/get") + Set getServersById( + @BinderParam(BindIdsToQueryParams.class) long... ids); /** * Returns a map of running servers' names to the log in credentials. - * + * * @return map Credentials> */ + @GET + @ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class) + @Path("/support/password/list") Map 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 * * @author Oleksiy Yarmula diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java index bcf5fd0023..44fd29d171 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java @@ -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 { - protected GridJobClient jobClient; + protected GridJobApi jobClient; @Resource protected Logger logger = Logger.NULL; @Inject - public LoadBalancerLatestJobCompleted(GridJobClient jobClient) { + public LoadBalancerLatestJobCompleted(GridJobApi jobClient) { this.jobClient = jobClient; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java index f8fbddef26..2f689a4a9e 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java @@ -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 { - protected GridJobClient jobClient; + protected GridJobApi jobClient; @Resource protected Logger logger = Logger.NULL; @Inject - public ServerLatestJobCompleted(GridJobClient jobClient) { + public ServerLatestJobCompleted(GridJobApi jobClient) { this.jobClient = jobClient; } diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java deleted file mode 100644 index ee30738f9b..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java +++ /dev/null @@ -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 - * @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 getImageList(GetImageListOptions... options); - - /** - * Returns images, found by specified ids - * - * @param ids - * the ids that match existing images - * @return images found - */ - Set getImagesById(Long... ids); - - /** - * Returns images, found by specified names - * - * @param names - * the names that march existing images - * @return images found - */ - Set 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 - * - * @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 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 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 getJobsById(long... ids); - -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java deleted file mode 100644 index c78e5f24c1..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java +++ /dev/null @@ -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> getLoadBalancerList(); - - /** - * @see GridLoadBalancerClient#getLoadBalancersByName - */ - @GET - @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) - @Path("/grid/loadbalancer/get") - ListenableFuture> getLoadBalancersByName( - @BinderParam(BindNamesToQueryParams.class) String... names); - - /** - * @see GridLoadBalancerClient#getLoadBalancersById - */ - @GET - @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) - @Path("/grid/loadbalancer/get") - ListenableFuture> getLoadBalancersById( - @BinderParam(BindIdsToQueryParams.class) Long... ids); - - /** - * @see GridLoadBalancerClient#addLoadBalancer - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/add") - ListenableFuture addLoadBalancer(@QueryParam(NAME_KEY) String name, - @BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp, - @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps, - AddLoadBalancerOptions... options); - - /** - * @see GridLoadBalancerClient#editLoadBalancerNamed - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/edit") - ListenableFuture editLoadBalancerNamed(@QueryParam(NAME_KEY) String name, - @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps); - - /** - * @see GridLoadBalancerClient#editLoadBalancer - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/edit") - ListenableFuture editLoadBalancer(@QueryParam(ID_KEY) long id, - @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps); - - /** - * @see GridLoadBalancerClient# - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/delete") - ListenableFuture deleteById(@QueryParam(ID_KEY) Long id); - - /** - * @see GridLoadBalancerClient# - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/delete") - ListenableFuture 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> getDatacenters(); -} diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java deleted file mode 100644 index cab4e3815e..0000000000 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java +++ /dev/null @@ -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. - *

    - * - * @see GridServerClient - * @see - * @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> getServerList(GetServerListOptions... getServerListOptions); - - /** - * @see GridServerClient#getServersByName(String...) - */ - @GET - @SelectJson("list") - @Fallback(EmptySetOnNotFoundOr404.class) - @Path("/grid/server/get") - ListenableFuture> getServersByName( - @BinderParam(BindNamesToQueryParams.class) String... names); - - /** - * @see GridServerClient#getServersById(Long...) - */ - @GET - @SelectJson("list") - @Fallback(EmptySetOnNotFoundOr404.class) - @Path("/grid/server/get") - ListenableFuture> getServersById( - @BinderParam(BindIdsToQueryParams.class) long... ids); - - /** - * @see GridServerClient#getServerCredentialsList - */ - @GET - @ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class) - @Path("/support/password/list") - ListenableFuture> getServerCredentialsList(); - - /** - * @see GridServerClient#getServerCredentials - */ - @GET - @ResponseParser(ParseCredentialsFromJsonResponse.class) - @Path("/support/grid/password/get") - ListenableFuture 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 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 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 deleteById(@QueryParam(ID_KEY) long id); - - /** - * @see GridServerClient#deleteByName(String) - */ - @GET - @SelectJson("list") - @OnlyElement - @Path("/grid/server/delete") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture 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> getRamSizes(); - - /** - * @see GridServerClient#getTypes - */ - @GET - @ResponseParser(ParseOptionsFromJsonResponse.class) - @Path("/common/lookup/list") - @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type") - ListenableFuture> getTypes(); - - /** - * @see GridServerClient#getDatacenters - */ - @GET - @ResponseParser(ParseOptionsFromJsonResponse.class) - @Path("/common/lookup/list") - @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter") - ListenableFuture> getDatacenters(); - - - /** - * @see GridServerClient#editServerDescription - */ - @GET - @SelectJson("list") - @OnlyElement - @Path("/grid/server/edit") - ListenableFuture editServerDescription(@QueryParam("id") long id, - @QueryParam("description") String newDescription); - - /** - * @see GridServerClient#editServerRam - */ - @GET - @SelectJson("list") - @OnlyElement - @Path("/grid/server/edit") - ListenableFuture editServerRam(@QueryParam("id") long id, - @QueryParam("server.ram") String ram); - - /** - * @see GridServerClient#editServerType - */ - @GET - @SelectJson("list") - @OnlyElement - @Path("/grid/server/edit") - ListenableFuture editServerType(@QueryParam("id") long id, - @QueryParam("server.type") String newType); -} diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java similarity index 65% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java index 24ec1c54d9..0691a5d755 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GoGridApiTest") +public class GoGridApiTest extends BaseGoGridApiTest { - 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 { +public class GoGridLiveTestDisabled extends BaseApiLiveTest { public GoGridLiveTestDisabled() { provider = "gogrid"; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index 0b4ba2dc59..2ab7a8724c 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -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) { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java similarity index 79% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java index a92b3f0298..9f96e2673c 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java @@ -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 { - public BaseGoGridClientLiveTest() { +@Test(groups = "live", singleThreaded = true, testName = "BaseGoGridApiLiveTest") +public class BaseGoGridApiLiveTest extends BaseApiLiveTest { + public BaseGoGridApiLiveTest() { provider = "gogrid"; } } diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java similarity index 86% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java index f498fd517e..dbd0b16d1c 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java @@ -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 extends BaseAsyncClientTest { +public abstract class BaseGoGridApiTest extends BaseAsyncClientTest { @Override protected void checkFilters(HttpRequest request) { assertEquals(request.getFilters().size(), 1); @@ -44,7 +44,7 @@ public abstract class BaseGoGridAsyncClientTest extends BaseAsyncClientTest extends BaseAsyncClientTest { +public class BaseGoGridHttpApiExpectTest extends BaseRestClientExpectTest { - 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 cache) { @@ -46,6 +46,6 @@ public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest response = api.getImageServices().getImageList(); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java similarity index 89% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java index a52b8c844b..9b1a45b10a 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GridImageApiTest") +public class GridImageApiTest extends BaseGoGridApiTest { @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. of( new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE) @@ -72,7 +72,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest method = method(GridImageAsyncClient.class, "getImagesByName", String[].class); + Invokable method = method(GridImageApi.class, "getImagesByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 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. 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 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. 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 method = method(GridImageAsyncClient.class, "deleteById", long.class); + Invokable method = method(GridImageApi.class, "deleteById", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 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. of("friendly", "serverName")); @@ -173,7 +173,7 @@ public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest 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. of("friendly", "serverName", new SaveImageOptions().withDescription("fooy"))); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java similarity index 89% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java index 1fa2ba8563..cf082478a3 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GridIpApiTest") +public class GridIpApiTest extends BaseGoGridApiTest { @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. of(new GetIpListOptions() .onlyUnassigned().onlyWithType(IpType.PUBLIC))); @@ -64,7 +64,7 @@ public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest method = method(GridIpAsyncClient.class, "getAssignedIpList"); + Invokable method = method(GridIpApi.class, "getAssignedIpList"); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of()); assertRequestLineEquals(httpRequest, diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java similarity index 92% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java index 4397611e8e..ad7a467351 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java @@ -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 response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10)); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java similarity index 89% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java index 3a6973fd94..1d0b5e63b1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GridJobApiTest") +public class GridJobApiTest extends BaseGoGridApiTest { @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. 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 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 method = method(GridJobAsyncClient.class, "getJobsForObjectName", String.class); + Invokable method = method(GridJobApi.class, "getJobsForObjectName", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 method = method(GridJobAsyncClient.class, "getJobsById", long[].class); + Invokable method = method(GridJobApi.class, "getJobsById", long[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(123L, 456L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&" diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java similarity index 91% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java index 911ee0cacb..6fc3b25868 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GridLoadBalancerApiTest") +public class GridLoadBalancerApiTest extends BaseGoGridApiTest { @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 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. 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 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. 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 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. 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 method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancersByName", String[].class); + Invokable method = method(GridLoadBalancerApi.class, "getLoadBalancersByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of( "My Load Balancer", "My Load Balancer 2")); @@ -186,7 +186,7 @@ public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest method = method(GridLoadBalancerAsyncClient.class, "deleteById", Long.class); + Invokable method = method(GridLoadBalancerApi.class, "deleteById", Long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(55L)); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java similarity index 90% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java index 23a948993f..be06c8d6a7 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java @@ -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 { +@Test(groups = "unit", testName = "GridServerApiTest") +public class GridServerApiTest extends BaseGoGridApiTest { @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. of( new GetServerListOptions.Builder().onlySandboxServers())); @@ -66,7 +66,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = method(GridServerAsyncClient.class, "getServersByName", String[].class); + Invokable method = method(GridServerApi.class, "getServersByName", String[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 method = method(GridServerAsyncClient.class, "getServersById", long[].class); + Invokable method = method(GridServerApi.class, "getServersById", long[].class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 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. of("PowerServer", PowerCommand.RESTART)); @@ -132,7 +132,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest method = method(GridServerAsyncClient.class, "deleteByName", String.class); + Invokable method = method(GridServerApi.class, "deleteByName", String.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. 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 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 method = method(GridServerAsyncClient.class, "getServerCredentials", long.class); + Invokable method = method(GridServerApi.class, "getServerCredentials", long.class); GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList. of(1)); assertRequestLineEquals(httpRequest, @@ -192,7 +192,7 @@ public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest 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 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. 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 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. 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 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. of(2, "web")); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&" diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java similarity index 90% rename from providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java rename to providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java index e724512f16..bdcf3e6861 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java @@ -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"); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java index 44f2479017..1f5f03b2a1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java @@ -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. of(job)); replay(job);