mirror of https://github.com/apache/jclouds.git
formatting, imports, and ridding warnings
This commit is contained in:
parent
dac0c67a50
commit
3e39324e90
|
@ -23,12 +23,9 @@
|
|||
*/
|
||||
package org.jclouds.gogrid;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.google.inject.Key;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextBuilder;
|
||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||
|
@ -36,6 +33,7 @@ import org.jclouds.gogrid.config.GoGridComputeServiceContextModule;
|
|||
import org.jclouds.gogrid.config.GoGridRestClientModule;
|
||||
import org.jclouds.gogrid.config.internal.GoGridResolveImagesModule;
|
||||
|
||||
import com.google.inject.Key;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
@ -43,7 +41,8 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class GoGridContextBuilder extends ComputeServiceContextBuilder<GoGridAsyncClient, GoGridClient> {
|
||||
public class GoGridContextBuilder extends
|
||||
ComputeServiceContextBuilder<GoGridAsyncClient, GoGridClient> {
|
||||
|
||||
public GoGridContextBuilder(Properties props) {
|
||||
super(new TypeLiteral<GoGridAsyncClient>() {
|
||||
|
|
|
@ -23,15 +23,14 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
|
||||
|
||||
/**
|
||||
* Binds IDs to corresponding query parameters
|
||||
*
|
||||
|
@ -40,26 +39,24 @@ import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
|
|||
public class BindIdsToQueryParams implements Binder {
|
||||
|
||||
/**
|
||||
* Binds the ids to query parameters. The pattern, as
|
||||
* specified by GoGrid's specification, is:
|
||||
* Binds the ids to query parameters. The pattern, as specified by GoGrid's specification, is:
|
||||
*
|
||||
* https://api.gogrid.com/api/grid/server/get
|
||||
* ?id=5153
|
||||
* &id=3232
|
||||
* https://api.gogrid.com/api/grid/server/get ?id=5153 &id=3232
|
||||
*
|
||||
* @param request
|
||||
* request where the query params will be set
|
||||
* @param input array of String params
|
||||
* @param input
|
||||
* array of String params
|
||||
*/
|
||||
@Override
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest,
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest<?>,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
checkArgument(checkNotNull(input, "input is null") instanceof Long[],
|
||||
"this binder is only valid for Long[] arguments");
|
||||
|
||||
Long[] names = (Long[]) input;
|
||||
GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request;
|
||||
GeneratedHttpRequest<?> generatedRequest = (GeneratedHttpRequest<?>) request;
|
||||
|
||||
for (Long id : names) {
|
||||
generatedRequest.addQueryParam(ID_KEY, checkNotNull(id.toString(),
|
||||
|
|
|
@ -23,44 +23,41 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
|
||||
|
||||
/**
|
||||
* Binds names to corresponding query parameters
|
||||
|
||||
*
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
public class BindNamesToQueryParams implements Binder {
|
||||
|
||||
/**
|
||||
* Binds the names to query parameters. The pattern, as
|
||||
* specified by GoGrid's specification, is:
|
||||
* Binds the names to query parameters. The pattern, as specified by GoGrid's specification, is:
|
||||
*
|
||||
* https://api.gogrid.com/api/grid/server/get
|
||||
* ?name=My+Server
|
||||
* &name=My+Server+2
|
||||
* &name=My+Server+3
|
||||
* https://api.gogrid.com/api/grid/server/get ?name=My+Server &name=My+Server+2 &name=My+Server+3
|
||||
* &name=My+Server+4
|
||||
*
|
||||
* @param request
|
||||
* request where the query params will be set
|
||||
* @param input array of String params
|
||||
* @param input
|
||||
* array of String params
|
||||
*/
|
||||
@Override
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest,
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest<?>,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
checkArgument(checkNotNull(input, "input is null") instanceof String[],
|
||||
"this binder is only valid for String[] arguments");
|
||||
|
||||
String[] names = (String[]) input;
|
||||
GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request;
|
||||
GeneratedHttpRequest<?> generatedRequest = (GeneratedHttpRequest<?>) request;
|
||||
|
||||
for (String name : names) {
|
||||
generatedRequest.addQueryParam(NAME_KEY, name);
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.OBJECT_KEY;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @see org.jclouds.gogrid.services.GridJobClient#getJobsForObjectName(String)
|
||||
|
@ -35,18 +35,18 @@ import static org.jclouds.gogrid.reference.GoGridQueryParams.*;
|
|||
public class BindObjectNameToGetJobsRequestQueryParams implements Binder {
|
||||
|
||||
/**
|
||||
* Maps the object's name to the
|
||||
* input of <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.job.list/>.
|
||||
* Maps the object's name to the input of <a
|
||||
* href="http://wiki.gogrid.com/wiki/index.php/API:grid.job.list/>.
|
||||
*/
|
||||
@Override
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest,
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest<?>,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
checkArgument(checkNotNull(input, "input is null") instanceof String,
|
||||
"this binder is only valid for String arguments");
|
||||
|
||||
String serverName = (String) input;
|
||||
GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request;
|
||||
GeneratedHttpRequest<?> generatedRequest = (GeneratedHttpRequest<?>) request;
|
||||
|
||||
generatedRequest.addQueryParam(OBJECT_KEY, serverName);
|
||||
}
|
||||
|
|
|
@ -18,21 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.VIRTUAL_IP_KEY;
|
||||
|
||||
import org.jclouds.gogrid.domain.IpPortPair;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.Binder;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.VIRTUAL_IP_KEY;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
/**
|
||||
* Binds a virtual IP to the request.
|
||||
*
|
||||
* The {@link IpPortPair} must have a {@link IpPortPair#ip} set with a valid
|
||||
* IP address.
|
||||
* The {@link IpPortPair} must have a {@link IpPortPair#ip} set with a valid IP address.
|
||||
*
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
|
@ -40,13 +39,13 @@ public class BindVirtualIpPortPairToQueryParams implements Binder {
|
|||
|
||||
@Override
|
||||
public void bindToRequest(HttpRequest request, Object input) {
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest,
|
||||
checkArgument(checkNotNull(request, "request is null") instanceof GeneratedHttpRequest<?>,
|
||||
"this binder is only valid for GeneratedHttpRequests!");
|
||||
checkArgument(checkNotNull(input, "input is null") instanceof IpPortPair,
|
||||
"this binder is only valid for a IpPortPair argument");
|
||||
|
||||
IpPortPair ipPortPair = (IpPortPair) input;
|
||||
GeneratedHttpRequest generatedRequest = (GeneratedHttpRequest) request;
|
||||
GeneratedHttpRequest<?> generatedRequest = (GeneratedHttpRequest<?>) request;
|
||||
|
||||
checkNotNull(ipPortPair.getIp(), "There must be an IP address defined");
|
||||
checkNotNull(ipPortPair.getIp().getIp(), "There must be an IP address defined in Ip object");
|
||||
|
|
|
@ -26,23 +26,24 @@ package org.jclouds.gogrid.config;
|
|||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.*;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||
import org.jclouds.gogrid.GoGridClient;
|
||||
import org.jclouds.gogrid.reference.GoGridConstants;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.reference.GoGridConstants;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -60,9 +61,11 @@ public class GoGridContextModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<GoGridAsyncClient, GoGridClient> provideContext(Closer closer, GoGridAsyncClient asyncApi,
|
||||
GoGridClient syncApi, @GoGrid URI endPoint, @Named(GoGridConstants.PROPERTY_GOGRID_USER) String account) {
|
||||
return new RestContextImpl<GoGridAsyncClient, GoGridClient>(closer, asyncApi, syncApi, endPoint, account);
|
||||
RestContext<GoGridAsyncClient, GoGridClient> provideContext(Closer closer,
|
||||
GoGridAsyncClient asyncApi, GoGridClient syncApi, @GoGrid URI endPoint,
|
||||
@Named(GoGridConstants.PROPERTY_GOGRID_USER) String account) {
|
||||
return new RestContextImpl<GoGridAsyncClient, GoGridClient>(closer, asyncApi, syncApi,
|
||||
endPoint, account);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.config;
|
||||
|
||||
import static org.jclouds.gogrid.reference.GoGridConstants.PROPERTY_GOGRID_SESSIONINTERVAL;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
@ -49,17 +51,33 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.concurrent.ExpirableSupplier;
|
||||
import org.jclouds.concurrent.internal.SyncProxy;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.gogrid.domain.*;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.IpState;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerOs;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerType;
|
||||
import org.jclouds.gogrid.domain.ObjectType;
|
||||
import org.jclouds.gogrid.domain.ServerImageState;
|
||||
import org.jclouds.gogrid.domain.ServerImageType;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.gogrid.handlers.GoGridErrorHandler;
|
||||
import org.jclouds.gogrid.services.*;
|
||||
import org.jclouds.gogrid.reference.GoGridConstants;
|
||||
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.RequiresHttp;
|
||||
import org.jclouds.http.annotation.ClientError;
|
||||
|
@ -70,14 +88,12 @@ import org.jclouds.predicates.SocketOpen;
|
|||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestClientFactory;
|
||||
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.reference.GoGridConstants;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import static org.jclouds.gogrid.reference.GoGridConstants.*;
|
||||
|
||||
/**
|
||||
* Configures the GoGrid connection.
|
||||
*
|
||||
|
@ -102,8 +118,8 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public GridServerClient provideServerClient(GridServerAsyncClient client) throws IllegalArgumentException,
|
||||
SecurityException, NoSuchMethodException {
|
||||
public GridServerClient provideServerClient(GridServerAsyncClient client)
|
||||
throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(GridServerClient.class, client);
|
||||
}
|
||||
|
||||
|
@ -115,8 +131,8 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public GridJobClient provideJobClient(GridJobAsyncClient client) throws IllegalArgumentException,
|
||||
SecurityException, NoSuchMethodException {
|
||||
public GridJobClient provideJobClient(GridJobAsyncClient client)
|
||||
throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(GridJobClient.class, client);
|
||||
}
|
||||
|
||||
|
@ -141,8 +157,8 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public GridLoadBalancerClient provideLoadBalancerClient(GridLoadBalancerAsyncClient client) throws IllegalArgumentException,
|
||||
SecurityException, NoSuchMethodException {
|
||||
public GridLoadBalancerClient provideLoadBalancerClient(GridLoadBalancerAsyncClient client)
|
||||
throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(GridLoadBalancerClient.class, client);
|
||||
}
|
||||
|
||||
|
@ -154,8 +170,8 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public GridImageClient provideImageClient(GridImageAsyncClient client) throws IllegalArgumentException,
|
||||
SecurityException, NoSuchMethodException {
|
||||
public GridImageClient provideImageClient(GridImageAsyncClient client)
|
||||
throws IllegalArgumentException, SecurityException, NoSuchMethodException {
|
||||
return SyncProxy.create(GridImageClient.class, client);
|
||||
}
|
||||
|
||||
|
@ -178,6 +194,7 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
return new RetryablePredicate<InetSocketAddress>(open, 130, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Provides
|
||||
@Singleton
|
||||
@com.google.inject.name.Named(Constants.PROPERTY_GSON_ADAPTERS)
|
||||
|
@ -186,7 +203,8 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
bindings.put(ObjectType.class, new CustomDeserializers.ObjectTypeAdapter());
|
||||
bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter());
|
||||
bindings.put(LoadBalancerState.class, new CustomDeserializers.LoadBalancerStateAdapter());
|
||||
bindings.put(LoadBalancerPersistenceType.class, new CustomDeserializers.LoadBalancerPersistenceTypeAdapter());
|
||||
bindings.put(LoadBalancerPersistenceType.class,
|
||||
new CustomDeserializers.LoadBalancerPersistenceTypeAdapter());
|
||||
bindings.put(LoadBalancerType.class, new CustomDeserializers.LoadBalancerTypeAdapter());
|
||||
bindings.put(IpState.class, new CustomDeserializers.IpStateAdapter());
|
||||
bindings.put(JobState.class, new CustomDeserializers.JobStateAdapter());
|
||||
|
@ -195,14 +213,12 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
return bindings;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* borrowing concurrency code to ensure that caching takes place properly
|
||||
*/
|
||||
@Provides
|
||||
@TimeStamp
|
||||
Supplier<Long> provideTimeStampCache(
|
||||
@Named(PROPERTY_GOGRID_SESSIONINTERVAL) long seconds) {
|
||||
Supplier<Long> provideTimeStampCache(@Named(PROPERTY_GOGRID_SESSIONINTERVAL) long seconds) {
|
||||
return new ExpirableSupplier<Long>(new Supplier<Long>() {
|
||||
public Long get() {
|
||||
return System.currentTimeMillis() / 1000;
|
||||
|
@ -211,12 +227,9 @@ public class GoGridRestClientModule extends AbstractModule {
|
|||
}
|
||||
|
||||
protected void bindErrorHandlers() {
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(
|
||||
GoGridErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(
|
||||
GoGridErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(
|
||||
GoGridErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GoGridErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GoGridErrorHandler.class);
|
||||
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GoGridErrorHandler.class);
|
||||
}
|
||||
|
||||
protected void bindRetryHandlers() {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.domain;
|
||||
|
||||
import org.omg.CORBA.UNKNOWN;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
|
@ -27,17 +25,17 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*/
|
||||
public enum JobState {
|
||||
|
||||
QUEUED("Queued", "Change request is new to the system."),
|
||||
PROCESSING("Processing", "Change request is is transient state...Processing."),
|
||||
SUCCEEDED("Succeeded", "Change request has succeeded."),
|
||||
FAILED("Failed", "Change request has failed."),
|
||||
CANCELED("Canceled", "Change request has been canceled."),
|
||||
FATAL("Fatal", "Change request had Fatal or Unrecoverable Failure"),
|
||||
CREATED("Created", "Change request is created but not queued yet"),
|
||||
UNKNOWN("Unknown", "The state is unknown to JClouds");
|
||||
QUEUED("Queued", "Change request is new to the system."), PROCESSING("Processing",
|
||||
"Change request is is transient state...Processing."), SUCCEEDED("Succeeded",
|
||||
"Change request has succeeded."), FAILED("Failed", "Change request has failed."), CANCELED(
|
||||
"Canceled", "Change request has been canceled."), FATAL("Fatal",
|
||||
"Change request had Fatal or Unrecoverable Failure"), CREATED("Created",
|
||||
"Change request is created but not queued yet"), UNKNOWN("Unknown",
|
||||
"The state is unknown to JClouds");
|
||||
|
||||
String name;
|
||||
String description;
|
||||
|
||||
JobState(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
|
@ -50,7 +48,8 @@ public enum JobState {
|
|||
|
||||
public static JobState fromValue(String state) {
|
||||
for (JobState jobState : values()) {
|
||||
if(jobState.name.equals(checkNotNull(state))) return jobState;
|
||||
if (jobState.name.equals(checkNotNull(state)))
|
||||
return jobState;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.domain;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
|
@ -27,12 +25,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
*/
|
||||
public enum LoadBalancerPersistenceType {
|
||||
|
||||
NONE("None"),
|
||||
SSL_STICKY("SSL Sticky"),
|
||||
SOURCE_ADDRESS("Source Address"),
|
||||
UNKNOWN("Unknown");
|
||||
NONE("None"), SSL_STICKY("SSL Sticky"), SOURCE_ADDRESS("Source Address"), UNKNOWN("Unknown");
|
||||
|
||||
String type;
|
||||
|
||||
LoadBalancerPersistenceType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -44,7 +40,8 @@ public enum LoadBalancerPersistenceType {
|
|||
|
||||
public static LoadBalancerPersistenceType fromValue(String type) {
|
||||
for (LoadBalancerPersistenceType persistenceType : values()) {
|
||||
if(persistenceType.type.equals(checkNotNull(type))) return persistenceType;
|
||||
if (persistenceType.type.equals(checkNotNull(type)))
|
||||
return persistenceType;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
|
|
@ -23,13 +23,11 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.domain;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
|
||||
/**
|
||||
* Server's state transition.
|
||||
*
|
||||
* Using this value, server's state will be changed
|
||||
* to one of the following:
|
||||
* Using this value, server's state will be changed to one of the following:
|
||||
* <ul>
|
||||
* <li>Start</li>
|
||||
* <li>Stop</li>
|
||||
|
@ -42,10 +40,7 @@ import com.google.common.base.CaseFormat;
|
|||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
public enum PowerCommand {
|
||||
START,
|
||||
STOP /*NOTE: This is a hard shutdown, equivalent to powering off a server.*/,
|
||||
RESTART;
|
||||
|
||||
START, STOP /* NOTE: This is a hard shutdown, equivalent to powering off a server. */, RESTART;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -23,8 +23,16 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.filters;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
|
@ -36,15 +44,8 @@ import org.jclouds.logging.Logger;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.lang.String.format;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -62,8 +63,7 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter {
|
|||
@Inject
|
||||
public SharedKeyLiteAuthentication(@Named(GoGridConstants.PROPERTY_GOGRID_USER) String apiKey,
|
||||
@Named(GoGridConstants.PROPERTY_GOGRID_PASSWORD) String secret,
|
||||
@TimeStamp Long timeStamp,
|
||||
EncryptionService encryptionService) {
|
||||
@TimeStamp Long timeStamp, EncryptionService encryptionService) {
|
||||
this.encryptionService = encryptionService;
|
||||
this.apiKey = apiKey;
|
||||
this.secret = secret;
|
||||
|
@ -73,21 +73,20 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter {
|
|||
public void filter(HttpRequest request) {
|
||||
checkArgument(checkNotNull(request, "input") instanceof GeneratedHttpRequest<?>,
|
||||
"this decorator is only valid for GeneratedHttpRequests!");
|
||||
GeneratedHttpRequest<?> generatedRequest = (GeneratedHttpRequest<?>) request;
|
||||
|
||||
String toSign = createStringToSign();
|
||||
String signatureMd5 = getMd5For(toSign);
|
||||
|
||||
String query = request.getEndpoint().getQuery();
|
||||
Multimap<String, String> decodedParams =
|
||||
RestAnnotationProcessor.parseQueryToMap(query);
|
||||
Multimap<String, String> decodedParams = RestAnnotationProcessor.parseQueryToMap(query);
|
||||
|
||||
decodedParams.replaceValues("sig", ImmutableSet.of(signatureMd5));
|
||||
decodedParams.replaceValues("api_key", ImmutableSet.of(apiKey));
|
||||
|
||||
String updatedQuery = RestAnnotationProcessor.makeQueryLine(decodedParams, null);
|
||||
String requestBasePart = request.getEndpoint().toASCIIString();
|
||||
String updatedEndpoint = requestBasePart.substring(0, requestBasePart.indexOf("?") + 1) + updatedQuery;
|
||||
String updatedEndpoint = requestBasePart.substring(0, requestBasePart.indexOf("?") + 1)
|
||||
+ updatedQuery;
|
||||
request.setEndpoint(URI.create(updatedEndpoint));
|
||||
|
||||
HttpUtils.logRequest(signatureLog, request, "<<");
|
||||
|
|
|
@ -23,26 +23,25 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Singleton;
|
||||
import org.jclouds.gogrid.domain.internal.ErrorResponse;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.gogrid.domain.internal.ErrorResponse;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Parses {@link org.jclouds.gogrid.domain.internal.ErrorResponse
|
||||
* error response} from a json string.
|
||||
* Parses {@link org.jclouds.gogrid.domain.internal.ErrorResponse error response} from a json
|
||||
* string.
|
||||
*
|
||||
* GoGrid may return multiple error objects, if multiple errors were found.
|
||||
*
|
||||
|
|
|
@ -18,20 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Parses {@link org.jclouds.gogrid.domain.LoadBalancer jobs} from a json string.
|
||||
*
|
||||
|
|
|
@ -18,25 +18,25 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.domain.Option;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.gogrid.domain.Option;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Parses the list of generic options.
|
||||
*
|
||||
* GoGrid uses options as containers for
|
||||
* id/name/description objects.
|
||||
* GoGrid uses options as containers for id/name/description objects.
|
||||
*
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.SortedSet;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
|
|
@ -18,32 +18,29 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.internal.ImmutableMap;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.domain.internal.GenericResponseContainer;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
public class ParseServerNameToCredentialsMapFromJsonResponse extends ParseJson<Map<String, Credentials>> {
|
||||
public class ParseServerNameToCredentialsMapFromJsonResponse extends
|
||||
ParseJson<Map<String, Credentials>> {
|
||||
|
||||
@Inject
|
||||
public ParseServerNameToCredentialsMapFromJsonResponse(Gson gson) {
|
||||
|
@ -61,13 +58,12 @@ public class ParseServerNameToCredentialsMapFromJsonResponse extends ParseJson<M
|
|||
}
|
||||
Map<String, Credentials> serverNameToCredentials = Maps.newHashMap();
|
||||
for (Password password : response.getList()) {
|
||||
serverNameToCredentials.put(password.getServer().getName(),
|
||||
new Credentials(password.getUserName(), password.getPassword()));
|
||||
serverNameToCredentials.put(password.getServer().getName(), new Credentials(password
|
||||
.getUserName(), password.getPassword()));
|
||||
}
|
||||
return serverNameToCredentials;
|
||||
}
|
||||
|
||||
|
||||
public static class Password implements Comparable<Password> {
|
||||
@SerializedName("username")
|
||||
private String userName;
|
||||
|
@ -88,14 +84,19 @@ public class ParseServerNameToCredentialsMapFromJsonResponse extends ParseJson<M
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Password password1 = (Password) o;
|
||||
|
||||
if (password != null ? !password.equals(password1.password) : password1.password != null) return false;
|
||||
if (server != null ? !server.equals(password1.server) : password1.server != null) return false;
|
||||
if (userName != null ? !userName.equals(password1.userName) : password1.userName != null) return false;
|
||||
if (password != null ? !password.equals(password1.password) : password1.password != null)
|
||||
return false;
|
||||
if (server != null ? !server.equals(password1.server) : password1.server != null)
|
||||
return false;
|
||||
if (userName != null ? !userName.equals(password1.userName) : password1.userName != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.handlers;
|
||||
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.gogrid.GoGridResponseException;
|
||||
import org.jclouds.gogrid.domain.internal.ErrorResponse;
|
||||
import org.jclouds.gogrid.functions.ParseErrorFromJsonResponse;
|
||||
|
@ -32,10 +33,9 @@ import org.jclouds.http.HttpCommand;
|
|||
import org.jclouds.http.HttpErrorHandler;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Set;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -49,7 +49,6 @@ public class GoGridErrorHandler implements HttpErrorHandler {
|
|||
this.errorParser = errorParser;
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ThrowableInstanceNeverThrown"})
|
||||
@Override
|
||||
public void handleError(HttpCommand command, HttpResponse response) {
|
||||
Exception exception;
|
||||
|
@ -59,9 +58,8 @@ public class GoGridErrorHandler implements HttpErrorHandler {
|
|||
exception = new HttpResponseException(command, response);
|
||||
break;
|
||||
default:
|
||||
exception = errors != null ?
|
||||
new GoGridResponseException(command, response, errors) :
|
||||
new HttpResponseException(command, response);
|
||||
exception = errors != null ? new GoGridResponseException(command, response, errors)
|
||||
: new HttpResponseException(command, response);
|
||||
}
|
||||
command.setException(exception);
|
||||
Closeables.closeQuietly(response.getContent());
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package org.jclouds.gogrid.services;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.gogrid.binders.BindIdsToQueryParams;
|
||||
import org.jclouds.gogrid.domain.ServerImage;
|
||||
import org.jclouds.gogrid.options.GetImageListOptions;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.gogrid.domain.ServerImage;
|
||||
import org.jclouds.gogrid.options.GetImageListOptions;
|
||||
|
||||
/**
|
||||
* Manages the server images
|
||||
*
|
||||
|
@ -21,21 +19,26 @@ public interface GridImageClient {
|
|||
/**
|
||||
* Returns all server images.
|
||||
*
|
||||
* @param options options to narrow the search down
|
||||
* @param options
|
||||
* options to narrow the search down
|
||||
* @return server images found
|
||||
*/
|
||||
Set<ServerImage> getImageList(GetImageListOptions... options);
|
||||
|
||||
/**
|
||||
* Returns images, found by specified ids
|
||||
* @param ids the ids that match existing images
|
||||
*
|
||||
* @param ids
|
||||
* the ids that match existing images
|
||||
* @return images found
|
||||
*/
|
||||
Set<ServerImage> getImagesById(Long... ids);
|
||||
|
||||
/**
|
||||
* Returns images, found by specified names
|
||||
* @param names the names that march existing images
|
||||
*
|
||||
* @param names
|
||||
* the names that march existing images
|
||||
* @return images found
|
||||
*/
|
||||
Set<ServerImage> getImagesByName(String... names);
|
||||
|
@ -43,8 +46,10 @@ public interface GridImageClient {
|
|||
/**
|
||||
* Edits an existing image
|
||||
*
|
||||
* @param idOrName id or name of the existing image
|
||||
* @param newDescription description to replace the current one
|
||||
* @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);
|
||||
|
@ -52,8 +57,10 @@ public interface GridImageClient {
|
|||
/**
|
||||
* Edits an existing image
|
||||
*
|
||||
* @param idOrName id or name of the existing image
|
||||
* @param newFriendlyName friendly name to replace the current one
|
||||
* @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);
|
||||
|
|
|
@ -18,11 +18,17 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_STATE_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_TYPE_KEY;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
import org.jclouds.gogrid.domain.IpState;
|
||||
import org.jclouds.gogrid.domain.IpType;
|
||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||
import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
|
||||
import org.jclouds.gogrid.options.GetIpListOptions;
|
||||
|
@ -31,13 +37,7 @@ import org.jclouds.rest.annotations.QueryParams;
|
|||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_STATE_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_TYPE_KEY;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.gogrid.services.GridImageClient
|
||||
|
@ -66,7 +66,6 @@ public interface GridIpAsyncClient {
|
|||
@QueryParams(keys = IP_STATE_KEY, values = "Unassigned")
|
||||
ListenableFuture<Set<Ip>> getUnassignedIpList();
|
||||
|
||||
|
||||
/**
|
||||
* @see org.jclouds.gogrid.services.GridIpClient#getUnassignedPublicIpList()
|
||||
*/
|
||||
|
@ -85,5 +84,4 @@ public interface GridIpAsyncClient {
|
|||
@QueryParams(keys = IP_STATE_KEY, values = "Assigned")
|
||||
ListenableFuture<Set<Ip>> getAssignedIpList();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,27 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobProperties;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.ObjectType;
|
||||
import org.jclouds.gogrid.domain.Option;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -25,21 +46,6 @@ import com.google.gson.Gson;
|
|||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
import org.jclouds.gogrid.domain.*;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -62,25 +68,15 @@ public class ParseJobsFromJsonResponseTest {
|
|||
details.put("name", "ServerCreated40562");
|
||||
details.put("type", "virtual_server");
|
||||
|
||||
Job job = new Job(250628L,
|
||||
new Option(7L, "DeleteVirtualServer", "Delete Virtual Server"),
|
||||
ObjectType.VIRTUAL_SERVER,
|
||||
new Date(1267404528895L),
|
||||
new Date(1267404538592L),
|
||||
JobState.SUCCEEDED,
|
||||
1,
|
||||
"3116784158f0af2d-24076@api.gogrid.com",
|
||||
ImmutableSortedSet.of(
|
||||
new JobProperties(940263L, new Date(1267404528897L),
|
||||
JobState.CREATED, null),
|
||||
new JobProperties(940264L, new Date(1267404528967L),
|
||||
JobState.QUEUED, null)
|
||||
),
|
||||
details);
|
||||
Job job = new Job(250628L, new Option(7L, "DeleteVirtualServer", "Delete Virtual Server"),
|
||||
ObjectType.VIRTUAL_SERVER, new Date(1267404528895L), new Date(1267404538592L),
|
||||
JobState.SUCCEEDED, 1, "3116784158f0af2d-24076@api.gogrid.com", ImmutableSortedSet
|
||||
.of(new JobProperties(940263L, new Date(1267404528897L), JobState.CREATED,
|
||||
null), new JobProperties(940264L, new Date(1267404528967L),
|
||||
JobState.QUEUED, null)), details);
|
||||
assertEquals(job, Iterables.getOnlyElement(response));
|
||||
}
|
||||
|
||||
|
||||
Injector i = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -88,6 +84,7 @@ public class ParseJobsFromJsonResponseTest {
|
|||
super.configure();
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@Provides
|
||||
@Singleton
|
||||
@com.google.inject.name.Named(Constants.PROPERTY_GSON_ADAPTERS)
|
||||
|
@ -99,5 +96,4 @@ public class ParseJobsFromJsonResponseTest {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,29 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
import org.jclouds.gogrid.domain.IpPortPair;
|
||||
import org.jclouds.gogrid.domain.IpState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerOs;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerType;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -25,21 +48,6 @@ import com.google.gson.Gson;
|
|||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
import org.jclouds.gogrid.domain.*;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -55,30 +63,13 @@ public class ParseLoadBalancersFromJsonResponseTest {
|
|||
.getInstance(Gson.class));
|
||||
SortedSet<LoadBalancer> response = parser.apply(is);
|
||||
|
||||
LoadBalancer loadBalancer = new LoadBalancer(6372L,
|
||||
"Balancer", null, new IpPortPair(new Ip(1313082L,
|
||||
"204.51.240.181",
|
||||
"204.51.240.176/255.255.255.240",
|
||||
true,
|
||||
IpState.ASSIGNED),
|
||||
80),
|
||||
ImmutableSortedSet.of(
|
||||
new IpPortPair(new Ip(1313086L,
|
||||
"204.51.240.185",
|
||||
"204.51.240.176/255.255.255.240",
|
||||
true,
|
||||
IpState.ASSIGNED),
|
||||
80),
|
||||
new IpPortPair(new Ip(1313089L,
|
||||
"204.51.240.188",
|
||||
"204.51.240.176/255.255.255.240",
|
||||
true,
|
||||
IpState.ASSIGNED),
|
||||
80)
|
||||
),
|
||||
LoadBalancerType.ROUND_ROBIN,
|
||||
LoadBalancerPersistenceType.NONE,
|
||||
LoadBalancerOs.F5,
|
||||
LoadBalancer loadBalancer = new LoadBalancer(6372L, "Balancer", null, new IpPortPair(
|
||||
new Ip(1313082L, "204.51.240.181", "204.51.240.176/255.255.255.240", true,
|
||||
IpState.ASSIGNED), 80), ImmutableSortedSet.of(new IpPortPair(
|
||||
new Ip(1313086L, "204.51.240.185", "204.51.240.176/255.255.255.240", true,
|
||||
IpState.ASSIGNED), 80), new IpPortPair(new Ip(1313089L, "204.51.240.188",
|
||||
"204.51.240.176/255.255.255.240", true, IpState.ASSIGNED), 80)),
|
||||
LoadBalancerType.ROUND_ROBIN, LoadBalancerPersistenceType.NONE, LoadBalancerOs.F5,
|
||||
LoadBalancerState.ON);
|
||||
assertEquals(Iterables.getOnlyElement(response), loadBalancer);
|
||||
}
|
||||
|
@ -92,12 +83,14 @@ public class ParseLoadBalancersFromJsonResponseTest {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@com.google.inject.name.Named(Constants.PROPERTY_GSON_ADAPTERS)
|
||||
public Map<Class, Object> provideCustomAdapterBindings() {
|
||||
Map<Class, Object> bindings = Maps.newHashMap();
|
||||
bindings.put(LoadBalancerOs.class, new CustomDeserializers.LoadBalancerOsAdapter());
|
||||
bindings.put(LoadBalancerState.class, new CustomDeserializers.LoadBalancerStateAdapter());
|
||||
bindings.put(LoadBalancerPersistenceType.class, new CustomDeserializers.LoadBalancerPersistenceTypeAdapter());
|
||||
bindings.put(LoadBalancerPersistenceType.class,
|
||||
new CustomDeserializers.LoadBalancerPersistenceTypeAdapter());
|
||||
bindings.put(LoadBalancerType.class, new CustomDeserializers.LoadBalancerTypeAdapter());
|
||||
bindings.put(IpState.class, new CustomDeserializers.IpStateAdapter());
|
||||
return bindings;
|
||||
|
|
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.functions;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
|
@ -32,12 +35,12 @@ import org.jclouds.gogrid.domain.ServerImageType;
|
|||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -49,13 +52,12 @@ public class ParseServerNameToCredentialsMapFromJsonResponseTest {
|
|||
public void testApplyInputStreamDetails() throws UnknownHostException {
|
||||
InputStream is = getClass().getResourceAsStream("/test_credentials_list.json");
|
||||
|
||||
ParseServerNameToCredentialsMapFromJsonResponse parser = new ParseServerNameToCredentialsMapFromJsonResponse(i
|
||||
.getInstance(Gson.class));
|
||||
ParseServerNameToCredentialsMapFromJsonResponse parser = new ParseServerNameToCredentialsMapFromJsonResponse(
|
||||
i.getInstance(Gson.class));
|
||||
Map<String, Credentials> response = parser.apply(is);
|
||||
assertEquals(response.size(), 6);
|
||||
}
|
||||
|
||||
|
||||
Injector i = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -63,9 +65,9 @@ public class ParseServerNameToCredentialsMapFromJsonResponseTest {
|
|||
super.configure();
|
||||
}
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@com.google.inject.name.Named(Constants.PROPERTY_GSON_ADAPTERS)
|
||||
public Map<Class, Object> provideCustomAdapterBindings() {
|
||||
Map<Class, Object> bindings = Maps.newHashMap();
|
||||
|
|
|
@ -27,27 +27,34 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.gogrid.config.GoGridContextModule;
|
||||
import org.jclouds.gogrid.domain.*;
|
||||
import org.jclouds.gogrid.domain.BillingToken;
|
||||
import org.jclouds.gogrid.domain.Customer;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
import org.jclouds.gogrid.domain.IpState;
|
||||
import org.jclouds.gogrid.domain.Option;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.domain.ServerImage;
|
||||
import org.jclouds.gogrid.domain.ServerImageState;
|
||||
import org.jclouds.gogrid.domain.ServerImageType;
|
||||
import org.jclouds.gogrid.functions.internal.CustomDeserializers;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseStatusesFromJsonResponse}
|
||||
|
@ -67,30 +74,22 @@ public class ParseServersFromJsonResponseTest {
|
|||
|
||||
Option centOs = new Option(13L, "CentOS 5.2 (32-bit)", "CentOS 5.2 (32-bit)");
|
||||
Option webServer = new Option(1L, "Web Server", "Web or Application Server");
|
||||
Server server = new Server(75245L, false, "PowerServer", "server to test the api. created by Alex",
|
||||
new Option(1L, "On", "Server is in active state."),
|
||||
webServer,
|
||||
new Option(1L, "512MB", "Server with 512MB RAM"),
|
||||
centOs,
|
||||
new Ip(1313079L, "204.51.240.178", "204.51.240.176/255.255.255.240", true,
|
||||
IpState.ASSIGNED),
|
||||
new ServerImage(1946L, "GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
||||
"BitNami Gallery 2.3.1-0", "http://bitnami.org/stack/gallery",
|
||||
centOs, null, ServerImageType.WEB_APPLICATION_SERVER,
|
||||
ServerImageState.AVAILABLE,
|
||||
0.0, "24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img",
|
||||
true, true,
|
||||
new Date(1261504577971L),
|
||||
new Date(1262649582180L),
|
||||
ImmutableSortedSet.of(
|
||||
new BillingToken(38L, "CentOS 5.2 32bit", 0.0),
|
||||
new BillingToken(56L, "BitNami: Gallery", 0.0)
|
||||
),
|
||||
new Customer(24732L, "BitRock")));
|
||||
Server server = new Server(75245L, false, "PowerServer",
|
||||
"server to test the api. created by Alex", new Option(1L, "On",
|
||||
"Server is in active state."), webServer, new Option(1L, "512MB",
|
||||
"Server with 512MB RAM"), centOs, new Ip(1313079L, "204.51.240.178",
|
||||
"204.51.240.176/255.255.255.240", true, IpState.ASSIGNED), new ServerImage(
|
||||
1946L, "GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
||||
"BitNami Gallery 2.3.1-0", "http://bitnami.org/stack/gallery", centOs,
|
||||
null, ServerImageType.WEB_APPLICATION_SERVER, ServerImageState.AVAILABLE,
|
||||
0.0, "24732/GSI-f8979644-e646-4711-ad58-d98a5fa3612c.img", true, true,
|
||||
new Date(1261504577971L), new Date(1262649582180L), ImmutableSortedSet.of(
|
||||
new BillingToken(38L, "CentOS 5.2 32bit", 0.0), new BillingToken(
|
||||
56L, "BitNami: Gallery", 0.0)), new Customer(24732L,
|
||||
"BitRock")));
|
||||
assertEquals(Iterables.getOnlyElement(response), server);
|
||||
}
|
||||
|
||||
|
||||
Injector i = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -98,9 +97,9 @@ public class ParseServersFromJsonResponseTest {
|
|||
super.configure();
|
||||
}
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@SuppressWarnings( { "unused", "unchecked" })
|
||||
@com.google.inject.name.Named(Constants.PROPERTY_GSON_ADAPTERS)
|
||||
public Map<Class, Object> provideCustomAdapterBindings() {
|
||||
Map<Class, Object> bindings = Maps.newHashMap();
|
||||
|
|
|
@ -18,11 +18,15 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.ServerImageState;
|
||||
|
@ -37,13 +41,11 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -52,15 +54,14 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
|
||||
@Test
|
||||
public void testGetImageListWithOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridImageAsyncClient.class.getMethod("getImageList", GetImageListOptions[].class);
|
||||
Method method = GridImageAsyncClient.class.getMethod("getImageList",
|
||||
GetImageListOptions[].class);
|
||||
GeneratedHttpRequest<GridImageAsyncClient> httpRequest = processor.createRequest(method,
|
||||
new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE).
|
||||
setType(ServerImageType.WEB_APPLICATION_SERVER));
|
||||
new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE).setType(
|
||||
ServerImageType.WEB_APPLICATION_SERVER));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/list?v=1.4&" +
|
||||
"isPublic=true&image.state=Available&" +
|
||||
"image.type=Web%20Server HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?v=1.4&"
|
||||
+ "isPublic=true&image.state=Available&" + "image.type=Web%20Server HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -71,12 +72,9 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/list?" +
|
||||
"v=1.4&isPublic=true&image.state=Available&" +
|
||||
"image.type=Web%20Server&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?"
|
||||
+ "v=1.4&isPublic=true&image.state=Available&" + "image.type=Web%20Server&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
@ -87,9 +85,8 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
GeneratedHttpRequest<GridImageAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"name1", "name2");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/get?v=1.4&" +
|
||||
"name=name1&name=name2 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.4&"
|
||||
+ "name=name1&name=name2 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -100,24 +97,22 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/get?v=1.4&" +
|
||||
"name=name1&name=name2&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.4&"
|
||||
+ "name=name1&name=name2&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditImageDescription() throws NoSuchMethodException, IOException {
|
||||
Method method = GridImageAsyncClient.class.getMethod("editImageDescription", String.class, String.class);
|
||||
Method method = GridImageAsyncClient.class.getMethod("editImageDescription", String.class,
|
||||
String.class);
|
||||
GeneratedHttpRequest<GridImageAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"imageName", "newDesc");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/edit?v=1.4&" +
|
||||
"image=imageName&description=newDesc HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.4&"
|
||||
+ "image=imageName&description=newDesc HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -128,24 +123,22 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/edit?v=1.4&" +
|
||||
"image=imageName&description=newDesc&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.4&"
|
||||
+ "image=imageName&description=newDesc&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditImageFriendlyName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridImageAsyncClient.class.getMethod("editImageFriendlyName", String.class, String.class);
|
||||
Method method = GridImageAsyncClient.class.getMethod("editImageFriendlyName", String.class,
|
||||
String.class);
|
||||
GeneratedHttpRequest<GridImageAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"imageName", "newFriendlyName");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/edit?v=1.4&" +
|
||||
"image=imageName&friendlyName=newFriendlyName HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.4&"
|
||||
+ "image=imageName&friendlyName=newFriendlyName HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -156,11 +149,9 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/image/edit?v=1.4&" +
|
||||
"image=imageName&friendlyName=newFriendlyName&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.4&"
|
||||
+ "image=imageName&friendlyName=newFriendlyName&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
@ -191,10 +182,11 @@ public class GridImageAsyncClientTest extends RestClientTest<GridImageAsyncClien
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
public SharedKeyLiteAuthentication provideAuthentication(
|
||||
EncryptionService encryptionService) throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,33 +18,32 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.IpType;
|
||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||
import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
|
||||
import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
|
||||
import org.jclouds.gogrid.options.GetIpListOptions;
|
||||
import org.jclouds.gogrid.options.GetJobListOptions;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -58,8 +57,8 @@ public class GridIpAsyncClientTest extends RestClientTest<GridIpAsyncClient> {
|
|||
new GetIpListOptions().onlyUnassigned().onlyWithType(IpType.PUBLIC));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Unassigned&" +
|
||||
"ip.type=Public HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Unassigned&"
|
||||
+ "ip.type=Public HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -71,14 +70,13 @@ public class GridIpAsyncClientTest extends RestClientTest<GridIpAsyncClient> {
|
|||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Unassigned&" +
|
||||
"ip.type=Public&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Unassigned&"
|
||||
+ "ip.type=Public&sig=3f446f171455fbb5574aecff4997b273&api_key=foo "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetAssignedIpList() throws NoSuchMethodException, IOException {
|
||||
Method method = GridIpAsyncClient.class.getMethod("getAssignedIpList");
|
||||
|
@ -97,14 +95,12 @@ public class GridIpAsyncClientTest extends RestClientTest<GridIpAsyncClient> {
|
|||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Assigned&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/ip/list?v=1.3&ip.state=Assigned&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<GridIpAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
|
@ -133,8 +129,9 @@ public class GridIpAsyncClientTest extends RestClientTest<GridIpAsyncClient> {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
@SuppressWarnings("unused")
|
||||
public SharedKeyLiteAuthentication provideAuthentication(
|
||||
EncryptionService encryptionService) throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,11 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
|
@ -36,14 +41,11 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -54,17 +56,14 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class);
|
||||
GeneratedHttpRequest<GridJobAsyncClient> httpRequest = processor.createRequest(method,
|
||||
new GetJobListOptions.Builder().
|
||||
create().
|
||||
withStartDate(new Date(1267385381770L)).
|
||||
withEndDate(new Date(1267385382770L)).
|
||||
onlyForObjectType(ObjectType.VIRTUAL_SERVER).
|
||||
onlyForState(JobState.PROCESSING));
|
||||
new GetJobListOptions.Builder().create().withStartDate(new Date(1267385381770L))
|
||||
.withEndDate(new Date(1267385382770L)).onlyForObjectType(
|
||||
ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&startdate=1267385381770&" +
|
||||
"enddate=1267385382770&job.objecttype=VirtualServer&" +
|
||||
"job.state=Processing HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&startdate=1267385381770&"
|
||||
+ "enddate=1267385382770&job.objecttype=VirtualServer&"
|
||||
+ "job.state=Processing HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -76,10 +75,10 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&startdate=1267385381770&" +
|
||||
"enddate=1267385382770&job.objecttype=VirtualServer&" +
|
||||
"job.state=Processing&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&startdate=1267385381770&"
|
||||
+ "enddate=1267385382770&job.objecttype=VirtualServer&"
|
||||
+ "job.state=Processing&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
@ -101,9 +100,8 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
GeneratedHttpRequest<GridJobAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"MyServer");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&" +
|
||||
"object=MyServer HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.3&"
|
||||
+ "object=MyServer HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -114,25 +112,20 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.3&" +
|
||||
"object=MyServer&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.3&"
|
||||
+ "object=MyServer&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetJobsById() throws NoSuchMethodException, IOException {
|
||||
Method method = GridJobAsyncClient.class.getMethod("getJobsById", Long[].class);
|
||||
GeneratedHttpRequest<GridJobAsyncClient> httpRequest = processor.createRequest(method,
|
||||
123L, 456L);
|
||||
GeneratedHttpRequest<GridJobAsyncClient> httpRequest = processor.createRequest(method, 123L,
|
||||
456L);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/get?v=1.3&" +
|
||||
"id=123&id=456 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.3&"
|
||||
+ "id=123&id=456 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -143,10 +136,8 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/get?v=1.3&" +
|
||||
"id=123&id=456&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.3&"
|
||||
+ "id=123&id=456&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
@ -179,8 +170,9 @@ public class GridJobAsyncClientTest extends RestClientTest<GridJobAsyncClient> {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
@SuppressWarnings("unused")
|
||||
public SharedKeyLiteAuthentication provideAuthentication(
|
||||
EncryptionService encryptionService) throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,11 +18,17 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
|
@ -39,15 +45,11 @@ import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -57,14 +59,16 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
@Test
|
||||
public void testGetLoadBalancerList() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancerList");
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor
|
||||
.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.4 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
|
||||
assertResponseParserClassEquals(method, httpRequest,
|
||||
ParseLoadBalancerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
|
@ -72,30 +76,27 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.4&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.4&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddLoadBalancer() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer",
|
||||
String.class, IpPortPair.class, List.class, AddLoadBalancerOptions[].class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"BalanceIt", new IpPortPair(new Ip("127.0.0.1"), 80),
|
||||
Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
||||
new IpPortPair(new Ip("127.0.0.1"), 9090)),
|
||||
new AddLoadBalancerOptions.Builder().create(LoadBalancerType.LEAST_CONNECTED,
|
||||
LoadBalancerPersistenceType.SSL_STICKY));
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("addLoadBalancer", String.class,
|
||||
IpPortPair.class, List.class, AddLoadBalancerOptions[].class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||
method, "BalanceIt", new IpPortPair(new Ip("127.0.0.1"), 80), Arrays.asList(
|
||||
new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(new Ip(
|
||||
"127.0.0.1"), 9090)), new AddLoadBalancerOptions.Builder().create(
|
||||
LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&" +
|
||||
"loadbalancer.persistence=SSL%20Sticky&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&" +
|
||||
"virtualip.ip=127.0.0.1&virtualip.port=80 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&"
|
||||
+ "loadbalancer.persistence=SSL%20Sticky&realiplist.0.ip=127.0.0.1&"
|
||||
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&"
|
||||
+ "virtualip.ip=127.0.0.1&virtualip.port=80 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -106,30 +107,27 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&" +
|
||||
"loadbalancer.persistence=SSL%20Sticky&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&" +
|
||||
"virtualip.ip=127.0.0.1&virtualip.port=80&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "add?v=1.4&name=BalanceIt&loadbalancer.type=Least%20Connect&"
|
||||
+ "loadbalancer.persistence=SSL%20Sticky&realiplist.0.ip=127.0.0.1&"
|
||||
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&"
|
||||
+ "virtualip.ip=127.0.0.1&virtualip.port=80&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer",
|
||||
String.class, List.class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancer", String.class,
|
||||
List.class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||
method, "BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080),
|
||||
new IpPortPair(new Ip("127.0.0.1"), 9090)));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
||||
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -140,40 +138,37 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" +
|
||||
"realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&"
|
||||
+ "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName", String[].class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"My Load Balancer", "My Load Balancer 2");
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("getLoadBalancersByName",
|
||||
String[].class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||
method, "My Load Balancer", "My Load Balancer 2");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"get?v=1.4&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "get?v=1.4&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
|
||||
assertResponseParserClassEquals(method, httpRequest,
|
||||
ParseLoadBalancerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"get?v=1.4&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "get?v=1.4&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
@ -181,12 +176,11 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
@Test
|
||||
public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException {
|
||||
Method method = GridLoadBalancerAsyncClient.class.getMethod("deleteById", Long.class);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
55L);
|
||||
GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpRequest = processor.createRequest(
|
||||
method, 55L);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"delete?v=1.4&id=55 HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "delete?v=1.4&id=55 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
|
@ -197,16 +191,13 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/loadbalancer/" +
|
||||
"delete?v=1.4&id=55&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
|
||||
+ "delete?v=1.4&id=55&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<GridLoadBalancerAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
|
@ -235,8 +226,9 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest<GridLoadBala
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
@SuppressWarnings("unused")
|
||||
public SharedKeyLiteAuthentication provideAuthentication(
|
||||
EncryptionService encryptionService) throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue