You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/02 16:57:54 UTC
[01/10] Removed async from elasticstack
Updated Branches:
refs/heads/master a9cb3cf06 -> a14c03ba0
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java
deleted file mode 100644
index e7c968a..0000000
--- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackAsyncClientTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elasticstack;
-
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.elasticstack.binders.BindServerToPlainTextStringTest;
-import org.jclouds.elasticstack.domain.CreateDriveRequest;
-import org.jclouds.elasticstack.domain.Drive;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.ImageConversionType;
-import org.jclouds.elasticstack.domain.Server;
-import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
-import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
-import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
-import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
-import org.jclouds.elasticstack.functions.ReturnPayload;
-import org.jclouds.elasticstack.functions.SplitNewlines;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.io.Payload;
-import org.jclouds.io.Payloads;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code ElasticStackAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "ElasticStackAsyncClientTest")
-public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStackAsyncClient> {
- public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "listServers");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "listServerInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "getServerInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateAndStartServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "createAndStartServer", Server.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- BindServerToPlainTextStringTest.SERVER));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "createServer", Server.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- BindServerToPlainTextStringTest.SERVER));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create/stopped HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "setServerConfiguration", String.class, Server.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
- BindServerToPlainTextStringTest.SERVER));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/100/set HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "destroyServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "startServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/start HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "stopServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/stop HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "shutdownServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/shutdown HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "resetServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/reset HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "listDrives");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "listDriveInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "getDriveInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "createDrive", Drive.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- new CreateDriveRequest.Builder().name("foo").size(10000l).build()));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name foo\nsize 10000", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "setDriveData", String.class, DriveData.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
- new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build()));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/set HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name foo\nsize 10000\ntags production candy", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "destroyDrive", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testImageDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "imageDrive", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200"));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testImageDriveWithConversion() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "imageDrive", String.class, String.class,
- ImageConversionType.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200",
- ImageConversionType.GUNZIP));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100/gunzip HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testReadDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "readDrive", String.class, long.class, long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", 1024, 2048));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/read/1024/2048 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: application/octet-stream\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReturnPayload.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- }
-
- public void testWriteDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "writeDrive", String.class, Payload.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
- Payloads.newStringPayload("foo")));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "foo", MediaType.APPLICATION_OCTET_STREAM, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- }
-
- public void testWriteDriveOffset() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ElasticStackAsyncClient.class, "writeDrive", String.class, Payload.class, long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
- Payloads.newStringPayload("foo"), 2048));
-
- assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write/2048 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "foo", MediaType.APPLICATION_OCTET_STREAM, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
- }
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new ElasticStackApiMetadata();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java
deleted file mode 100644
index 1abc72b..0000000
--- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elasticstack;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.elasticstack.domain.ClaimType;
-import org.jclouds.elasticstack.domain.CreateDriveRequest;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.DriveInfo;
-import org.jclouds.elasticstack.domain.DriveStatus;
-import org.jclouds.elasticstack.domain.IDEDevice;
-import org.jclouds.elasticstack.domain.ImageConversionType;
-import org.jclouds.elasticstack.domain.Model;
-import org.jclouds.elasticstack.domain.Server;
-import org.jclouds.elasticstack.domain.ServerInfo;
-import org.jclouds.elasticstack.domain.ServerStatus;
-import org.jclouds.elasticstack.predicates.DriveClaimed;
-import org.jclouds.elasticstack.util.Servers;
-import org.jclouds.io.Payloads;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.ssh.SshClient;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.net.HostAndPort;
-import com.google.gson.Gson;
-import com.google.inject.Guice;
-
-/**
- * Tests behavior of {@code ElasticStackClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticStackClientLiveTest")
-public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTest {
-
- public ElasticStackClientLiveTest() {
- provider = "elasticstack";
- }
-
- protected long driveSize = 1 * 1024 * 1024 * 1024l;
- protected int maxDriveImageTime = 360;
- protected String vncPassword = "Il0veVNC";
- protected ElasticStackClient client;
- protected Predicate<HostAndPort> socketTester;
- protected Predicate<DriveInfo> driveNotClaimed;
- protected String imageId;
-
- @Override
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- imageId = view.getComputeService().templateBuilder().build().getImage().getId();
-
- client = view.utils().injector().getInstance(ElasticStackClient.class);
- driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
- SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
- }
-
- @Test
- public void testListServers() throws Exception {
- Set<String> servers = client.listServers();
- assertNotNull(servers);
- }
-
- @Test
- public void testListServerInfo() throws Exception {
- Set<? extends ServerInfo> servers = client.listServerInfo();
- assertNotNull(servers);
- }
-
- @Test
- public void testGetServer() throws Exception {
- for (String serverUUID : client.listServers()) {
- assert !"".equals(serverUUID);
- assertNotNull(client.getServerInfo(serverUUID));
- }
- }
-
- @Test
- public void testListDrives() throws Exception {
- Set<String> drives = client.listDrives();
- assertNotNull(drives);
- }
-
- @Test
- public void testListDriveInfo() throws Exception {
- Set<? extends DriveInfo> drives = client.listDriveInfo();
- assertNotNull(drives);
- }
-
- @Test
- public void testGetDrive() throws Exception {
- for (String driveUUID : client.listDrives()) {
- assert !"".equals(driveUUID) : driveUUID;
- assert client.getDriveInfo(driveUUID) != null : driveUUID;
- }
- }
-
- protected String prefix = System.getProperty("user.name") + ".test";
- protected DriveInfo drive;
-
- @Test
- public void testCreateDrive() throws Exception {
- drive = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(driveSize).build());
- checkCreatedDrive();
-
- DriveInfo newInfo = client.getDriveInfo(drive.getUuid());
- checkDriveMatchesGet(newInfo);
-
- }
-
- protected void checkDriveMatchesGet(DriveInfo newInfo) {
- assertEquals(newInfo.getUuid(), drive.getUuid());
- }
-
- protected void checkCreatedDrive() {
- assertNotNull(drive.getUuid());
- assertNotNull(drive.getUser());
- assertEquals(drive.getName(), prefix);
- assertEquals(drive.getSize(), driveSize);
- assertEquals(drive.getStatus(), DriveStatus.ACTIVE);
- // for some reason, these occasionally return as 4096,1
- // assertEquals(info.getReadBytes(), 0l);
- // assertEquals(info.getWriteBytes(), 0l);
- // assertEquals(info.getReadRequests(), 0l);
- // assertEquals(info.getWriteRequests(), 0l);
- assertEquals(drive.getEncryptionCipher(), "aes-xts-plain");
- }
-
- @Test(dependsOnMethods = "testCreateDrive")
- public void testSetDriveData() throws Exception {
-
- DriveInfo drive2 = client.setDriveData(drive.getUuid(), new DriveData.Builder().claimType(ClaimType.SHARED).name(
- "rediculous").readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")).tags(
- ImmutableSet.of("networking", "security", "gateway")).userMetadata(ImmutableMap.of("foo", "bar"))
- .build());
-
- assertNotNull(drive2.getUuid(), drive.getUuid());
- assertEquals(drive2.getName(), "rediculous");
- assertEquals(drive2.getClaimType(), ClaimType.SHARED);
- assertEquals(drive2.getReaders(), ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"));
- assertEquals(drive2.getTags(), ImmutableSet.of("networking", "security", "gateway"));
- assertEquals(drive2.getUserMetadata(), ImmutableMap.of("foo", "bar"));
- drive = drive2;
- }
-
- protected ServerInfo server;
-
- @Test(dependsOnMethods = "testSetDriveData")
- public void testCreateAndStartServer() throws Exception {
- Logger.getAnonymousLogger().info("preparing drive");
- prepareDrive();
-
- Server serverRequest = Servers.small(prefix, drive.getUuid(), vncPassword).build();
-
- Logger.getAnonymousLogger().info("starting server");
- server = client.createServer(serverRequest);
- client.startServer(server.getUuid());
- server = client.getServerInfo(server.getUuid());
- checkStartedServer();
-
- Server newInfo = client.getServerInfo(server.getUuid());
- checkServerMatchesGet(newInfo);
-
- }
-
- protected void checkServerMatchesGet(Server newInfo) {
- assertEquals(newInfo.getUuid(), server.getUuid());
- }
-
- protected void checkStartedServer() {
- System.out.println(new Gson().toJson(server));
- assertNotNull(server.getUuid());
- assertNotNull(server.getUser());
- assertEquals(server.getName(), prefix);
- assertEquals(server.isPersistent(), true);
- assertEquals(server.getDevices(), ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid())
- .build()));
- assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0"));
- assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp());
- assertEquals(server.getNics().get(0).getModel(), Model.E1000);
- assertEquals(server.getStatus(), ServerStatus.ACTIVE);
- }
-
- @Test(dependsOnMethods = "testCreateAndStartServer")
- public void testConnectivity() throws Exception {
- HostAndPort vncsocket = HostAndPort.fromParts(server.getVnc().getIp(), 5900);
- Logger.getAnonymousLogger().info("awaiting vnc: " + vncsocket);
- assert socketTester.apply(vncsocket) : server;
- HostAndPort sshsocket = HostAndPort.fromParts(server.getNics().get(0).getDhcp(), 22);
- Logger.getAnonymousLogger().info("awaiting ssh: " + sshsocket);
- assert socketTester.apply(sshsocket) : server;
- doConnectViaSsh(server, getSshCredentials(server));
- }
-
- @Test(dependsOnMethods = "testConnectivity")
- public void testLifeCycle() throws Exception {
- client.stopServer(server.getUuid());
- assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
-
- client.startServer(server.getUuid());
- assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
-
- client.resetServer(server.getUuid());
- assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
-
- client.shutdownServer(server.getUuid());
- // behavior on shutdown depends on how your server OS is set up to respond to an ACPI power
- // button signal
- assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
- server.getUuid()).getStatus() == ServerStatus.STOPPED);
- }
-
- @Test(dependsOnMethods = "testLifeCycle")
- public void testSetServerConfiguration() throws Exception {
- client.stopServer(server.getUuid());
- assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
-
- ServerInfo server2 = client.setServerConfiguration(server.getUuid(), Server.Builder.fromServer(server).name(
- "rediculous").tags(ImmutableSet.of("networking", "security", "gateway")).userMetadata(
- ImmutableMap.of("foo", "bar")).build());
-
- assertNotNull(server2.getUuid(), server.getUuid());
- assertEquals(server2.getName(), "rediculous");
- checkTagsAndMetadata(server2);
- server = server2;
- }
-
- protected void checkTagsAndMetadata(ServerInfo server2) {
- assertEquals(server2.getTags(), ImmutableSet.of("networking", "security", "gateway"));
- assertEquals(server2.getUserMetadata(), ImmutableMap.of("foo", "bar"));
- }
-
- @Test(dependsOnMethods = "testSetServerConfiguration")
- public void testDestroyServer() throws Exception {
- client.destroyServer(server.getUuid());
- assertEquals(client.getServerInfo(server.getUuid()), null);
- }
-
- @Test(dependsOnMethods = "testDestroyServer")
- public void testDestroyDrive() throws Exception {
- client.destroyDrive(drive.getUuid());
- assertEquals(client.getDriveInfo(drive.getUuid()), null);
- }
-
- protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException {
- SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create(
- HostAndPort.fromParts(server.getVnc().getIp(), 22), creds);
- try {
- ssh.connect();
- ExecResponse hello = ssh.exec("echo hello");
- assertEquals(hello.getOutput().trim(), "hello");
- System.err.println(ssh.exec("df -k").getOutput());
- System.err.println(ssh.exec("mount").getOutput());
- System.err.println(ssh.exec("uname -a").getOutput());
- } finally {
- if (ssh != null)
- ssh.disconnect();
- }
- }
-
- @AfterGroups(groups = "live")
- @Override
- protected void tearDownContext() {
- try {
- client.destroyServer(server.getUuid());
- } catch (Exception e) {
- // no need to check null or anything as we swallow all
- }
- try {
- client.destroyDrive(drive.getUuid());
- } catch (Exception e) {
-
- }
- super.tearDownContext();
- }
-
- private DriveInfo drive2;
- private DriveInfo drive3;
-
- public void testWeCanReadAndWriteToDrive() throws IOException {
- drive2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1 * 1024 * 1024l).build());
- client.writeDrive(drive2.getUuid(), Payloads.newStringPayload("foo"));
- assertEquals(Strings2.toString(client.readDrive(drive2.getUuid(), 0, 3)), "foo");
- }
-
- @Test(dependsOnMethods = "testWeCanReadAndWriteToDrive")
- public void testWeCopyADriveContentsViaGzip() throws IOException {
- try {
- drive3 = client
- .createDrive(new CreateDriveRequest.Builder().name(prefix + "3").size(1 * 1024 * 1024l).build());
- System.err.println("before image; drive 2" + client.getDriveInfo(drive2.getUuid()));
- System.err.println("before image; drive 3" + client.getDriveInfo(drive3.getUuid()));
- client.imageDrive(drive2.getUuid(), drive3.getUuid());
- assert driveNotClaimed.apply(drive3) : client.getDriveInfo(drive3.getUuid());
- assert driveNotClaimed.apply(drive2) : client.getDriveInfo(drive2.getUuid());
- System.err.println("after image; drive 2" + client.getDriveInfo(drive2.getUuid()));
- System.err.println("after image; drive 3" + client.getDriveInfo(drive3.getUuid()));
- assertEquals(Strings2.toString(client.readDrive(drive3.getUuid(), 0, 3)), "foo");
- } finally {
- client.destroyDrive(drive2.getUuid());
- client.destroyDrive(drive3.getUuid());
- }
- }
-
- protected LoginCredentials getSshCredentials(Server server) {
- return LoginCredentials.builder().user("toor").password(server.getVnc().getPassword()).build();
- }
-
- protected void prepareDrive() {
- System.err.println("before prepare" + client.getDriveInfo(drive.getUuid()));
- client.imageDrive(imageId, drive.getUuid(), ImageConversionType.GUNZIP);
- assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
- System.err.println("after prepare" + client.getDriveInfo(drive.getUuid()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesApiLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesApiLiveTest.java
new file mode 100644
index 0000000..e899cf6
--- /dev/null
+++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesApiLiveTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elastichosts;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1LosAngelesApiLiveTest")
+public class ElasticHostsPeer1LosAngelesApiLiveTest extends ElasticStackApiLiveTest {
+ public ElasticHostsPeer1LosAngelesApiLiveTest() {
+ provider = "elastichosts-lax-p";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java
deleted file mode 100644
index 21eb2b5..0000000
--- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesClientLiveTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elastichosts;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1LosAngelesClientLiveTest")
-public class ElasticHostsPeer1LosAngelesClientLiveTest extends ElasticStackClientLiveTest {
- public ElasticHostsPeer1LosAngelesClientLiveTest() {
- provider = "elastichosts-lax-p";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonApiLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonApiLiveTest.java
new file mode 100644
index 0000000..f797316
--- /dev/null
+++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elastichosts;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsBlueSquareLondonApiLiveTest")
+public class ElasticHostsBlueSquareLondonApiLiveTest extends ElasticStackApiLiveTest {
+ public ElasticHostsBlueSquareLondonApiLiveTest() {
+ provider = "elastichosts-lon-b";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonClientLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonClientLiveTest.java
deleted file mode 100644
index b26260e..0000000
--- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elastichosts;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsBlueSquareLondonClientLiveTest")
-public class ElasticHostsBlueSquareLondonClientLiveTest extends ElasticStackClientLiveTest {
- public ElasticHostsBlueSquareLondonClientLiveTest() {
- provider = "elastichosts-lon-b";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonApiLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonApiLiveTest.java
new file mode 100644
index 0000000..72b93fc
--- /dev/null
+++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elastichosts;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1LondonApiLiveTest")
+public class ElasticHostsPeer1LondonApiLiveTest extends ElasticStackApiLiveTest {
+ public ElasticHostsPeer1LondonApiLiveTest() {
+ provider = "elastichosts-lon-p";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonClientLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonClientLiveTest.java
deleted file mode 100644
index 16f17b7..0000000
--- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elastichosts;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1LondonClientLiveTest")
-public class ElasticHostsPeer1LondonClientLiveTest extends ElasticStackClientLiveTest {
- public ElasticHostsPeer1LondonClientLiveTest() {
- provider = "elastichosts-lon-p";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioApiLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioApiLiveTest.java
new file mode 100644
index 0000000..9c0d800
--- /dev/null
+++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elastichosts;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1SanAntonioApiLiveTest")
+public class ElasticHostsPeer1SanAntonioApiLiveTest extends ElasticStackApiLiveTest {
+ public ElasticHostsPeer1SanAntonioApiLiveTest() {
+ provider = "elastichosts-sat-p";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioClientLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioClientLiveTest.java
deleted file mode 100644
index 761a73a..0000000
--- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1SanAntonioClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elastichosts;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1SanAntonioClientLiveTest")
-public class ElasticHostsPeer1SanAntonioClientLiveTest extends ElasticStackClientLiveTest {
- public ElasticHostsPeer1SanAntonioClientLiveTest() {
- provider = "elastichosts-sat-p";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoApiLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoApiLiveTest.java
new file mode 100644
index 0000000..a049c5a
--- /dev/null
+++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elastichosts;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1TorontoApiLiveTest")
+public class ElasticHostsPeer1TorontoApiLiveTest extends ElasticStackApiLiveTest {
+ public ElasticHostsPeer1TorontoApiLiveTest() {
+ provider = "elastichosts-tor-p";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoClientLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoClientLiveTest.java
deleted file mode 100644
index e56d22a..0000000
--- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/ElasticHostsPeer1TorontoClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elastichosts;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ElasticHostsPeer1TorontoClientLiveTest")
-public class ElasticHostsPeer1TorontoClientLiveTest extends ElasticStackClientLiveTest {
- public ElasticHostsPeer1TorontoClientLiveTest() {
- provider = "elastichosts-tor-p";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ApiLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ApiLiveTest.java
new file mode 100644
index 0000000..b68522b
--- /dev/null
+++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.go2cloud;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "Go2CloudJohannesburg1ApiLiveTest")
+public class Go2CloudJohannesburg1ApiLiveTest extends ElasticStackApiLiveTest {
+ public Go2CloudJohannesburg1ApiLiveTest() {
+ provider = "go2cloud-jhb1";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ClientLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ClientLiveTest.java
deleted file mode 100644
index d3b449f..0000000
--- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/Go2CloudJohannesburg1ClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.go2cloud;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "Go2CloudJohannesburg1ClientLiveTest")
-public class Go2CloudJohannesburg1ClientLiveTest extends ElasticStackClientLiveTest {
- public Go2CloudJohannesburg1ClientLiveTest() {
- provider = "go2cloud-jhb1";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ApiLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ApiLiveTest.java
new file mode 100644
index 0000000..5230cae
--- /dev/null
+++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.openhosting;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "OpenHostingEast1ApiLiveTest")
+public class OpenHostingEast1ApiLiveTest extends ElasticStackApiLiveTest {
+ public OpenHostingEast1ApiLiveTest() {
+ provider = "openhosting-east1";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ClientLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ClientLiveTest.java
deleted file mode 100644
index d2a8170..0000000
--- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/OpenHostingEast1ClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.openhosting;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "OpenHostingEast1ClientLiveTest")
-public class OpenHostingEast1ClientLiveTest extends ElasticStackClientLiveTest {
- public OpenHostingEast1ClientLiveTest() {
- provider = "openhosting-east1";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java
new file mode 100644
index 0000000..85c993d
--- /dev/null
+++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterApiLiveTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.serverlove;
+
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.jclouds.elasticstack.domain.Server;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ServerloveManchesterApiLiveTest")
+public class ServerloveManchesterApiLiveTest extends ElasticStackApiLiveTest {
+ public ServerloveManchesterApiLiveTest() {
+ provider = "serverlove-z1-man";
+ }
+
+ @Override
+ protected LoginCredentials getSshCredentials(Server server) {
+ return LoginCredentials.builder().user("root").password(server.getVnc().getPassword()).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java
deleted file mode 100644
index 0a5dfa7..0000000
--- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.serverlove;
-
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.jclouds.elasticstack.domain.Server;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "ServerloveManchesterClientLiveTest")
-public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest {
- public ServerloveManchesterClientLiveTest() {
- provider = "serverlove-z1-man";
- }
-
- @Override
- protected LoginCredentials getSshCredentials(Server server) {
- return LoginCredentials.builder().user("root").password(server.getVnc().getPassword()).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaApiLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaApiLiveTest.java
new file mode 100644
index 0000000..4085d7e
--- /dev/null
+++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaApiLiveTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.skalicloud;
+
+import org.jclouds.elasticstack.ElasticStackApiLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "SkaliCloudMalaysiaApiLiveTest")
+public class SkaliCloudMalaysiaApiLiveTest extends ElasticStackApiLiveTest {
+ public SkaliCloudMalaysiaApiLiveTest() {
+ provider = "skalicloud-sdg-my";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaClientLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaClientLiveTest.java
deleted file mode 100644
index 4f3cf32..0000000
--- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/SkaliCloudMalaysiaClientLiveTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.skalicloud;
-
-import org.jclouds.elasticstack.ElasticStackClientLiveTest;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "SkaliCloudMalaysiaClientLiveTest")
-public class SkaliCloudMalaysiaClientLiveTest extends ElasticStackClientLiveTest {
- public SkaliCloudMalaysiaClientLiveTest() {
- provider = "skalicloud-sdg-my";
- }
-}
[03/10] Removed async from cloudsigma
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
deleted file mode 100644
index e1e5867..0000000
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
+++ /dev/null
@@ -1,646 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudsigma;
-
-import static org.jclouds.reflect.Reflection2.method;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
-import org.jclouds.cloudsigma.domain.CreateDriveRequest;
-import org.jclouds.cloudsigma.domain.Drive;
-import org.jclouds.cloudsigma.domain.DriveData;
-import org.jclouds.cloudsigma.domain.Server;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
-import org.jclouds.cloudsigma.functions.SplitNewlines;
-import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
-import org.jclouds.cloudsigma.options.CloneDriveOptions;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code CloudSigmaAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "CloudSigmaAsyncClientTest")
-public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsyncClient> {
-
- public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "getProfileInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToProfileInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listStandardDrives");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listStandardCds");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listStandardImages");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listDriveInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "getDriveInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "createDrive", Drive.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l)
- .build()));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "cloneDrive", String.class, String.class,
- CloneDriveOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name newname", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "cloneDrive", String.class, String.class,
- CloneDriveOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname",
- new CloneDriveOptions().size(1024l)));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name newname\nsize 1024", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "setDriveData", String.class, DriveData.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", new DriveData.Builder().name("foo").size(10000l)
- .use(ImmutableList.of("production", "candy")).build()));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listServers");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listServerInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "getServerInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "createServer", Server.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(BindServerToPlainTextStringTest.SERVER));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "setServerConfiguration", String.class, Server.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", BindServerToPlainTextStringTest.SERVER));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "destroyServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "startServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "stopServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "shutdownServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "resetServer", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listDrives");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "destroyDrive", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listVLANs");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listVLANInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "getVLANInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "createVLAN", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("poohbear"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "renameVLAN", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "poohbear"));
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "destroyVLAN", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listStaticIPs");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // now make sure request filters apply by replaying
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
- // for example, using basic authentication, we should get "only one"
- // header
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- // TODO: insert expected response class, which probably extends ParseJson
- assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
-
- }
-
- public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "listStaticIPInfo");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- }
-
- public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "getStaticIPInfo", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "createStaticIP");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(CloudSigmaAsyncClient.class, "destroyStaticIP", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
-
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
- }
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new CloudSigmaApiMetadata();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
index 210683e..2c4e206 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
@@ -60,7 +60,7 @@ import com.google.gson.Gson;
import com.google.inject.Guice;
/**
- * Tests behavior of {@code CloudSigmaClient}
+ * Tests behavior of {@code CloudSigmaApi}
*
* @author Adrian Cole
*/
@@ -74,7 +74,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
protected long driveSize = 8 * 1024 * 1024 * 1024l;
protected int maxDriveImageTime = 300;
protected String vncPassword = "Il0veVNC";
- protected CloudSigmaClient client;
+ protected CloudSigmaApi client;
protected Predicate<HostAndPort> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
@@ -85,7 +85,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
public void setupContext() {
super.setupContext();
- client = view.utils().injector().getInstance(CloudSigmaClient.class);
+ client = view.utils().injector().getInstance(CloudSigmaApi.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java
index 42b5733..38e4976 100644
--- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java
+++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java
@@ -24,8 +24,7 @@ import static org.testng.Assert.assertTrue;
import java.util.Set;
-import org.jclouds.cloudsigma.CloudSigmaApiMetadata;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions;
import org.jclouds.cloudsigma.domain.AffinityType;
import org.jclouds.cloudsigma.domain.Device;
@@ -62,8 +61,7 @@ public class CloudSigmaZurichComputeServiceLiveTest extends CloudSigmaComputeSer
Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, template);
NodeMetadata node = get(nodes, 0);
- CloudSigmaClient api = CloudSigmaClient.class.cast(client.getContext().unwrap(
- CloudSigmaApiMetadata.CONTEXT_TOKEN).getApi());
+ CloudSigmaApi api = CloudSigmaApi.class.cast(client.getContext());
// Note: I wanted to use node.getHardware().getVolumes() but there is no
// way to go from a Volume to a DriveInfo
[10/10] git commit: Remove async from glesys
Posted by ab...@apache.org.
Remove async from glesys
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/a14c03ba
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/a14c03ba
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/a14c03ba
Branch: refs/heads/master
Commit: a14c03ba0b6be2a0c1cb20374a0efdf1aee3f0a8
Parents: d4bf511
Author: Andrew Bayer <an...@gmail.com>
Authored: Fri Aug 2 07:57:30 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Fri Aug 2 07:57:42 2013 -0700
----------------------------------------------------------------------
.../main/java/org/jclouds/glesys/GleSYSApi.java | 1 -
.../org/jclouds/glesys/GleSYSApiMetadata.java | 23 +-
.../java/org/jclouds/glesys/GleSYSAsyncApi.java | 71 -----
.../compute/GleSYSComputeServiceAdapter.java | 16 +-
.../glesys/config/GleSYSHttpApiModule.java | 65 +++++
.../glesys/config/GleSYSRestClientModule.java | 91 -------
.../org/jclouds/glesys/features/ArchiveApi.java | 64 ++++-
.../glesys/features/ArchiveAsyncApi.java | 121 ---------
.../org/jclouds/glesys/features/DomainApi.java | 78 +++++-
.../jclouds/glesys/features/DomainAsyncApi.java | 146 -----------
.../glesys/features/EmailAccountApi.java | 70 ++++-
.../glesys/features/EmailAccountAsyncApi.java | 135 ----------
.../java/org/jclouds/glesys/features/IpApi.java | 95 ++++++-
.../org/jclouds/glesys/features/IpAsyncApi.java | 162 ------------
.../org/jclouds/glesys/features/ServerApi.java | 173 ++++++++++--
.../jclouds/glesys/features/ServerAsyncApi.java | 262 -------------------
.../java/org/jclouds/glesys/GleSYSApiTest.java | 62 +++++
.../org/jclouds/glesys/GleSYSAsyncApiTest.java | 71 -----
.../glesys/features/ArchiveApiExpectTest.java | 2 +-
.../glesys/features/DomainApiExpectTest.java | 2 +-
.../glesys/features/ServerApiExpectTest.java | 4 +-
21 files changed, 559 insertions(+), 1155 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApi.java
index 096b30b..d0e2c93 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApi.java
@@ -29,7 +29,6 @@ import org.jclouds.rest.annotations.Delegate;
* Provides synchronous access to GleSYS.
* <p/>
*
- * @see GleSYSAsyncApi
* @see <a href="https://customer.glesys.com/api.php" />
* @author Adrian Cole
*/
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java
index 8ffb57a..7259d74 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSApiMetadata.java
@@ -24,11 +24,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.glesys.compute.config.GleSYSComputeServiceContextModule;
-import org.jclouds.glesys.config.GleSYSRestClientModule;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.glesys.config.GleSYSHttpApiModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -36,17 +35,8 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class GleSYSApiMetadata extends BaseRestApiMetadata {
+public class GleSYSApiMetadata extends BaseHttpApiMetadata {
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GleSYSApi.class)} as
- * {@link GleSYSAsyncApi} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<GleSYSApi, GleSYSAsyncApi>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -61,17 +51,16 @@ public class GleSYSApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<GleSYSApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
- super(GleSYSApi.class, GleSYSAsyncApi.class);
id("glesys")
.name("GleSYS API")
.identityName("Username")
@@ -82,7 +71,7 @@ public class GleSYSApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.glesys.com")
.defaultProperties(GleSYSApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(GleSYSComputeServiceContextModule.class, GleSYSRestClientModule.class));
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(GleSYSComputeServiceContextModule.class, GleSYSHttpApiModule.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncApi.java
deleted file mode 100644
index e93f40a..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/GleSYSAsyncApi.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys;
-
-import java.io.Closeable;
-
-import org.jclouds.glesys.features.ArchiveAsyncApi;
-import org.jclouds.glesys.features.DomainAsyncApi;
-import org.jclouds.glesys.features.EmailAccountAsyncApi;
-import org.jclouds.glesys.features.IpAsyncApi;
-import org.jclouds.glesys.features.ServerAsyncApi;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * Provides asynchronous access to GleSYS via their REST API.
- * <p/>
- *
- * @see GleSYSApi
- * @see <a href="https://customer.glesys.com/api.php" />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GleSYSApi.class)} as
- * {@link GleSYSAsyncApi} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public interface GleSYSAsyncApi extends Closeable {
-
- /**
- * Provides asynchronous access to Server features.
- */
- @Delegate
- ServerAsyncApi getServerApi();
-
- /**
- * Provides asynchronous access to Ip Address features.
- */
- @Delegate
- IpAsyncApi getIpApi();
-
- /**
- * Provides asynchronous access to Archive features.
- */
- @Delegate
- ArchiveAsyncApi getArchiveApi();
-
- /**
- * Provides asynchronous access to DNS features.
- */
- @Delegate
- DomainAsyncApi getDomainApi();
-
- /**
- * Provides asynchronous access to E-Mail features.
- */
- @Delegate
- EmailAccountAsyncApi getEmailAccountApi();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java b/providers/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java
index 74669ef..9858595 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/compute/GleSYSComputeServiceAdapter.java
@@ -24,7 +24,6 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static com.google.common.io.BaseEncoding.base16;
import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
-import static org.jclouds.concurrent.FutureIterables.transformParallel;
import static org.jclouds.util.Predicates2.retry;
import java.util.Map;
@@ -53,7 +52,6 @@ import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.glesys.GleSYSApi;
-import org.jclouds.glesys.GleSYSAsyncApi;
import org.jclouds.glesys.compute.options.GleSYSTemplateOptions;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
import org.jclouds.glesys.domain.OSTemplate;
@@ -72,8 +70,6 @@ import com.google.common.base.Supplier;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
/**
@@ -89,17 +85,15 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
protected Logger logger = Logger.NULL;
private final GleSYSApi api;
- private final GleSYSAsyncApi aapi;
private final ListeningExecutorService userExecutor;
private final Timeouts timeouts;
private final Supplier<Set<? extends Location>> locations;
@Inject
- public GleSYSComputeServiceAdapter(GleSYSApi api, GleSYSAsyncApi aapi,
+ public GleSYSComputeServiceAdapter(GleSYSApi api,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, Timeouts timeouts,
@Memoized Supplier<Set<? extends Location>> locations) {
this.api = checkNotNull(api, "api");
- this.aapi = checkNotNull(aapi, "aapi");
this.userExecutor = checkNotNull(userExecutor, "userExecutor");
this.timeouts = checkNotNull(timeouts, "timeouts");
this.locations = checkNotNull(locations, "locations");
@@ -210,11 +204,11 @@ public class GleSYSComputeServiceAdapter implements ComputeServiceAdapter<Server
@Override
public Iterable<ServerDetails> listNodes() {
- return transformParallel(api.getServerApi().list(), new Function<Server, ListenableFuture<? extends ServerDetails>>() {
- public ListenableFuture<ServerDetails> apply(Server from) {
- return aapi.getServerApi().get(from.getId());
+ return api.getServerApi().list().transform(new Function<Server, ServerDetails>() {
+ public ServerDetails apply(Server from) {
+ return api.getServerApi().get(from.getId());
}
- }, userExecutor, null, logger, "server details");
+ });
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSHttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSHttpApiModule.java b/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSHttpApiModule.java
new file mode 100644
index 0000000..9e4764a
--- /dev/null
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSHttpApiModule.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glesys.config;
+
+import org.jclouds.glesys.GleSYSApi;
+import org.jclouds.glesys.handlers.GleSYSErrorHandler;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpRetryHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.HttpApiModule;
+
+import com.google.inject.Scopes;
+
+/**
+ * Configures the GleSYS connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresRestClient
+public class GleSYSHttpApiModule extends HttpApiModule<GleSYSApi> {
+
+ @Override
+ protected void configure() {
+ install(new GleSYSParserModule());
+ super.configure();
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GleSYSErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GleSYSErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GleSYSErrorHandler.class);
+ }
+
+ @Override
+ protected void bindRetryHandlers() {
+ bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
+ }
+
+ @Override
+ protected void installLocations() {
+ super.installLocations();
+ bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java b/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
deleted file mode 100644
index 82f9760..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/config/GleSYSRestClientModule.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.config;
-
-import java.util.Map;
-
-import org.jclouds.glesys.GleSYSApi;
-import org.jclouds.glesys.GleSYSAsyncApi;
-import org.jclouds.glesys.features.ArchiveApi;
-import org.jclouds.glesys.features.ArchiveAsyncApi;
-import org.jclouds.glesys.features.DomainApi;
-import org.jclouds.glesys.features.DomainAsyncApi;
-import org.jclouds.glesys.features.EmailAccountApi;
-import org.jclouds.glesys.features.EmailAccountAsyncApi;
-import org.jclouds.glesys.features.IpApi;
-import org.jclouds.glesys.features.IpAsyncApi;
-import org.jclouds.glesys.features.ServerApi;
-import org.jclouds.glesys.features.ServerAsyncApi;
-import org.jclouds.glesys.handlers.GleSYSErrorHandler;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpRetryHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
-import org.jclouds.location.suppliers.ImplicitLocationSupplier;
-import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Scopes;
-
-/**
- * Configures the GleSYS connection.
- *
- * @author Adrian Cole
- */
-@ConfiguresRestClient
-public class GleSYSRestClientModule extends RestClientModule<GleSYSApi, GleSYSAsyncApi> {
-
- public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
- .put(ServerApi.class, ServerAsyncApi.class)//
- .put(IpApi.class, IpAsyncApi.class)//
- .put(ArchiveApi.class, ArchiveAsyncApi.class)//
- .put(DomainApi.class, DomainAsyncApi.class)//
- .put(EmailAccountApi.class, EmailAccountAsyncApi.class)//
- .build();
-
- public GleSYSRestClientModule() {
- super(DELEGATE_MAP);
- }
-
- @Override
- protected void configure() {
- install(new GleSYSParserModule());
- super.configure();
- }
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(GleSYSErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(GleSYSErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(GleSYSErrorHandler.class);
- }
-
- @Override
- protected void bindRetryHandlers() {
- bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
- }
-
- @Override
- protected void installLocations() {
- super.installLocations();
- bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstZone.class).in(Scopes.SINGLETON);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveApi.java
index e441918..34ce600 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveApi.java
@@ -16,8 +16,21 @@
*/
package org.jclouds.glesys.features;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.Archive;
import org.jclouds.glesys.domain.ArchiveAllowedArguments;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@@ -26,14 +39,20 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
- * @see ArchiveAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
+@RequestFilters(BasicAuthentication.class)
public interface ArchiveApi {
/**
* Lists all active disks on this account.
*/
+ @Named("archive:list")
+ @POST
+ @Path("/archive/list/format/json")
+ @SelectJson("archives")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Archive> list();
/**
@@ -42,24 +61,39 @@ public interface ArchiveApi {
* @param username the username associated with the archive
* @return the archive information or null if not found
*/
- Archive get(String username);
+ @Named("archive:details")
+ @POST
+ @Path("/archive/details/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Archive get(@FormParam("username") String username);
/**
* Create a new backup volume.
*
- * @param username the archive username, this must be prefixed by Glesys account name (in lower case) and an
+ * @param username the archive username, this must be prefixed by Glesys account name (in lower case) and an
* underscore, ex. "c100005_archive1"
* @param password the new password
* @param size the new size required in GB
*/
- Archive createWithCredentialsAndSize(String username, String password, int size);
+ @Named("archive:create")
+ @POST
+ @Path("/archive/create/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Archive createWithCredentialsAndSize(@FormParam("username") String username, @FormParam("password") String password,
+ @FormParam("size")int size);
/**
* Delete an archive volume. All files on the volume
*
* @param username the username associated with the archive
*/
- void delete(String username);
+ @Named("archive:delete")
+ @POST
+ @Path("/archive/delete/format/json")
+ void delete(@FormParam("username") String username);
/**
* Resize an archive volume. It is only possible to upgrade the size of the disk. Downgrading is currently not
@@ -69,7 +103,12 @@ public interface ArchiveApi {
* @param username the username associated with the archive
* @param size the new size required, see #getAllowedArguments for valid values
*/
- Archive resize(String username, int size);
+ @Named("archive:resize")
+ @POST
+ @Path("/archive/resize/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Archive resize(@FormParam("username") String username, @FormParam("size") int size);
/**
* Change the password for an archive user.
@@ -77,11 +116,22 @@ public interface ArchiveApi {
* @param username the archive username
* @param password the new password
*/
- Archive changePassword(String username, String password);
+ @Named("archive:changepassword")
+ @POST
+ @Path("/archive/changepassword/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Archive changePassword(@FormParam("username") String username, @FormParam("password") String password);
/**
* Lists the allowed arguments for some of the functions in this module such as archive size.
*/
+ @Named("archive:allowedarguments")
+ @GET
+ @Path("/archive/allowedarguments/format/json")
+ @SelectJson("argumentslist")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
ArchiveAllowedArguments getAllowedArguments();
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveAsyncApi.java
deleted file mode 100644
index 42fde23..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/ArchiveAsyncApi.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.features;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.glesys.domain.Archive;
-import org.jclouds.glesys.domain.ArchiveAllowedArguments;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to Archive data via the Glesys REST API.
- * <p/>
- *
- * @author Adam Lowe
- * @see ArchiveApi
- * @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
- */
-@RequestFilters(BasicAuthentication.class)
-public interface ArchiveAsyncApi {
-
- /**
- * @see ArchiveApi#list
- */
- @Named("archive:list")
- @POST
- @Path("/archive/list/format/json")
- @SelectJson("archives")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<Archive>> list();
-
- /**
- * @see ArchiveApi#get
- */
- @Named("archive:details")
- @POST
- @Path("/archive/details/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Archive> get(@FormParam("username") String username);
-
- /**
- * @see ArchiveApi#createWithCredentialsAndSize
- */
- @Named("archive:create")
- @POST
- @Path("/archive/create/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Archive> createWithCredentialsAndSize(@FormParam("username") String username, @FormParam("password") String password,
- @FormParam("size")int size);
-
- /**
- * @see ArchiveApi#delete
- */
- @Named("archive:delete")
- @POST
- @Path("/archive/delete/format/json")
- ListenableFuture<Void> delete(@FormParam("username") String username);
-
- /**
- * @see ArchiveApi#resize
- */
- @Named("archive:resize")
- @POST
- @Path("/archive/resize/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Archive> resize(@FormParam("username") String username, @FormParam("size") int size);
- /**
- * @see ArchiveApi#changePassword
- */
- @Named("archive:changepassword")
- @POST
- @Path("/archive/changepassword/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Archive> changePassword(@FormParam("username") String username, @FormParam("password") String password);
-
- /**
- * @see org.jclouds.glesys.features.ArchiveApi#getAllowedArguments
- */
- @Named("archive:allowedarguments")
- @GET
- @Path("/archive/allowedarguments/format/json")
- @SelectJson("argumentslist")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ArchiveAllowedArguments> getAllowedArguments();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainApi.java
index 88598ee..208bf1b 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainApi.java
@@ -17,12 +17,25 @@
package org.jclouds.glesys.features;
import java.util.Set;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.Domain;
import org.jclouds.glesys.domain.DomainRecord;
import org.jclouds.glesys.options.AddDomainOptions;
import org.jclouds.glesys.options.AddRecordOptions;
import org.jclouds.glesys.options.DomainOptions;
import org.jclouds.glesys.options.UpdateRecordOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@@ -31,9 +44,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
- * @see DomainAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
+@RequestFilters(BasicAuthentication.class)
public interface DomainApi {
/**
@@ -41,6 +54,12 @@ public interface DomainApi {
*
* @return an account's associated domain objects.
*/
+ @Named("domain:list")
+ @POST
+ @Path("/domain/list/format/json")
+ @SelectJson("domains")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Domain> list();
/**
@@ -48,16 +67,27 @@ public interface DomainApi {
*
* @return the requested domain object.
*/
- Domain get(String domain);
+ @Named("domain:details")
+ @POST
+ @Path("/domain/details/format/json")
+ @SelectJson("domain")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Domain get(@FormParam("domainname") String name);
/**
* Add a domain to the Glesys dns-system
*
- * @param domain the name of the domain to add.
+ * @param name the name of the domain to add.
* @param options optional parameters
* @return information about the added domain
*/
- Domain create(String domain, AddDomainOptions... options);
+ @Named("domain:add")
+ @POST
+ @Path("/domain/add/format/json")
+ @SelectJson("domain")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Domain create(@FormParam("domainname") String name, AddDomainOptions... options);
/**
* Update a domain to the Glesys dns-system
@@ -66,21 +96,34 @@ public interface DomainApi {
* @param options optional parameters
* @return information about the modified domain
*/
- Domain update(String domain, DomainOptions options);
+ @Named("domain:edit")
+ @POST
+ @Path("/domain/edit/format/json")
+ @SelectJson("domain")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Domain update(@FormParam("domainname") String domain, DomainOptions options);
/**
* Remove a domain to the Glesys dns-system
*
* @param domain the name of the domain to remove
*/
- void delete(String domain);
+ @Named("domain:delete")
+ @POST
+ @Path("/domain/delete/format/json")
+ void delete(@FormParam("domainname") String domain);
/**
* Retrieve the DNS records for a given domain
*
* @param domain the name of the domain to retrieve records for
*/
- Set<DomainRecord> listRecords(String domain);
+ @Named("domain:listrecords")
+ @POST
+ @Path("/domain/listrecords/format/json")
+ @SelectJson("records")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Set<DomainRecord> listRecords(@FormParam("domainname") String domain);
/**
* Add a DNS Record
@@ -88,7 +131,14 @@ public interface DomainApi {
* @param domain the domain to add the record to
* @param options optional settings for the record
*/
- DomainRecord createRecord(String domain, String host, String type, String data, AddRecordOptions... options);
+ @Named("domain:addrecord")
+ @POST
+ @Path("/domain/addrecord/format/json")
+ @SelectJson("record")
+ @Consumes(MediaType.APPLICATION_JSON)
+ DomainRecord createRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
+ @FormParam("type") String type, @FormParam("data") String data,
+ AddRecordOptions... options);
/**
* Modify a specific DNS Record
@@ -97,7 +147,12 @@ public interface DomainApi {
* @param options the settings to change
* @see #listRecords to retrieve the necessary ids
*/
- DomainRecord updateRecord(String recordId, UpdateRecordOptions options);
+ @Named("domain:updaterecord")
+ @POST
+ @Path("/domain/updaterecord/format/json")
+ @SelectJson("record")
+ @Consumes(MediaType.APPLICATION_JSON)
+ DomainRecord updateRecord(@FormParam("recordid") String recordId, UpdateRecordOptions options);
/**
* Delete a DNS record
@@ -105,6 +160,9 @@ public interface DomainApi {
* @param recordId the id for the record to delete
* @see #listRecords to retrieve the necessary ids
*/
- void deleteRecord(String recordId);
+ @Named("domain:deleterecord")
+ @POST
+ @Path("/domain/deleterecord/format/json")
+ void deleteRecord(@FormParam("recordid") String recordId);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncApi.java
deleted file mode 100644
index 16b0a17..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/DomainAsyncApi.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.features;
-
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.glesys.domain.Domain;
-import org.jclouds.glesys.domain.DomainRecord;
-import org.jclouds.glesys.options.AddDomainOptions;
-import org.jclouds.glesys.options.AddRecordOptions;
-import org.jclouds.glesys.options.DomainOptions;
-import org.jclouds.glesys.options.UpdateRecordOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to Domain (DNS) data via the Glesys REST API.
- * <p/>
- *
- * @author Adam Lowe
- * @see DomainApi
- * @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
- */
-@RequestFilters(BasicAuthentication.class)
-public interface DomainAsyncApi {
-
- /**
- * @see org.jclouds.glesys.features.DomainApi#list
- */
- @Named("domain:list")
- @POST
- @Path("/domain/list/format/json")
- @SelectJson("domains")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<Domain>> list();
-
- /**
- * @see org.jclouds.glesys.features.DomainApi#get
- */
- @Named("domain:details")
- @POST
- @Path("/domain/details/format/json")
- @SelectJson("domain")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Domain> get(@FormParam("domainname") String name);
-
- /**
- * @see DomainApi#create
- */
- @Named("domain:add")
- @POST
- @Path("/domain/add/format/json")
- @SelectJson("domain")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Domain> create(@FormParam("domainname") String name, AddDomainOptions... options);
-
- /**
- * @see DomainApi#update
- */
- @Named("domain:edit")
- @POST
- @Path("/domain/edit/format/json")
- @SelectJson("domain")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Domain> update(@FormParam("domainname") String domain, DomainOptions options);
-
-
- /**
- * @see DomainApi#delete
- */
- @Named("domain:delete")
- @POST
- @Path("/domain/delete/format/json")
- ListenableFuture<Void> delete(@FormParam("domainname") String domain);
-
- /**
- * @see DomainApi#listRecords
- */
- @Named("domain:listrecords")
- @POST
- @Path("/domain/listrecords/format/json")
- @SelectJson("records")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Set<DomainRecord>> listRecords(@FormParam("domainname") String domain);
-
- /**
- * @see DomainApi#createRecord
- */
- @Named("domain:addrecord")
- @POST
- @Path("/domain/addrecord/format/json")
- @SelectJson("record")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<DomainRecord> createRecord(@FormParam("domainname") String domain, @FormParam("host") String host,
- @FormParam("type") String type, @FormParam("data") String data,
- AddRecordOptions... options);
-
- /**
- * @see DomainApi#updateRecord
- */
- @Named("domain:updaterecord")
- @POST
- @Path("/domain/updaterecord/format/json")
- @SelectJson("record")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<DomainRecord> updateRecord(@FormParam("recordid") String record_id, UpdateRecordOptions options);
-
- /**
- * @see DomainApi#deleteRecord
- */
- @Named("domain:deleterecord")
- @POST
- @Path("/domain/deleterecord/format/json")
- ListenableFuture<Void> deleteRecord(@FormParam("recordid") String recordId);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountApi.java
index b6d0470..de28af3 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountApi.java
@@ -16,11 +16,23 @@
*/
package org.jclouds.glesys.features;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.EmailAccount;
import org.jclouds.glesys.domain.EmailAlias;
import org.jclouds.glesys.domain.EmailOverview;
import org.jclouds.glesys.options.CreateAccountOptions;
import org.jclouds.glesys.options.UpdateAccountOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@@ -29,9 +41,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adam Lowe
- * @see org.jclouds.glesys.features.EmailAccountAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
+@RequestFilters(BasicAuthentication.class)
public interface EmailAccountApi {
/**
@@ -39,6 +51,12 @@ public interface EmailAccountApi {
*
* @return the relevant summary data
*/
+ @Named("email:overview")
+ @POST
+ @Path("/email/overview/format/json")
+ @SelectJson("overview")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
EmailOverview getOverview();
/**
@@ -46,14 +64,26 @@ public interface EmailAccountApi {
*
* @return the relevant set of details
*/
- FluentIterable<EmailAccount> listDomain(String domain);
+ @Named("email:list:accounts")
+ @POST
+ @Path("/email/list/format/json")
+ @SelectJson("emailaccounts")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
+ FluentIterable<EmailAccount> listDomain(@FormParam("domainname") String domain);
/**
* Get the set of details about e-mail aliases
*
* @return the relevant set of details
*/
- FluentIterable<EmailAlias> listAliasesInDomain(String domain);
+ @Named("email:list:aliases")
+ @POST
+ @Path("/email/list/format/json")
+ @SelectJson("emailaliases")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
+ FluentIterable<EmailAlias> listAliasesInDomain(@FormParam("domainname") String domain);
/**
* Create a new e-mail account
@@ -63,7 +93,12 @@ public interface EmailAccountApi {
* @param options optional parameters
* @see DomainApi#create
*/
- EmailAccount createWithPassword(String accountAddress, String password, CreateAccountOptions... options);
+ @Named("email:createaccount")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("emailaccount")
+ @Path("/email/createaccount/format/json")
+ EmailAccount createWithPassword(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options);
/**
* Create an e-mail alias for an e-mail account
@@ -72,7 +107,12 @@ public interface EmailAccountApi {
* @param toEmailAddress the existing e-mail account address the alias should forward to
* @see DomainApi#create
*/
- EmailAlias createAlias(String aliasAddress, String toEmailAddress);
+ @Named("email:createalias")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("alias")
+ @Path("/email/createalias/format/json")
+ EmailAlias createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* Adjust an e-mail account's settings
@@ -80,7 +120,12 @@ public interface EmailAccountApi {
* @param accountAddress the existing e-mail account address
* @param options optional parameters
*/
- EmailAccount update(String accountAddress, UpdateAccountOptions... options);
+ @Named("email:editaccount")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("emailaccount")
+ @Path("/email/editaccount/format/json")
+ EmailAccount update(@FormParam("emailaccount") String accountAddress, UpdateAccountOptions... options);
/**
* Adjust (re-target) an e-mail alias
@@ -88,13 +133,22 @@ public interface EmailAccountApi {
* @param aliasAddress the existing alias e-mail address
* @param toEmailAddress the existing e-mail account address the alias should forward to
*/
- EmailAlias updateAlias(String aliasAddress, String toEmailAddress);
+ @Named("email:editalias")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("alias")
+ @Path("/email/editalias/format/json")
+ EmailAlias updateAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
/**
* Delete an e-mail account or alias
*
* @param accountAddress the existing alias e-mail account or alias address
*/
- boolean delete(String accountAddress);
+ @Named("email:delete")
+ @POST
+ @Path("/email/delete/format/json")
+ @Fallback(Fallbacks.TrueOnNotFoundOr404.class)
+ boolean delete(@FormParam("email") String accountAddress);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountAsyncApi.java
deleted file mode 100644
index 578e727..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/EmailAccountAsyncApi.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.features;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.TrueOnNotFoundOr404;
-import org.jclouds.glesys.domain.EmailAccount;
-import org.jclouds.glesys.domain.EmailAlias;
-import org.jclouds.glesys.domain.EmailOverview;
-import org.jclouds.glesys.options.CreateAccountOptions;
-import org.jclouds.glesys.options.UpdateAccountOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to E-Mail data via the Glesys REST API.
- * <p/>
- *
- * @author Adam Lowe
- * @see org.jclouds.glesys.features.EmailAccountApi
- * @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
- */
-@RequestFilters(BasicAuthentication.class)
-public interface EmailAccountAsyncApi {
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#getOverview
- */
- @Named("email:overview")
- @POST
- @Path("/email/overview/format/json")
- @SelectJson("overview")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<EmailOverview> getOverview();
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#listDomain
- */
- @Named("email:list:accounts")
- @POST
- @Path("/email/list/format/json")
- @SelectJson("emailaccounts")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<EmailAccount>> listDomain(@FormParam("domainname") String domain);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#listAliasesInDomain
- */
- @Named("email:list:aliases")
- @POST
- @Path("/email/list/format/json")
- @SelectJson("emailaliases")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<EmailAlias>> listAliasesInDomain(@FormParam("domainname") String domain);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#createWithPassword
- */
- @Named("email:createaccount")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("emailaccount")
- @Path("/email/createaccount/format/json")
- ListenableFuture<EmailAccount> createWithPassword(@FormParam("emailaccount") String accountAddress, @FormParam("password") String password, CreateAccountOptions... options);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#createAlias
- */
- @Named("email:createalias")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("alias")
- @Path("/email/createalias/format/json")
- ListenableFuture<EmailAlias> createAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#update
- */
- @Named("email:editaccount")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("emailaccount")
- @Path("/email/editaccount/format/json")
- ListenableFuture<EmailAccount> update(@FormParam("emailaccount") String accountAddress, UpdateAccountOptions... options);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#updateAlias
- */
- @Named("email:editalias")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("alias")
- @Path("/email/editalias/format/json")
- ListenableFuture<EmailAlias> updateAlias(@FormParam("emailalias") String aliasAddress, @FormParam("goto") String toEmailAddress);
-
- /**
- * @see org.jclouds.glesys.features.EmailAccountApi#delete
- */
- @Named("email:delete")
- @POST
- @Path("/email/delete/format/json")
- @Fallback(TrueOnNotFoundOr404.class)
- ListenableFuture<Boolean> delete(@FormParam("email") String accountAddress);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/IpApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/IpApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/IpApi.java
index 7f2a955..062d93c 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/IpApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/features/IpApi.java
@@ -16,8 +16,23 @@
*/
package org.jclouds.glesys.features;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.IpDetails;
import org.jclouds.glesys.options.ListIpOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
import com.google.common.collect.FluentIterable;
@@ -26,9 +41,9 @@ import com.google.common.collect.FluentIterable;
* <p/>
*
* @author Adrian Cole, Mattias Holmqvist, Adam Lowe
- * @see IpAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
+@RequestFilters(BasicAuthentication.class)
public interface IpApi {
/**
* Get a set of all IP addresses that are available and not used on any account or server.
@@ -38,7 +53,15 @@ public interface IpApi {
* @param platform the platform
* @return a set of free IP addresses
*/
- FluentIterable<String> listFree(int ipVersion, String datacenter, String platform);
+ @Named("ip:listfree")
+ @GET
+ @Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("ipaddresses")
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
+ FluentIterable<String> listFree(@PathParam("ipversion") int ipVersion,
+ @PathParam("datacenter") String datacenter,
+ @PathParam("platform") String platform);
/**
* Take a free IP address and add it to this account. You can list free IP addresses with the function listFree().
@@ -46,7 +69,12 @@ public interface IpApi {
*
* @param ipAddress the IP address to be add to this account (reserve)
*/
- IpDetails take(String ipAddress);
+ @Named("ip:take")
+ @POST
+ @Path("/ip/take/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails take(@FormParam("ipaddress") String ipAddress);
/**
* Return an unused IP address to the pool of free ips. If the IP address is allocated to a server,
@@ -54,7 +82,12 @@ public interface IpApi {
*
* @param ipAddress the IP address to be released
*/
- IpDetails release(String ipAddress);
+ @Named("ip:release")
+ @POST
+ @Path("/ip/release/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails release(@FormParam("ipaddress") String ipAddress);
/**
* Get IP addresses associated with your account (reserved, assigned to servers, etc)
@@ -62,6 +95,12 @@ public interface IpApi {
* @param options options to filter the results (by IPV4/6, serverId, etc)
* @return the set of IP addresses
*/
+ @Named("ip:listown")
+ @GET
+ @Path("/ip/listown/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @SelectJson("iplist")
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<IpDetails> list(ListIpOptions... options);
/**
@@ -71,7 +110,13 @@ public interface IpApi {
* @param ipAddress the ip address
* @return details about the given IP address
*/
- IpDetails get(String ipAddress);
+ @Named("ip:details")
+ @GET
+ @Path("/ip/details/ipaddress/{ipaddress}/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ IpDetails get(@PathParam("ipaddress") String ipAddress);
/**
* Add an IP address to an server. The IP has to be free, but reserved to this account. You are able to list such addresses
@@ -82,7 +127,13 @@ public interface IpApi {
* @param ipAddress the IP address to remove
* @param serverId the server to add the IP address to
*/
- IpDetails addToServer(String ipAddress, String serverId);
+ @Named("ip:add")
+ @POST
+ @Path("/ip/add/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails addToServer(@FormParam("ipaddress") String ipAddress,
+ @FormParam("serverid") String serverId);
/**
* Remove an IP address from a server. This does not release it back to GleSYS pool of free ips. The address will be
@@ -93,7 +144,13 @@ public interface IpApi {
* @param serverId the server to remove the IP address from
* @see #removeFromServerAndRelease
*/
- IpDetails removeFromServer(String ipAddress, String serverId);
+ @Named("ip:remove")
+ @POST
+ @Path("/ip/remove/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails removeFromServer(@FormParam("ipaddress") String ipAddress,
+ @FormParam("serverid") String serverId);
/**
* Remove an IP address from a server and release it back to GleSYS pool of free ips.
@@ -102,16 +159,34 @@ public interface IpApi {
* @param serverId the server to remove the IP address from
* @see #removeFromServer
*/
- IpDetails removeFromServerAndRelease(String ipAddress, String serverId);
+ @Named("ip:remove:release")
+ @POST
+ @FormParams(keys = "release", values = "true")
+ @Path("/ip/remove/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
+ @FormParam("serverid") String serverId);
/**
* Sets PTR data for an IP. Use ip/listown or ip/details to get current PTR data
*/
- IpDetails setPtr(String ipAddress, String ptr);
+ @Named("ip:setptr")
+ @POST
+ @Path("/ip/setptr/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails setPtr(@FormParam("ipaddress") String ipAddress,
+ @FormParam("data") String ptr);
/**
* Resets PTR data for an IP back to the default value
*/
- IpDetails resetPtr(String ipAddress);
+ @Named("ip:resetptr")
+ @POST
+ @Path("/ip/resetptr/format/json")
+ @SelectJson("details")
+ @Consumes(MediaType.APPLICATION_JSON)
+ IpDetails resetPtr(@FormParam("ipaddress") String ipAddress);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/IpAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/IpAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/IpAsyncApi.java
deleted file mode 100644
index 42e033b..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/IpAsyncApi.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.features;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.glesys.domain.IpDetails;
-import org.jclouds.glesys.options.ListIpOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.FormParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to IP Addresses via their REST API.
- * <p/>
- *
- * @author Adrian Cole, Mattias Holmqvist, Adam Lowe
- * @see IpApi
- * @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
- */
-@RequestFilters(BasicAuthentication.class)
-public interface IpAsyncApi {
- /**
- * @see IpApi#listFree
- */
- @Named("ip:listfree")
- @GET
- @Path("/ip/listfree/ipversion/{ipversion}/datacenter/{datacenter}/platform/{platform}/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("ipaddresses")
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<String>> listFree(@PathParam("ipversion") int ipversion,
- @PathParam("datacenter") String datacenter,
- @PathParam("platform") String platform);
-
- /**
- * @see IpApi#take
- */
- @Named("ip:take")
- @POST
- @Path("/ip/take/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> take(@FormParam("ipaddress") String ipAddress);
-
- /**
- * @see IpApi#release
- */
- @Named("ip:release")
- @POST
- @Path("/ip/release/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> release(@FormParam("ipaddress") String ipAddress);
-
- /**
- * @see IpApi#list
- */
- @Named("ip:listown")
- @GET
- @Path("/ip/listown/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- @SelectJson("iplist")
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<IpDetails>> list(ListIpOptions... options);
-
- /**
- * @see IpApi#get
- */
- @Named("ip:details")
- @GET
- @Path("/ip/details/ipaddress/{ipaddress}/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<IpDetails> get(@PathParam("ipaddress") String ipAddress);
-
- /**
- * @see IpApi#addToServer
- */
- @Named("ip:add")
- @POST
- @Path("/ip/add/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> addToServer(@FormParam("ipaddress") String ipAddress,
- @FormParam("serverid") String serverId);
-
- /**
- * @see IpApi#removeFromServer
- */
- @Named("ip:remove")
- @POST
- @Path("/ip/remove/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> removeFromServer(@FormParam("ipaddress") String ipAddress,
- @FormParam("serverid") String serverId);
-
- /**
- * @see IpApi#removeFromServer
- */
- @Named("ip:remove:release")
- @POST
- @FormParams(keys = "release", values = "true")
- @Path("/ip/remove/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> removeFromServerAndRelease(@FormParam("ipaddress") String ipAddress,
- @FormParam("serverid") String serverId);
-
- /**
- * @see IpApi#setPtr
- */
- @Named("ip:setptr")
- @POST
- @Path("/ip/setptr/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> setPtr(@FormParam("ipaddress") String ipAddress,
- @FormParam("data") String ptr);
-
- /**
- * @see IpApi#resetPtr
- */
- @Named("ip:resetptr")
- @POST
- @Path("/ip/resetptr/format/json")
- @SelectJson("details")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<IpDetails> resetPtr(@FormParam("ipaddress") String ipAddress);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerApi.java
index 0508c6f..0c42394 100644
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerApi.java
+++ b/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerApi.java
@@ -17,6 +17,17 @@
package org.jclouds.glesys.features;
import java.util.Map;
+import java.util.SortedMap;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks;
import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
import org.jclouds.glesys.domain.Console;
import org.jclouds.glesys.domain.OSTemplate;
@@ -26,13 +37,21 @@ import org.jclouds.glesys.domain.ServerDetails;
import org.jclouds.glesys.domain.ServerLimit;
import org.jclouds.glesys.domain.ServerSpec;
import org.jclouds.glesys.domain.ServerStatus;
+import org.jclouds.glesys.functions.ParseTemplatesFromHttpResponse;
import org.jclouds.glesys.options.CloneServerOptions;
import org.jclouds.glesys.options.CreateServerOptions;
import org.jclouds.glesys.options.DestroyServerOptions;
-import org.jclouds.glesys.options.UpdateServerOptions;
import org.jclouds.glesys.options.ServerStatusOptions;
+import org.jclouds.glesys.options.UpdateServerOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.FormParams;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
-import com.google.common.annotations.Beta;
import com.google.common.collect.FluentIterable;
/**
@@ -41,9 +60,9 @@ import com.google.common.collect.FluentIterable;
*
* @author Adrian Cole
* @author Adam Lowe
- * @see ServerAsyncApi
* @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
*/
+@RequestFilters(BasicAuthentication.class)
public interface ServerApi {
/**
@@ -51,6 +70,12 @@ public interface ServerApi {
*
* @return an account's associated server objects.
*/
+ @Named("server:list")
+ @POST
+ @Path("/server/list/format/json")
+ @SelectJson("servers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
FluentIterable<Server> list();
/**
@@ -61,7 +86,14 @@ public interface ServerApi {
* @param id id of the server
* @return server or null if not found
*/
- ServerDetails get(String id);
+ @Named("server:details")
+ @POST
+ @Path("/server/details/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @FormParams(keys = "includestate", values = "true")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ServerDetails get(@FormParam("serverid") String id);
/**
* Get detailed information about a server status including up-time and
@@ -71,7 +103,13 @@ public interface ServerApi {
* @param options optional parameters
* @return the status of the server or null if not found
*/
- ServerStatus getStatus(String id, ServerStatusOptions... options);
+ @Named("server:status")
+ @POST
+ @Path("/server/status/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ServerStatus getStatus(@FormParam("serverid") String id, ServerStatusOptions... options);
/**
* Get detailed information about a server's limits (for OpenVZ only).
@@ -80,7 +118,13 @@ public interface ServerApi {
* @param id id of the server
* @return the requested information about the server or null if not found
*/
- Map<String, ServerLimit> getLimits(String id);
+ @Named("server:limits")
+ @POST
+ @Path("/server/limits/format/json")
+ @SelectJson("limits")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ SortedMap<String, ServerLimit> getLimits(@FormParam("serverid") String id);
/**
* Get information about how to connect to a server via VNC
@@ -88,21 +132,38 @@ public interface ServerApi {
* @param id id of the server
* @return the requested information about the server or null if not found
*/
- Console getConsole(String id);
+ @Named("server:console")
+ @POST
+ @Path("/server/console/format/json")
+ @SelectJson("console")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Console getConsole(@FormParam("serverid") String id);
/**
* Get information about the OS templates available
*
* @return the set of information about each template
*/
- FluentIterable<OSTemplate> listTemplates();
+ @Named("server:allowedarguments")
+ @GET
+ @Path("/server/allowedarguments/format/json")
+ @SelectJson("argumentslist")
+ @Consumes(MediaType.APPLICATION_JSON)
+ Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateByPlatform();
/**
* Get information about valid arguments to #createServer for each platform
*
* @return a map of argument lists, keyed on platform
*/
- Map<String, AllowedArgumentsForCreateServer> getAllowedArgumentsForCreateByPlatform();
+ @Named("server:templates")
+ @GET
+ @Path("/server/templates/format/json")
+ @ResponseParser(ParseTemplatesFromHttpResponse.class)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ FluentIterable<OSTemplate> listTemplates();
/**
* Reset the fail count for a server limit (for OpenVZ only).
@@ -110,35 +171,61 @@ public interface ServerApi {
* @param id id of the server
* @param type the type of limit to reset
*/
- Map<String, ServerLimit> resetLimit(String id, String type);
+ @Named("server:resetlimit")
+ @POST
+ @Path("/server/resetlimit/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ SortedMap<String, ServerLimit> resetLimit(@FormParam("serverid") String id,
+ @FormParam("type") String type);
/**
* Reboot a server
*
* @param id id of the server
*/
- ServerDetails reboot(String id);
+ @Named("server:reboot")
+ @POST
+ @SelectJson("server")
+ @Path("/server/reboot/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails reboot(@FormParam("serverid") String id);
/**
* Start a server
*
* @param id id of the server
*/
- ServerDetails start(String id);
+ @Named("server:start")
+ @POST
+ @SelectJson("server")
+ @Path("/server/start/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails start(@FormParam("serverid") String id);
/**
* Stop a server
*
* @param id id of the server
*/
- ServerDetails stop(String id);
+ @Named("server:stop")
+ @POST
+ @SelectJson("server")
+ @Path("/server/stop/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails stop(@FormParam("serverid") String id);
/**
* hard stop a server
*
* @param id id of the server
*/
- ServerDetails hardStop(String id);
+ @Named("server:stop:hard")
+ @POST
+ @SelectJson("server")
+ @Path("/server/stop/format/json")
+ @FormParams(keys = "type", values = "hard")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails hardStop(@FormParam("serverid") String id);
/**
* Create a new server
@@ -147,25 +234,43 @@ public interface ServerApi {
* @param rootPassword the root password to use
* @param options optional settings ex. description
*/
- ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec, String hostname, String rootPassword,
- CreateServerOptions... options);
+ @Named("server:create")
+ @POST
+ @SelectJson("server")
+ @Path("/server/create/format/json")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @MapBinder(CreateServerOptions.class)
+ ServerDetails createWithHostnameAndRootPassword(ServerSpec serverSpec,
+ @PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
+ CreateServerOptions... options);
/**
- * Update the configuration of a server
+ * Clone a server
*
- * @param serverid the serverId of the server to edit
+ * @param serverid the serverId of the server to clone
+ * @param hostname the new host name of the cloned server
* @param options the settings to change
*/
- ServerDetails update(String serverid, UpdateServerOptions options);
+ @Named("server:clone")
+ @POST
+ @Path("/server/clone/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails clone(@FormParam("serverid") String serverid,
+ @FormParam("hostname") String hostname, CloneServerOptions... options);
/**
- * Clone a server
+ * Update the configuration of a server
*
- * @param serverid the serverId of the server to clone
- * @param hostname the new host name of the cloned server
+ * @param serverid the serverId of the server to edit
* @param options the settings to change
*/
- ServerDetails clone(String serverid, String hostname, CloneServerOptions... options);
+ @Named("server:edit")
+ @POST
+ @Path("/server/edit/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails update(@FormParam("serverid") String serverid, UpdateServerOptions options);
/**
* Destroy a server
@@ -173,7 +278,10 @@ public interface ServerApi {
* @param id the id of the server
* @param keepIp if DestroyServerOptions.keepIp(true) the servers ip will be retained for use in your GleSYS account
*/
- ServerDetails destroy(String id, DestroyServerOptions keepIp);
+ @Named("server:destroy")
+ @POST
+ @Path("/server/destroy/format/json")
+ void destroy(@FormParam("serverid") String id, DestroyServerOptions keepIp);
/**
* Reset the root password of a server
@@ -181,7 +289,12 @@ public interface ServerApi {
* @param id the id of the server
* @param password the new password to use
*/
- ServerDetails resetPassword(String id, String password);
+ @Named("server:resetpassword")
+ @POST
+ @Path("/server/resetpassword/format/json")
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ServerDetails resetPassword(@FormParam("serverid") String id, @FormParam("rootpassword") String password);
/**
* Return resource usage over time for server
@@ -190,8 +303,12 @@ public interface ServerApi {
* @param resource the name of the resource to retrieve usage information for (e.g. "cpuusage")
* @param resolution the time-period to extract data for (one of "minute", "hour" or "day)
*/
- @Beta
- // TODO: better name
- ResourceUsage getResourceUsage(String id, String resource, String resolution);
+ @Named("server:resourceusage")
+ @POST
+ @Path("/server/resourceusage/format/json")
+ @SelectJson("usage")
+ @Consumes(MediaType.APPLICATION_JSON)
+ ResourceUsage getResourceUsage(@FormParam("serverid") String id, @FormParam("resource") String resource,
+ @FormParam("resolution") String resolution);
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncApi.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncApi.java b/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncApi.java
deleted file mode 100644
index 339e1fa..0000000
--- a/providers/glesys/src/main/java/org/jclouds/glesys/features/ServerAsyncApi.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys.features;
-
-import java.util.Map;
-import java.util.SortedMap;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.glesys.domain.AllowedArgumentsForCreateServer;
-import org.jclouds.glesys.domain.Console;
-import org.jclouds.glesys.domain.OSTemplate;
-import org.jclouds.glesys.domain.ResourceUsage;
-import org.jclouds.glesys.domain.Server;
-import org.jclouds.glesys.domain.ServerDetails;
-import org.jclouds.glesys.domain.ServerLimit;
-import org.jclouds.glesys.domain.ServerSpec;
-import org.jclouds.glesys.domain.ServerStatus;
-import org.jclouds.glesys.functions.ParseTemplatesFromHttpResponse;
-import org.jclouds.glesys.options.CloneServerOptions;
-import org.jclouds.glesys.options.CreateServerOptions;
-import org.jclouds.glesys.options.DestroyServerOptions;
-import org.jclouds.glesys.options.ServerStatusOptions;
-import org.jclouds.glesys.options.UpdateServerOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.FormParams;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.collect.FluentIterable;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to Server via their REST API.
- * <p/>
- *
- * @author Adrian Cole
- * @author Adam Lowe
- * @see ServerApi
- * @see <a href="https://github.com/GleSYS/API/wiki/API-Documentation" />
- */
-@RequestFilters(BasicAuthentication.class)
-public interface ServerAsyncApi {
-
- /**
- * @see ServerApi#list
- */
- @Named("server:list")
- @POST
- @Path("/server/list/format/json")
- @SelectJson("servers")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- ListenableFuture<FluentIterable<Server>> list();
-
- /**
- * @see ServerApi#get
- */
- @Named("server:details")
- @POST
- @Path("/server/details/format/json")
- @SelectJson("server")
- @Consumes(MediaType.APPLICATION_JSON)
- @FormParams(keys = "includestate", values = "true")
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ServerDetails> get(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#getStatus
- */
- @Named("server:status")
- @POST
- @Path("/server/status/format/json")
- @SelectJson("server")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ServerStatus> getStatus(@FormParam("serverid") String id, ServerStatusOptions... options);
-
- /**
- * @see ServerApi#getLimits
- */
- @Named("server:limits")
- @POST
- @Path("/server/limits/format/json")
- @SelectJson("limits")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<SortedMap<String, ServerLimit>> getLimits(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#getConsole
- */
- @Named("server:console")
- @POST
- @Path("/server/console/format/json")
- @SelectJson("console")
- @Consumes(MediaType.APPLICATION_JSON)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Console> getConsole(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#getAllowedArgumentsForCreateByPlatform
- */
- @Named("server:allowedarguments")
- @GET
- @Path("/server/allowedarguments/format/json")
- @SelectJson("argumentslist")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<Map<String, AllowedArgumentsForCreateServer>> getAllowedArgumentsForCreateByPlatform();
-
- /**
- * @see ServerApi#listTemplates
- */
- @Named("server:templates")
- @GET
- @Path("/server/templates/format/json")
- @ResponseParser(ParseTemplatesFromHttpResponse.class)
- @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<FluentIterable<OSTemplate>> listTemplates();
-
- /**
- * @see ServerApi#stop
- */
- @Named("server:resetlimit")
- @POST
- @Path("/server/resetlimit/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<SortedMap<String, ServerLimit>> resetLimit(@FormParam("serverid") String id,
- @FormParam("type") String type);
-
- /**
- * @see ServerApi#reboot
- */
- @Named("server:reboot")
- @POST
- @SelectJson("server")
- @Path("/server/reboot/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> reboot(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#start
- */
- @Named("server:start")
- @POST
- @SelectJson("server")
- @Path("/server/start/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> start(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#stop
- */
- @Named("server:stop")
- @POST
- @SelectJson("server")
- @Path("/server/stop/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> stop(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#hardStop
- */
- @Named("server:stop:hard")
- @POST
- @SelectJson("server")
- @Path("/server/stop/format/json")
- @FormParams(keys = "type", values = "hard")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> hardStop(@FormParam("serverid") String id);
-
- /**
- * @see ServerApi#createWithHostnameAndRootPassword
- */
- @Named("server:create")
- @POST
- @SelectJson("server")
- @Path("/server/create/format/json")
- @Consumes(MediaType.APPLICATION_JSON)
- @MapBinder(CreateServerOptions.class)
- ListenableFuture<ServerDetails> createWithHostnameAndRootPassword(ServerSpec serverSpec,
- @PayloadParam("hostname") String hostname, @PayloadParam("rootpassword") String rootPassword,
- CreateServerOptions... options);
-
- /**
- * @see ServerApi#clone
- */
- @Named("server:clone")
- @POST
- @Path("/server/clone/format/json")
- @SelectJson("server")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> clone(@FormParam("serverid") String serverid,
- @FormParam("hostname") String hostname, CloneServerOptions... options);
-
- /**
- * @see ServerApi#update
- */
- @Named("server:edit")
- @POST
- @Path("/server/edit/format/json")
- @SelectJson("server")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> update(@FormParam("serverid") String serverid, UpdateServerOptions options);
-
- /**
- * @see ServerApi#destroy
- */
- @Named("server:destroy")
- @POST
- @Path("/server/destroy/format/json")
- ListenableFuture<Void> destroy(@FormParam("serverid") String id, DestroyServerOptions keepIp);
-
- /**
- * @see ServerApi#resetPassword
- */
- @Named("server:resetpassword")
- @POST
- @Path("/server/resetpassword/format/json")
- @SelectJson("server")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ServerDetails> resetPassword(@FormParam("serverid") String id, @FormParam("rootpassword") String password);
-
- /**
- * @see ServerApi#getResourceUsage
- */
- @Named("server:resourceusage")
- @POST
- @Path("/server/resourceusage/format/json")
- @SelectJson("usage")
- @Consumes(MediaType.APPLICATION_JSON)
- ListenableFuture<ResourceUsage> getResourceUsage(@FormParam("serverid") String id, @FormParam("resource") String resource,
- @FormParam("resolution") String resolution);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSApiTest.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSApiTest.java b/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSApiTest.java
new file mode 100644
index 0000000..cc5fd27
--- /dev/null
+++ b/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSApiTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.glesys;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.internal.BaseAsyncApiTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code GleSYSApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "GleSYSApiTest")
+public class GleSYSApiTest extends BaseAsyncApiTest<GleSYSApi> {
+ private GleSYSApi syncApi;
+
+ @Override
+ public ProviderMetadata createProviderMetadata() {
+ return new GleSYSProviderMetadata();
+ }
+
+ public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
+ assert syncApi.getServerApi() != null;
+ assert syncApi.getIpApi() != null;
+ assert syncApi.getDomainApi() != null;
+ assert syncApi.getArchiveApi() != null;
+ }
+
+ @BeforeClass
+ @Override
+ protected void setupFactory() throws IOException {
+ super.setupFactory();
+ syncApi = injector.getInstance(GleSYSApi.class);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+
+ }
+}
[08/10] git commit: Remove async from gogrid
Posted by ab...@apache.org.
Remove async from gogrid
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/d4bf5112
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/d4bf5112
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/d4bf5112
Branch: refs/heads/master
Commit: d4bf51128e9e67f6d9be6cd87c65fa7511074002
Parents: a2af31c
Author: Andrew Bayer <an...@gmail.com>
Authored: Fri Aug 2 07:57:07 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Fri Aug 2 07:57:42 2013 -0700
----------------------------------------------------------------------
.../main/java/org/jclouds/gogrid/GoGridApi.java | 63 ++++
.../org/jclouds/gogrid/GoGridApiMetadata.java | 23 +-
.../org/jclouds/gogrid/GoGridAsyncClient.java | 66 -----
.../java/org/jclouds/gogrid/GoGridClient.java | 63 ----
...ndObjectNameToGetJobsRequestQueryParams.java | 2 +-
.../strategy/GoGridComputeServiceAdapter.java | 9 +-
.../gogrid/config/GoGridHttpApiModule.java | 88 ++++++
.../gogrid/config/GoGridRestClientModule.java | 112 -------
.../org/jclouds/gogrid/domain/PowerCommand.java | 2 +-
.../jclouds/gogrid/features/GridImageApi.java | 169 +++++++++++
.../org/jclouds/gogrid/features/GridIpApi.java | 107 +++++++
.../org/jclouds/gogrid/features/GridJobApi.java | 93 ++++++
.../gogrid/features/GridLoadBalancerApi.java | 193 ++++++++++++
.../jclouds/gogrid/features/GridServerApi.java | 296 +++++++++++++++++++
.../gogrid/options/AddLoadBalancerOptions.java | 2 +-
.../LoadBalancerLatestJobCompleted.java | 6 +-
.../predicates/ServerLatestJobCompleted.java | 6 +-
.../gogrid/services/GridImageAsyncClient.java | 127 --------
.../gogrid/services/GridImageClient.java | 111 -------
.../gogrid/services/GridIpAsyncClient.java | 94 ------
.../jclouds/gogrid/services/GridIpClient.java | 71 -----
.../gogrid/services/GridJobAsyncClient.java | 71 -----
.../jclouds/gogrid/services/GridJobClient.java | 67 -----
.../services/GridLoadBalancerAsyncClient.java | 136 ---------
.../gogrid/services/GridLoadBalancerClient.java | 134 ---------
.../gogrid/services/GridServerAsyncClient.java | 218 --------------
.../gogrid/services/GridServerClient.java | 199 -------------
.../java/org/jclouds/gogrid/GoGridApiTest.java | 52 ++++
.../jclouds/gogrid/GoGridAsyncClientTest.java | 63 ----
.../jclouds/gogrid/GoGridLiveTestDisabled.java | 2 +-
.../compute/GoGridComputeServiceLiveTest.java | 4 +-
.../gogrid/features/BaseGoGridApiLiveTest.java | 33 +++
.../gogrid/features/BaseGoGridApiTest.java | 69 +++++
.../features/BaseGoGridHttpApiExpectTest.java | 51 ++++
.../gogrid/features/GridImageApiLiveTest.java | 138 +++++++++
.../gogrid/features/GridImageApiTest.java | 192 ++++++++++++
.../jclouds/gogrid/features/GridIpApiTest.java | 87 ++++++
.../gogrid/features/GridJobApiLiveTest.java | 64 ++++
.../jclouds/gogrid/features/GridJobApiTest.java | 127 ++++++++
.../features/GridLoadBalancerApiTest.java | 209 +++++++++++++
.../gogrid/features/GridServerApiTest.java | 273 +++++++++++++++++
.../features/GridServerClientExpectTest.java | 143 +++++++++
.../ServerLatestJobCompletedTest.java | 4 +-
.../services/BaseGoGridAsyncClientTest.java | 69 -----
.../services/BaseGoGridClientLiveTest.java | 33 ---
.../BaseGoGridRestClientExpectTest.java | 51 ----
.../services/GridImageAsyncClientTest.java | 192 ------------
.../services/GridImageClientLiveTest.java | 138 ---------
.../gogrid/services/GridIpAsyncClientTest.java | 87 ------
.../gogrid/services/GridJobAsyncClientTest.java | 127 --------
.../gogrid/services/GridJobClientLiveTest.java | 64 ----
.../GridLoadBalancerAsyncClientTest.java | 209 -------------
.../services/GridServerAsyncClientTest.java | 273 -----------------
.../services/GridServerClientExpectTest.java | 143 ---------
54 files changed, 2471 insertions(+), 2954 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java
new file mode 100644
index 0000000..a2ef544
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApi.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid;
+
+import java.io.Closeable;
+
+import org.jclouds.gogrid.features.GridImageApi;
+import org.jclouds.gogrid.features.GridIpApi;
+import org.jclouds.gogrid.features.GridJobApi;
+import org.jclouds.gogrid.features.GridLoadBalancerApi;
+import org.jclouds.gogrid.features.GridServerApi;
+import org.jclouds.rest.annotations.Delegate;
+
+/**
+ * @author Oleksiy Yarmula
+ */
+public interface GoGridApi extends Closeable {
+
+ /**
+ * Services with methods, related to managing servers
+ */
+ @Delegate
+ GridServerApi getServerServices();
+
+ /**
+ * Services with methods, related to retrieving jobs
+ */
+ @Delegate
+ GridJobApi getJobServices();
+
+ /**
+ * Services with methods, related to retrieving IP addresses
+ */
+ @Delegate
+ GridIpApi getIpServices();
+
+ /**
+ * Services with methods, related to managing load balancers.
+ */
+ @Delegate
+ GridLoadBalancerApi getLoadBalancerServices();
+
+ /**
+ * Services with methods, related to managing images.
+ */
+ @Delegate
+ GridImageApi getImageServices();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java
index 53ec0b8..20af47b 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridApiMetadata.java
@@ -24,11 +24,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule;
-import org.jclouds.gogrid.config.GoGridRestClientModule;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.gogrid.config.GoGridHttpApiModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -36,17 +35,8 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class GoGridApiMetadata extends BaseRestApiMetadata {
+public class GoGridApiMetadata extends BaseHttpApiMetadata<GoGridApi> {
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GoGridClient.class)} as
- * {@link GoGridAsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<GoGridClient, GoGridAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<GoGridClient, GoGridAsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -61,17 +51,16 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty("jclouds.ssh.max-retries", "5");
properties.setProperty("jclouds.ssh.retry-auth", "true");
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<GoGridApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
- super(GoGridClient.class, GoGridAsyncClient.class);
id("gogrid")
.name("GoGrid API")
.identityName("API Key")
@@ -81,7 +70,7 @@ public class GoGridApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api.gogrid.com/api")
.defaultProperties(GoGridApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(GoGridRestClientModule.class, GoGridComputeServiceContextModule.class));
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(GoGridHttpApiModule.class, GoGridComputeServiceContextModule.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java
deleted file mode 100644
index 91b321e..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridAsyncClient.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid;
-
-import java.io.Closeable;
-
-import org.jclouds.gogrid.services.GridImageAsyncClient;
-import org.jclouds.gogrid.services.GridIpAsyncClient;
-import org.jclouds.gogrid.services.GridJobAsyncClient;
-import org.jclouds.gogrid.services.GridLoadBalancerAsyncClient;
-import org.jclouds.gogrid.services.GridServerAsyncClient;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * @author Oleksiy Yarmula
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(GoGridClient.class)} as
- * {@link GoGridAsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-public interface GoGridAsyncClient extends Closeable {
-
- /**
- * @see GoGridClient#getServerServices()
- */
- @Delegate
- GridServerAsyncClient getServerServices();
-
- /**
- * @see GoGridClient#getJobServices()
- */
- @Delegate
- GridJobAsyncClient getJobServices();
-
- /**
- * @see GoGridClient#getIpServices()
- */
- @Delegate
- GridIpAsyncClient getIpServices();
-
- /**
- * @see GoGridClient#getLoadBalancerServices()
- */
- @Delegate
- GridLoadBalancerAsyncClient getLoadBalancerServices();
-
- /**
- * @see GoGridClient#getImageServices()
- */
- @Delegate
- GridImageAsyncClient getImageServices();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java
deleted file mode 100644
index fac2205..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/GoGridClient.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid;
-
-import java.io.Closeable;
-
-import org.jclouds.gogrid.services.GridImageClient;
-import org.jclouds.gogrid.services.GridIpClient;
-import org.jclouds.gogrid.services.GridJobClient;
-import org.jclouds.gogrid.services.GridLoadBalancerClient;
-import org.jclouds.gogrid.services.GridServerClient;
-import org.jclouds.rest.annotations.Delegate;
-
-/**
- * @author Oleksiy Yarmula
- */
-public interface GoGridClient extends Closeable {
-
- /**
- * Services with methods, related to managing servers
- */
- @Delegate
- GridServerClient getServerServices();
-
- /**
- * Services with methods, related to retrieving jobs
- */
- @Delegate
- GridJobClient getJobServices();
-
- /**
- * Services with methods, related to retrieving IP addresses
- */
- @Delegate
- GridIpClient getIpServices();
-
- /**
- * Services with methods, related to managing load balancers.
- */
- @Delegate
- GridLoadBalancerClient getLoadBalancerServices();
-
- /**
- * Services with methods, related to managing images.
- */
- @Delegate
- GridImageClient getImageServices();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java
index d8861ef..0b38085 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/binders/BindObjectNameToGetJobsRequestQueryParams.java
@@ -25,7 +25,7 @@ import org.jclouds.rest.Binder;
/**
*
- * @see org.jclouds.gogrid.services.GridJobClient#getJobsForObjectName(String)
+ * @see org.jclouds.gogrid.features.GridJobApi#getJobsForObjectName(String)
*
* @author Oleksiy Yarmula
*/
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java
index 837fa71..2087845 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/strategy/GoGridComputeServiceAdapter.java
@@ -32,7 +32,7 @@ import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.LoginCredentials;
-import org.jclouds.gogrid.GoGridClient;
+import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.compute.suppliers.GoGridHardwareSupplier;
import org.jclouds.gogrid.domain.Ip;
import org.jclouds.gogrid.domain.IpType;
@@ -48,12 +48,11 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Longs;
/**
- * defines the connection between the {@link GoGridClient} implementation and the jclouds
+ * defines the connection between the {@link org.jclouds.gogrid.GoGridApi} implementation and the jclouds
* {@link ComputeService}
*
*/
@@ -63,13 +62,13 @@ public class GoGridComputeServiceAdapter implements ComputeServiceAdapter<Server
@Resource
protected Logger logger = Logger.NULL;
- private final GoGridClient client;
+ private final GoGridApi client;
private final Function<Hardware, String> sizeToRam;
private final Predicate<Server> serverLatestJobCompleted;
private final Predicate<Server> serverLatestJobCompletedShort;
@Inject
- protected GoGridComputeServiceAdapter(GoGridClient client, Function<Hardware, String> sizeToRam, Timeouts timeouts) {
+ protected GoGridComputeServiceAdapter(GoGridApi client, Function<Hardware, String> sizeToRam, Timeouts timeouts) {
this.client = checkNotNull(client, "client");
this.sizeToRam = checkNotNull(sizeToRam, "sizeToRam");
this.serverLatestJobCompleted = retry(new ServerLatestJobCompleted(client.getJobServices()),
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java
new file mode 100644
index 0000000..7585583
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridHttpApiModule.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.config;
+
+import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Named;
+
+import org.jclouds.date.TimeStamp;
+import org.jclouds.gogrid.GoGridApi;
+import org.jclouds.gogrid.handlers.GoGridErrorHandler;
+import org.jclouds.gogrid.location.GoGridDefaultLocationSupplier;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.location.suppliers.ImplicitLocationSupplier;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.HttpApiModule;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+
+/**
+ * Configures the GoGrid connection.
+ *
+ * @author Adrian Cole
+ * @author Oleksiy Yarmula
+ */
+@ConfiguresRestClient
+public class GoGridHttpApiModule extends HttpApiModule<GoGridApi> {
+
+ @Provides
+ @TimeStamp
+ protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
+ return cache.get();
+ }
+
+ /**
+ * borrowing concurrency code to ensure that caching takes place properly
+ */
+ @Provides
+ @TimeStamp
+ Supplier<Long> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds) {
+ return Suppliers.memoizeWithExpiration(new Supplier<Long>() {
+ public Long get() {
+ return System.currentTimeMillis() / 1000;
+ }
+ }, seconds, TimeUnit.SECONDS);
+ }
+
+ @Override
+ 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);
+ }
+
+ @Override
+ protected void configure() {
+ install(new GoGridParserModule());
+ super.configure();
+ }
+
+ @Override
+ protected void installLocations() {
+ super.installLocations();
+ bind(ImplicitLocationSupplier.class).to(GoGridDefaultLocationSupplier.class).in(Scopes.SINGLETON);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java
deleted file mode 100644
index d9bc670..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/config/GoGridRestClientModule.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.config;
-
-import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import javax.inject.Named;
-
-import org.jclouds.date.TimeStamp;
-import org.jclouds.gogrid.GoGridAsyncClient;
-import org.jclouds.gogrid.GoGridClient;
-import org.jclouds.gogrid.handlers.GoGridErrorHandler;
-import org.jclouds.gogrid.location.GoGridDefaultLocationSupplier;
-import org.jclouds.gogrid.services.GridImageAsyncClient;
-import org.jclouds.gogrid.services.GridImageClient;
-import org.jclouds.gogrid.services.GridIpAsyncClient;
-import org.jclouds.gogrid.services.GridIpClient;
-import org.jclouds.gogrid.services.GridJobAsyncClient;
-import org.jclouds.gogrid.services.GridJobClient;
-import org.jclouds.gogrid.services.GridLoadBalancerAsyncClient;
-import org.jclouds.gogrid.services.GridLoadBalancerClient;
-import org.jclouds.gogrid.services.GridServerAsyncClient;
-import org.jclouds.gogrid.services.GridServerClient;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.location.suppliers.ImplicitLocationSupplier;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Provides;
-import com.google.inject.Scopes;
-
-/**
- * Configures the GoGrid connection.
- *
- * @author Adrian Cole
- * @author Oleksiy Yarmula
- */
-@ConfiguresRestClient
-public class GoGridRestClientModule extends RestClientModule<GoGridClient, GoGridAsyncClient> {
- public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
- .put(GridServerClient.class, GridServerAsyncClient.class)//
- .put(GridJobClient.class, GridJobAsyncClient.class)//
- .put(GridIpClient.class, GridIpAsyncClient.class)//
- .put(GridLoadBalancerClient.class, GridLoadBalancerAsyncClient.class)//
- .put(GridImageClient.class, GridImageAsyncClient.class)//
- .build();
-
- public GoGridRestClientModule() {
- super(DELEGATE_MAP);
- }
-
- @Provides
- @TimeStamp
- protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
- return cache.get();
- }
-
- /**
- * borrowing concurrency code to ensure that caching takes place properly
- */
- @Provides
- @TimeStamp
- Supplier<Long> provideTimeStampCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds) {
- return Suppliers.memoizeWithExpiration(new Supplier<Long>() {
- public Long get() {
- return System.currentTimeMillis() / 1000;
- }
- }, seconds, TimeUnit.SECONDS);
- }
-
- @Override
- 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);
- }
-
- @Override
- protected void configure() {
- install(new GoGridParserModule());
- super.configure();
- }
-
- @Override
- protected void installLocations() {
- super.installLocations();
- bind(ImplicitLocationSupplier.class).to(GoGridDefaultLocationSupplier.class).in(Scopes.SINGLETON);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java
index 9b0313b..c77d578 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/domain/PowerCommand.java
@@ -27,7 +27,7 @@ package org.jclouds.gogrid.domain;
* <li>Restart</li>
* </ul>
*
- * @see org.jclouds.gogrid.services.GridServerClient#power(String, PowerCommand)
+ * @see org.jclouds.gogrid.features.GridServerApi#power(String, PowerCommand)
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.server.power" />
*
* @author Oleksiy Yarmula
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java
new file mode 100644
index 0000000..517c2c6
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridImageApi.java
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_DESCRIPTION_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_FRIENDLY_NAME_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
+
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.gogrid.binders.BindIdsToQueryParams;
+import org.jclouds.gogrid.binders.BindNamesToQueryParams;
+import org.jclouds.gogrid.domain.Option;
+import org.jclouds.gogrid.domain.ServerImage;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.options.GetImageListOptions;
+import org.jclouds.gogrid.options.SaveImageOptions;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * Manages the server images
+ *
+ * @see <a
+ * href="http://wiki.gogrid.com/wiki/index.php/API#Server_Image_Methods"/>
+ * @author Oleksiy Yarmula
+ */
+@RequestFilters(SharedKeyLiteAuthentication.class)
+@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
+public interface GridImageApi {
+
+ /**
+ * Returns all server images.
+ *
+ * @param options
+ * options to narrow the search down
+ * @return server images found
+ */
+ @GET
+ @ResponseParser(ParseImageListFromJsonResponse.class)
+ @Path("/grid/image/list")
+ Set<ServerImage> getImageList(GetImageListOptions... options);
+
+ /**
+ * Returns images, found by specified ids
+ *
+ * @param ids
+ * the ids that match existing images
+ * @return images found
+ */
+ @GET
+ @ResponseParser(ParseImageListFromJsonResponse.class)
+ @Path("/grid/image/get")
+ Set<ServerImage> getImagesById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
+
+ /**
+ * Returns images, found by specified names
+ *
+ * @param names
+ * the names that march existing images
+ * @return images found
+ */
+ @GET
+ @ResponseParser(ParseImageListFromJsonResponse.class)
+ @Path("/grid/image/get")
+ Set<ServerImage> getImagesByName(@BinderParam(BindNamesToQueryParams.class) String... names);
+
+ /**
+ * Edits an existing image
+ *
+ * @param idOrName
+ * id or name of the existing image
+ * @param newDescription
+ * description to replace the current one
+ * @return edited server image
+ */
+ @GET
+ @ResponseParser(ParseImageFromJsonResponse.class)
+ @Path("/grid/image/edit")
+ ServerImage editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
+ @QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription);
+
+ /**
+ * Edits an existing image
+ *
+ * @param idOrName
+ * id or name of the existing image
+ * @param newFriendlyName
+ * friendly name to replace the current one
+ * @return edited server image
+ */
+ @GET
+ @ResponseParser(ParseImageFromJsonResponse.class)
+ @Path("/grid/image/edit")
+ ServerImage editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
+ @QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName);
+
+ /**
+ * Retrieves the list of supported Datacenters to save images in. The objects
+ * will have datacenter ID, name and description. In most cases, id or name
+ * will be used for {@link #getImageList}.
+ *
+ * @return supported datacenters
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "datacenter")
+ Set<Option> getDatacenters();
+
+ /**
+ * Deletes an existing image
+ *
+ * @param id
+ * id of the existing image
+ */
+ @GET
+ @ResponseParser(ParseImageFromJsonResponse.class)
+ @Path("/grid/image/delete")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ServerImage deleteById(@QueryParam(ID_KEY) long id);
+
+ /**
+ * This call will save a private (visible to only you) server image to your
+ * library of available images. The image will be saved from an existing
+ * server.
+ *
+ * @param idOrName
+ * id or name of the existing server
+ * @param friendlyName
+ * friendly name of the image
+ * @return saved server image
+ */
+ @GET
+ @ResponseParser(ParseImageFromJsonResponse.class)
+ @Path("/grid/image/save")
+ ServerImage saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName,
+ @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName, SaveImageOptions... options);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridIpApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridIpApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridIpApi.java
new file mode 100644
index 0000000..c5bfdd3
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridIpApi.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+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 static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
+
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.jclouds.gogrid.domain.Ip;
+import org.jclouds.gogrid.domain.Option;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.options.GetIpListOptions;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * @author Oleksiy Yarmula
+ */
+@RequestFilters(SharedKeyLiteAuthentication.class)
+@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
+public interface GridIpApi {
+
+ /**
+ * Returns all IPs in the system that match the options
+ *
+ * @param options
+ * options to narrow the search down
+ * @return IPs found by the search
+ */
+ @GET
+ @ResponseParser(ParseIpListFromJsonResponse.class)
+ @Path("/grid/ip/list")
+ Set<Ip> getIpList(GetIpListOptions... options);
+
+ /**
+ * Returns the list of unassigned IPs.
+ *
+ * NOTE: this returns both public and private IPs!
+ *
+ * @return unassigned IPs
+ */
+ @GET
+ @ResponseParser(ParseIpListFromJsonResponse.class)
+ @Path("/grid/ip/list")
+ @QueryParams(keys = IP_STATE_KEY, values = "Unassigned")
+ Set<Ip> getUnassignedIpList();
+
+ /**
+ * Returns the list of unassigned public IPs.
+ *
+ * @return unassigned public IPs
+ */
+ @GET
+ @ResponseParser(ParseIpListFromJsonResponse.class)
+ @Path("/grid/ip/list")
+ @QueryParams(keys = { IP_STATE_KEY, IP_TYPE_KEY }, values = { "Unassigned", "Public" })
+ Set<Ip> getUnassignedPublicIpList();
+
+ /**
+ * Returns the list of assigned IPs
+ *
+ * NOTE: this returns both public and private IPs!
+ *
+ * @return assigned IPs
+ */
+ @GET
+ @ResponseParser(ParseIpListFromJsonResponse.class)
+ @Path("/grid/ip/list")
+ @QueryParams(keys = IP_STATE_KEY, values = "Assigned")
+ Set<Ip> getAssignedIpList();
+
+ /**
+ * Retrieves the list of supported Datacenters to retrieve ips from. The objects will have
+ * datacenter ID, name and description. In most cases, id or name will be used for
+ * {@link #addServer}.
+ *
+ * @return supported datacenters
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "ip.datacenter")
+ Set<Option> getDatacenters();
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridJobApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridJobApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridJobApi.java
new file mode 100644
index 0000000..16119be
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridJobApi.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
+
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+import org.jclouds.gogrid.binders.BindIdsToQueryParams;
+import org.jclouds.gogrid.binders.BindObjectNameToGetJobsRequestQueryParams;
+import org.jclouds.gogrid.domain.Job;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
+import org.jclouds.gogrid.options.GetJobListOptions;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * Manages the customer's jobs.
+ *
+ * @see <a href="http://wiki.gogrid.com/wiki/index.php/API#Job_Methods" />
+ *
+ * @author Oleksiy Yarmula
+ */
+@RequestFilters(SharedKeyLiteAuthentication.class)
+@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
+public interface GridJobApi {
+
+ /**
+ * Returns all jobs found. The resulting set may be narrowed down by providing
+ * {@link GetJobListOptions}.
+ *
+ * By default, the result is <=100 items from the date range of 4 weeks ago to now.
+ *
+ * NOTE: this method results in a big volume of data in response
+ *
+ * @return jobs found by request
+ */
+ @GET
+ @ResponseParser(ParseJobListFromJsonResponse.class)
+ @Path("/grid/job/list")
+ Set<Job> getJobList(GetJobListOptions... options);
+
+ /**
+ * Returns jobs found for an object with a provided name.
+ *
+ * Usually, in GoGrid a name will uniquely identify the object, or, as the docs state, some API
+ * methods will cause errors.
+ *
+ * @param objectName
+ * name of the object
+ * @return found jobs for the object
+ */
+ @GET
+ @ResponseParser(ParseJobListFromJsonResponse.class)
+ @Path("/grid/job/list")
+ Set<Job> getJobsForObjectName(
+ @BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName);
+
+ /**
+ * Returns jobs for the corresponding id(s).
+ *
+ * NOTE: there is a 1:1 relation between a job and its ID.
+ *
+ * @param ids
+ * ids for the jobs
+ * @return jobs found by the ids
+ */
+ @GET
+ @ResponseParser(ParseJobListFromJsonResponse.class)
+ @Path("/grid/job/get")
+ Set<Job> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java
new file mode 100644
index 0000000..5dcf978
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridLoadBalancerApi.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.jclouds.gogrid.binders.BindIdsToQueryParams;
+import org.jclouds.gogrid.binders.BindNamesToQueryParams;
+import org.jclouds.gogrid.binders.BindRealIpPortPairsToQueryParams;
+import org.jclouds.gogrid.binders.BindVirtualIpPortPairToQueryParams;
+import org.jclouds.gogrid.domain.IpPortPair;
+import org.jclouds.gogrid.domain.LoadBalancer;
+import org.jclouds.gogrid.domain.Option;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.options.AddLoadBalancerOptions;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * @author Oleksiy Yarmula
+ */
+@RequestFilters(SharedKeyLiteAuthentication.class)
+@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
+public interface GridLoadBalancerApi {
+
+
+ /**
+ * Returns all load balancers found for the current user.
+ *
+ * @return load balancers found
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
+ @Path("/grid/loadbalancer/list")
+ Set<LoadBalancer> getLoadBalancerList();
+
+ /**
+ * Returns the load balancer(s) by unique name(s).
+ *
+ * Given a name or a set of names, finds one or multiple load balancers.
+ *
+ * @param names
+ * to get the load balancers
+ * @return load balancer(s) matching the name(s)
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
+ @Path("/grid/loadbalancer/get")
+ Set<LoadBalancer> getLoadBalancersByName(
+ @BinderParam(BindNamesToQueryParams.class) String... names);
+
+ /**
+ * Returns the load balancer(s) by unique id(s).
+ *
+ * Given an id or a set of ids, finds one or multiple load balancers.
+ *
+ * @param ids
+ * to get the load balancers
+ * @return load balancer(s) matching the ids
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
+ @Path("/grid/loadbalancer/get")
+ Set<LoadBalancer> getLoadBalancersById(
+ @BinderParam(BindIdsToQueryParams.class) Long... ids);
+
+ /**
+ * Creates a load balancer with given properties.
+ *
+ * @param name
+ * name of the load balancer
+ * @param virtualIp
+ * virtual IP with IP address set in {@link org.jclouds.gogrid.domain.Ip#ip} and port
+ * set in {@link IpPortPair#port}
+ * @param realIps
+ * real IPs to bind the virtual IP to, with IP address set in
+ * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
+ * @param options
+ * options that specify load balancer's type (round robin, least load), persistence
+ * strategy, or description.
+ * @return created load balancer object
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
+ @Path("/grid/loadbalancer/add")
+ LoadBalancer addLoadBalancer(@QueryParam(NAME_KEY) String name,
+ @BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
+ @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
+ AddLoadBalancerOptions... options);
+
+ /**
+ * Edits the existing load balancer to change the real IP mapping.
+ *
+ * @param name
+ * id of the existing load balancer
+ * @param realIps
+ * real IPs to bind the virtual IP to, with IP address set in
+ * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
+ * @return edited object
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
+ @Path("/grid/loadbalancer/edit")
+ LoadBalancer editLoadBalancerNamed(@QueryParam(NAME_KEY) String name,
+ @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
+
+ /**
+ * Edits the existing load balancer to change the real IP mapping.
+ *
+ * @param id
+ * name of the existing load balancer
+ * @param realIps
+ * real IPs to bind the virtual IP to, with IP address set in
+ * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
+ * @return edited object
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
+ @Path("/grid/loadbalancer/edit")
+ LoadBalancer editLoadBalancer(@QueryParam(ID_KEY) long id,
+ @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
+
+ /**
+ * Deletes the load balancer by Id
+ *
+ * @param id
+ * id of the load balancer to delete
+ * @return load balancer before the command is executed
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
+ @Path("/grid/loadbalancer/delete")
+ LoadBalancer deleteById(@QueryParam(ID_KEY) Long id);
+
+ /**
+ * Deletes the load balancer by name;
+ *
+ * NOTE: Using this parameter may generate an error if one or more load balancers share a
+ * non-unique name.
+ *
+ * @param name
+ * name of the load balancer to be deleted
+ *
+ * @return load balancer before the command is executed
+ */
+ @GET
+ @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
+ @Path("/grid/loadbalancer/delete")
+ LoadBalancer deleteByName(@QueryParam(NAME_KEY) String name);
+
+ /**
+ * Retrieves the list of supported Datacenters to launch servers into. The objects will have
+ * datacenter ID, name and description. In most cases, id or name will be used for
+ * {@link #addLoadBalancer}.
+ *
+ * @return supported datacenters
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "loadbalancer.datacenter")
+ Set<Option> getDatacenters();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridServerApi.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridServerApi.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridServerApi.java
new file mode 100644
index 0000000..0615579
--- /dev/null
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/features/GridServerApi.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
+import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.QueryParam;
+
+import org.jclouds.Fallbacks;
+import org.jclouds.domain.Credentials;
+import org.jclouds.gogrid.binders.BindIdsToQueryParams;
+import org.jclouds.gogrid.binders.BindNamesToQueryParams;
+import org.jclouds.gogrid.domain.Option;
+import org.jclouds.gogrid.domain.PowerCommand;
+import org.jclouds.gogrid.domain.Server;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
+import org.jclouds.gogrid.options.AddServerOptions;
+import org.jclouds.gogrid.options.GetServerListOptions;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.OnlyElement;
+import org.jclouds.rest.annotations.QueryParams;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+
+/**
+ * Provides synchronous access to GoGrid.
+ * <p/>
+ *
+ * @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
+ *
+ * @author Adrian Cole
+ * @author Oleksiy Yarmula
+ */
+@RequestFilters(SharedKeyLiteAuthentication.class)
+@QueryParams(keys = VERSION, values = "1.6")
+public interface GridServerApi {
+
+ /**
+ * Returns the list of all servers.
+ *
+ * The result can be narrowed down by providing the options.
+ *
+ * @param getServerListOptions
+ * options to narrow down the result
+ * @return servers found by the request
+ */
+ @GET
+ @SelectJson("list")
+ @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
+ @Path("/grid/server/list")
+ Set<Server> getServerList(GetServerListOptions... getServerListOptions);
+
+ /**
+ * Returns the server(s) by unique name(s).
+ *
+ * Given a name or a set of names, finds one or multiple servers.
+ *
+ * @param names
+ * to get the servers
+ * @return server(s) matching the name(s)
+ */
+ @GET
+ @SelectJson("list")
+ @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
+ @Path("/grid/server/get")
+ Set<Server> getServersByName(
+ @BinderParam(BindNamesToQueryParams.class) String... names);
+
+ /**
+ * Returns the server(s) by unique id(s).
+ *
+ * Given an id or a set of ids, finds one or multiple servers.
+ *
+ * @param ids
+ * to get the servers
+ * @return server(s) matching the ids
+ */
+ @GET
+ @SelectJson("list")
+ @Fallback(Fallbacks.EmptySetOnNotFoundOr404.class)
+ @Path("/grid/server/get")
+ Set<Server> getServersById(
+ @BinderParam(BindIdsToQueryParams.class) long... ids);
+
+ /**
+ * Returns a map of running servers' names to the log in credentials.
+ *
+ * @return map <String server name => Credentials>
+ */
+ @GET
+ @ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
+ @Path("/support/password/list")
+ Map<String, Credentials> getServerCredentialsList();
+
+ /**
+ *
+ * @return the login user and password of a server, or null if none found
+ */
+ @GET
+ @ResponseParser(ParseCredentialsFromJsonResponse.class)
+ @Path("/support/grid/password/get")
+ Credentials getServerCredentials(@QueryParam("id") long id);
+
+ /**
+ * Adds a server with specified attributes
+ *
+ * @param name
+ * name of the server
+ * @param image
+ * image (id or name)
+ * @param ram
+ * ram type (id or name)
+ * @param ip
+ * ip address
+ * @param addServerOptions
+ * options to make it a sandbox instance or/and description
+ * @return created server
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/add")
+ Server addServer(@QueryParam(NAME_KEY) String name,
+ @QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
+ @QueryParam(IP_KEY) String ip, AddServerOptions... addServerOptions);
+
+ /**
+ * Changes the server's state according to {@link PowerCommand}
+ *
+ * @param idOrName
+ * id or name of the server to apply the command
+ * @param power
+ * new desired state
+ * @return server immediately after applying the command
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/power")
+ Server power(
+ @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName,
+ @QueryParam(POWER_KEY) PowerCommand power);
+
+ /**
+ * Deletes the server by Id
+ *
+ * @param id
+ * id of the server to delete
+ * @return server before the command is executed
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/delete")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Server deleteById(@QueryParam(ID_KEY) long id);
+
+ /**
+ * Deletes the server by name;
+ *
+ * NOTE: Using this parameter may generate an error if one or more servers
+ * share a non-unique name.
+ *
+ * @param name
+ * name of the server to be deleted
+ *
+ * @return server before the command is executed
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/delete")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Server deleteByName(@QueryParam(NAME_KEY) String name);
+
+ /**
+ * Retrieves the list of supported RAM configurations. The objects will have
+ * RAM ID, name and description. In most cases, id or name will be used for
+ * {@link #addServer}.
+ *
+ * To see how RAM maps to CPU and disk space (as of March 2010), see
+ * {@link org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule#provideSizeToRam}
+ * .
+ *
+ * @return supported ram sizes
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
+ Set<Option> getRamSizes();
+
+ /**
+ * Retrieves the list of supported server types, for example Web/App Server and Database Server. In most cases, id
+ * or name will be used for {@link #editServerType}.
+ *
+ * @return supported server types
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
+ Set<Option> getTypes();
+
+ /**
+ * Retrieves the list of supported Datacenters to launch servers into. The
+ * objects will have datacenter ID, name and description. In most cases, id
+ * or name will be used for {@link #addServer}.
+ *
+ * @return supported datacenters
+ */
+ @GET
+ @ResponseParser(ParseOptionsFromJsonResponse.class)
+ @Path("/common/lookup/list")
+ @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
+ Set<Option> getDatacenters();
+
+ /**
+ * Edits an existing server
+ *
+ * @param id
+ * id of the existing server
+ * @param newDescription
+ * description to replace the current one
+ * @return edited server
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/edit")
+ Server editServerDescription(@QueryParam("id") long id,
+ @QueryParam("description") String newDescription);
+
+ /**
+ * Edits an existing server
+ *
+ * @param id
+ * id of the existing server
+ * @param ram
+ * ram to replace the current one
+ * @return edited server
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/edit")
+ Server editServerRam(@QueryParam("id") long id,
+ @QueryParam("server.ram") String ram);
+
+ /**
+ * Edits an existing server
+ *
+ * @param id
+ * id of the existing server
+ * @param newType
+ * type to replace the current one
+ * @return edited server
+ */
+ @GET
+ @SelectJson("list")
+ @OnlyElement
+ @Path("/grid/server/edit")
+ Server editServerType(@QueryParam("id") long id,
+ @QueryParam("server.type") String newType);}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/options/AddLoadBalancerOptions.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/options/AddLoadBalancerOptions.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/options/AddLoadBalancerOptions.java
index e75d253..acfc22e 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/options/AddLoadBalancerOptions.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/options/AddLoadBalancerOptions.java
@@ -28,7 +28,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Optional parameters for adding a load balancer.
*
- * @see org.jclouds.gogrid.services.GridLoadBalancerClient#addLoadBalancer
+ * @see org.jclouds.gogrid.features.GridLoadBalancerApi#addLoadBalancer
* @see <a href="http://wiki.gogrid.com/wiki/index.php/API:grid.loadbalancer.add"/>
*
* @author Oleksiy Yarmula
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java
index bcf5fd0..44fd29d 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/LoadBalancerLatestJobCompleted.java
@@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.LoadBalancer;
-import org.jclouds.gogrid.services.GridJobClient;
+import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger;
import com.google.common.base.Predicate;
@@ -38,13 +38,13 @@ import com.google.inject.Inject;
@Singleton
public class LoadBalancerLatestJobCompleted implements Predicate<LoadBalancer> {
- protected GridJobClient jobClient;
+ protected GridJobApi jobClient;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public LoadBalancerLatestJobCompleted(GridJobClient jobClient) {
+ public LoadBalancerLatestJobCompleted(GridJobApi jobClient) {
this.jobClient = jobClient;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java
index f8fbdde..2f689a4 100644
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java
+++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/predicates/ServerLatestJobCompleted.java
@@ -25,7 +25,7 @@ import javax.inject.Singleton;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.services.GridJobClient;
+import org.jclouds.gogrid.features.GridJobApi;
import org.jclouds.logging.Logger;
import com.google.common.base.Predicate;
@@ -44,13 +44,13 @@ import com.google.inject.Inject;
@Singleton
public class ServerLatestJobCompleted implements Predicate<Server> {
- protected GridJobClient jobClient;
+ protected GridJobApi jobClient;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public ServerLatestJobCompleted(GridJobClient jobClient) {
+ public ServerLatestJobCompleted(GridJobApi jobClient) {
this.jobClient = jobClient;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java
deleted file mode 100644
index 779a60d..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageAsyncClient.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_DESCRIPTION_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_FRIENDLY_NAME_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
-
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.gogrid.binders.BindIdsToQueryParams;
-import org.jclouds.gogrid.binders.BindNamesToQueryParams;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.domain.ServerImage;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
-import org.jclouds.gogrid.options.GetImageListOptions;
-import org.jclouds.gogrid.options.SaveImageOptions;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * @author Oleksiy Yarmula
- */
-@RequestFilters(SharedKeyLiteAuthentication.class)
-@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
-public interface GridImageAsyncClient {
-
- /**
- * @see GridImageClient#getImageList
- */
- @GET
- @ResponseParser(ParseImageListFromJsonResponse.class)
- @Path("/grid/image/list")
- ListenableFuture<Set<ServerImage>> getImageList(GetImageListOptions... options);
-
- /**
- * @see GridImageClient#getImagesById
- */
- @GET
- @ResponseParser(ParseImageListFromJsonResponse.class)
- @Path("/grid/image/get")
- ListenableFuture<Set<ServerImage>> getImagesById(@BinderParam(BindIdsToQueryParams.class) Long... ids);
-
- /**
- * @see GridImageClient#getImagesByName
- */
- @GET
- @ResponseParser(ParseImageListFromJsonResponse.class)
- @Path("/grid/image/get")
- ListenableFuture<Set<ServerImage>> getImagesByName(@BinderParam(BindNamesToQueryParams.class) String... names);
-
- /**
- * @see GridImageClient#editImageDescription
- */
- @GET
- @ResponseParser(ParseImageFromJsonResponse.class)
- @Path("/grid/image/edit")
- ListenableFuture<ServerImage> editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
- @QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription);
-
- /**
- * @see GridImageClient#editImageFriendlyName
- */
- @GET
- @ResponseParser(ParseImageFromJsonResponse.class)
- @Path("/grid/image/edit")
- ListenableFuture<ServerImage> editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
- @QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName);
-
- /**
- * @see GridImageClient#getDatacenters
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "datacenter")
- ListenableFuture<Set<Option>> getDatacenters();
-
- /**
- * @see GridImageClient#deleteById(Long)
- */
- @GET
- @ResponseParser(ParseImageFromJsonResponse.class)
- @Path("/grid/image/delete")
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<ServerImage> deleteById(@QueryParam(ID_KEY) long id);
-
- /**
- * @see GridImageClient#saveImageFromServer
- */
- @GET
- @ResponseParser(ParseImageFromJsonResponse.class)
- @Path("/grid/image/save")
- ListenableFuture<ServerImage> saveImageFromServer(@QueryParam(IMAGE_FRIENDLY_NAME_KEY) String friendlyName,
- @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName, SaveImageOptions... options);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java
deleted file mode 100644
index ee30738..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridImageClient.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import java.util.Set;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.domain.ServerImage;
-import org.jclouds.gogrid.options.GetImageListOptions;
-import org.jclouds.gogrid.options.SaveImageOptions;
-
-/**
- * Manages the server images
- *
- * @see <a
- * href="http://wiki.gogrid.com/wiki/index.php/API#Server_Image_Methods"/>
- * @author Oleksiy Yarmula
- */
-public interface GridImageClient {
- /**
- * Deletes an existing image
- *
- * @param id
- * id of the existing image
- */
- ServerImage deleteById(long id);
-
- /**
- * This call will save a private (visible to only you) server image to your
- * library of available images. The image will be saved from an existing
- * server.
- *
- * @param idOrName
- * id or name of the existing server
- * @param friendlyName
- * friendly name of the image
- * @return saved server image
- */
- ServerImage saveImageFromServer(String friendlyName, String idOrName, SaveImageOptions... options);
-
- /**
- * Returns all server images.
- *
- * @param options
- * options to narrow the search down
- * @return server images found
- */
- Set<ServerImage> getImageList(GetImageListOptions... options);
-
- /**
- * Returns images, found by specified ids
- *
- * @param ids
- * the ids that match existing images
- * @return images found
- */
- Set<ServerImage> getImagesById(Long... ids);
-
- /**
- * Returns images, found by specified names
- *
- * @param names
- * the names that march existing images
- * @return images found
- */
- Set<ServerImage> getImagesByName(String... names);
-
- /**
- * Edits an existing image
- *
- * @param idOrName
- * id or name of the existing image
- * @param newDescription
- * description to replace the current one
- * @return edited server image
- */
- ServerImage editImageDescription(String idOrName, String newDescription);
-
- /**
- * Edits an existing image
- *
- * @param idOrName
- * id or name of the existing image
- * @param newFriendlyName
- * friendly name to replace the current one
- * @return edited server image
- */
- ServerImage editImageFriendlyName(String idOrName, String newFriendlyName);
-
- /**
- * Retrieves the list of supported Datacenters to save images in. The objects
- * will have datacenter ID, name and description. In most cases, id or name
- * will be used for {@link #getImageList}.
- *
- * @return supported datacenters
- */
- Set<Option> getDatacenters();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpAsyncClient.java
deleted file mode 100644
index 3cde534..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpAsyncClient.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_STATE_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_TYPE_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
-
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
-import org.jclouds.gogrid.options.GetIpListOptions;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * @see org.jclouds.gogrid.services.GridImageClient
- *
- * @author Oleksiy Yarmula
- */
-@RequestFilters(SharedKeyLiteAuthentication.class)
-@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
-public interface GridIpAsyncClient {
-
- /**
- * @see GridIpClient#getIpList(org.jclouds.gogrid.options.GetIpListOptions...)
- */
- @GET
- @ResponseParser(ParseIpListFromJsonResponse.class)
- @Path("/grid/ip/list")
- ListenableFuture<Set<Ip>> getIpList(GetIpListOptions... options);
-
- /**
- * @see org.jclouds.gogrid.services.GridIpClient#getUnassignedIpList()
- */
- @GET
- @ResponseParser(ParseIpListFromJsonResponse.class)
- @Path("/grid/ip/list")
- @QueryParams(keys = IP_STATE_KEY, values = "Unassigned")
- ListenableFuture<Set<Ip>> getUnassignedIpList();
-
- /**
- * @see org.jclouds.gogrid.services.GridIpClient#getUnassignedPublicIpList()
- */
- @GET
- @ResponseParser(ParseIpListFromJsonResponse.class)
- @Path("/grid/ip/list")
- @QueryParams(keys = { IP_STATE_KEY, IP_TYPE_KEY }, values = { "Unassigned", "Public" })
- ListenableFuture<Set<Ip>> getUnassignedPublicIpList();
-
- /**
- * @see org.jclouds.gogrid.services.GridIpClient#getAssignedIpList()
- */
- @GET
- @ResponseParser(ParseIpListFromJsonResponse.class)
- @Path("/grid/ip/list")
- @QueryParams(keys = IP_STATE_KEY, values = "Assigned")
- ListenableFuture<Set<Ip>> getAssignedIpList();
-
- /**
- *
- * @see org.jclouds.gogrid.services.GridIpClient#getDatacenters
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "ip.datacenter")
- ListenableFuture<Set<Option>> getDatacenters();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpClient.java
deleted file mode 100644
index 09705a8..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridIpClient.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import java.util.Set;
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.options.GetIpListOptions;
-
-/**
- * @author Oleksiy Yarmula
- */
-public interface GridIpClient {
-
- /**
- * Returns all IPs in the system that match the options
- *
- * @param options
- * options to narrow the search down
- * @return IPs found by the search
- */
- Set<Ip> getIpList(GetIpListOptions... options);
-
- /**
- * Returns the list of unassigned IPs.
- *
- * NOTE: this returns both public and private IPs!
- *
- * @return unassigned IPs
- */
- Set<Ip> getUnassignedIpList();
-
- /**
- * Returns the list of unassigned public IPs.
- *
- * @return unassigned public IPs
- */
- Set<Ip> getUnassignedPublicIpList();
-
- /**
- * Returns the list of assigned IPs
- *
- * NOTE: this returns both public and private IPs!
- *
- * @return assigned IPs
- */
- Set<Ip> getAssignedIpList();
-
- /**
- * Retrieves the list of supported Datacenters to retrieve ips from. The objects will have
- * datacenter ID, name and description. In most cases, id or name will be used for
- * {@link #addServer}.
- *
- * @return supported datacenters
- */
- Set<Option> getDatacenters();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobAsyncClient.java
deleted file mode 100644
index 103a15d..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobAsyncClient.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
-
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-
-import org.jclouds.gogrid.binders.BindIdsToQueryParams;
-import org.jclouds.gogrid.binders.BindObjectNameToGetJobsRequestQueryParams;
-import org.jclouds.gogrid.domain.Job;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
-import org.jclouds.gogrid.options.GetJobListOptions;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * @author Oleksiy Yarmula
- */
-@RequestFilters(SharedKeyLiteAuthentication.class)
-@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
-public interface GridJobAsyncClient {
-
- /**
- * @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...)
- */
- @GET
- @ResponseParser(ParseJobListFromJsonResponse.class)
- @Path("/grid/job/list")
- ListenableFuture<Set<Job>> getJobList(GetJobListOptions... options);
-
- /**
- * @see GridJobClient#getJobsForObjectName(String)
- */
- @GET
- @ResponseParser(ParseJobListFromJsonResponse.class)
- @Path("/grid/job/list")
- ListenableFuture<Set<Job>> getJobsForObjectName(
- @BinderParam(BindObjectNameToGetJobsRequestQueryParams.class) String objectName);
-
- /**
- * @see GridJobClient#getJobsById
- */
- @GET
- @ResponseParser(ParseJobListFromJsonResponse.class)
- @Path("/grid/job/get")
- ListenableFuture<Set<Job>> getJobsById(@BinderParam(BindIdsToQueryParams.class) long... ids);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobClient.java
deleted file mode 100644
index 5e6476b..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridJobClient.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import java.util.Set;
-import org.jclouds.gogrid.domain.Job;
-import org.jclouds.gogrid.options.GetJobListOptions;
-
-/**
- * Manages the customer's jobs.
- *
- * @see <a href="http://wiki.gogrid.com/wiki/index.php/API#Job_Methods" />
- *
- * @author Oleksiy Yarmula
- */
-public interface GridJobClient {
-
- /**
- * Returns all jobs found. The resulting set may be narrowed down by providing
- * {@link GetJobListOptions}.
- *
- * By default, the result is <=100 items from the date range of 4 weeks ago to now.
- *
- * NOTE: this method results in a big volume of data in response
- *
- * @return jobs found by request
- */
- Set<Job> getJobList(GetJobListOptions... options);
-
- /**
- * Returns jobs found for an object with a provided name.
- *
- * Usually, in GoGrid a name will uniquely identify the object, or, as the docs state, some API
- * methods will cause errors.
- *
- * @param serverName
- * name of the object
- * @return found jobs for the object
- */
- Set<Job> getJobsForObjectName(String serverName);
-
- /**
- * Returns jobs for the corresponding id(s).
- *
- * NOTE: there is a 1:1 relation between a job and its ID.
- *
- * @param ids
- * ids for the jobs
- * @return jobs found by the ids
- */
- Set<Job> getJobsById(long... ids);
-
-}
[09/10] Remove async from glesys
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSAsyncApiTest.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSAsyncApiTest.java b/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSAsyncApiTest.java
deleted file mode 100644
index a3b5fc5..0000000
--- a/providers/glesys/src/test/java/org/jclouds/glesys/GleSYSAsyncApiTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.glesys;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.internal.BaseAsyncApiTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code GleSYSAsyncApi}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "GleSYSAsyncApiTest")
-public class GleSYSAsyncApiTest extends BaseAsyncApiTest<GleSYSAsyncApi> {
- private GleSYSAsyncApi asyncApi;
- private GleSYSApi syncApi;
-
- @Override
- public ProviderMetadata createProviderMetadata() {
- return new GleSYSProviderMetadata();
- }
-
- public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert syncApi.getServerApi() != null;
- assert syncApi.getIpApi() != null;
- assert syncApi.getDomainApi() != null;
- assert syncApi.getArchiveApi() != null;
- }
-
- public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException, ExecutionException {
- assert asyncApi.getServerApi() != null;
- assert asyncApi.getIpApi() != null;
- assert asyncApi.getDomainApi() != null;
- assert asyncApi.getArchiveApi() != null;
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- asyncApi = injector.getInstance(GleSYSAsyncApi.class);
- syncApi = injector.getInstance(GleSYSApi.class);
- }
-
- @Override
- protected void checkFilters(HttpRequest request) {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/test/java/org/jclouds/glesys/features/ArchiveApiExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/test/java/org/jclouds/glesys/features/ArchiveApiExpectTest.java b/providers/glesys/src/test/java/org/jclouds/glesys/features/ArchiveApiExpectTest.java
index 22fb216..6c02f52 100644
--- a/providers/glesys/src/test/java/org/jclouds/glesys/features/ArchiveApiExpectTest.java
+++ b/providers/glesys/src/test/java/org/jclouds/glesys/features/ArchiveApiExpectTest.java
@@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
/**
- * Tests parsing of {@code ArchiveAsyncApi}
+ * Tests parsing of {@code ArchiveApi}
*
* @author Adam Lowe
*/
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/test/java/org/jclouds/glesys/features/DomainApiExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/test/java/org/jclouds/glesys/features/DomainApiExpectTest.java b/providers/glesys/src/test/java/org/jclouds/glesys/features/DomainApiExpectTest.java
index 04f2ec6..c331d98 100644
--- a/providers/glesys/src/test/java/org/jclouds/glesys/features/DomainApiExpectTest.java
+++ b/providers/glesys/src/test/java/org/jclouds/glesys/features/DomainApiExpectTest.java
@@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
/**
- * Tests annotation parsing of {@code DomainAsyncApi}
+ * Tests annotation parsing of {@code DomainApi}
*
* @author Adam Lowe
*/
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a14c03ba/providers/glesys/src/test/java/org/jclouds/glesys/features/ServerApiExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/glesys/src/test/java/org/jclouds/glesys/features/ServerApiExpectTest.java b/providers/glesys/src/test/java/org/jclouds/glesys/features/ServerApiExpectTest.java
index 809fb2f..7d7093e 100644
--- a/providers/glesys/src/test/java/org/jclouds/glesys/features/ServerApiExpectTest.java
+++ b/providers/glesys/src/test/java/org/jclouds/glesys/features/ServerApiExpectTest.java
@@ -55,12 +55,12 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/**
- * Tests annotation parsing of {@code ServerAsyncApi}
+ * Tests annotation parsing of {@code ServerApi}
*
* @author Adrian Cole
* @author Adam Lowe
*/
-@Test(groups = "unit", testName = "ServerAsyncApiTest")
+@Test(groups = "unit", testName = "ServerApiTest")
public class ServerApiExpectTest extends BaseGleSYSApiExpectTest {
public void testListServersWhenResponseIs2xx() throws Exception {
[07/10] Remove async from gogrid
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java
deleted file mode 100644
index c78e5f2..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
-
-import java.util.List;
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.gogrid.binders.BindIdsToQueryParams;
-import org.jclouds.gogrid.binders.BindNamesToQueryParams;
-import org.jclouds.gogrid.binders.BindRealIpPortPairsToQueryParams;
-import org.jclouds.gogrid.binders.BindVirtualIpPortPairToQueryParams;
-import org.jclouds.gogrid.domain.IpPortPair;
-import org.jclouds.gogrid.domain.LoadBalancer;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
-import org.jclouds.gogrid.options.AddLoadBalancerOptions;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * @author Oleksiy Yarmula
- */
-@RequestFilters(SharedKeyLiteAuthentication.class)
-@QueryParams(keys = VERSION, values = "{jclouds.api-version}")
-public interface GridLoadBalancerAsyncClient {
-
- /**
- * @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...)
- */
- @GET
- @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
- @Path("/grid/loadbalancer/list")
- ListenableFuture<Set<LoadBalancer>> getLoadBalancerList();
-
- /**
- * @see GridLoadBalancerClient#getLoadBalancersByName
- */
- @GET
- @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
- @Path("/grid/loadbalancer/get")
- ListenableFuture<Set<LoadBalancer>> getLoadBalancersByName(
- @BinderParam(BindNamesToQueryParams.class) String... names);
-
- /**
- * @see GridLoadBalancerClient#getLoadBalancersById
- */
- @GET
- @ResponseParser(ParseLoadBalancerListFromJsonResponse.class)
- @Path("/grid/loadbalancer/get")
- ListenableFuture<Set<LoadBalancer>> getLoadBalancersById(
- @BinderParam(BindIdsToQueryParams.class) Long... ids);
-
- /**
- * @see GridLoadBalancerClient#addLoadBalancer
- */
- @GET
- @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
- @Path("/grid/loadbalancer/add")
- ListenableFuture<LoadBalancer> addLoadBalancer(@QueryParam(NAME_KEY) String name,
- @BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp,
- @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps,
- AddLoadBalancerOptions... options);
-
- /**
- * @see GridLoadBalancerClient#editLoadBalancerNamed
- */
- @GET
- @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
- @Path("/grid/loadbalancer/edit")
- ListenableFuture<LoadBalancer> editLoadBalancerNamed(@QueryParam(NAME_KEY) String name,
- @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
-
- /**
- * @see GridLoadBalancerClient#editLoadBalancer
- */
- @GET
- @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
- @Path("/grid/loadbalancer/edit")
- ListenableFuture<LoadBalancer> editLoadBalancer(@QueryParam(ID_KEY) long id,
- @BinderParam(BindRealIpPortPairsToQueryParams.class) List<IpPortPair> realIps);
-
- /**
- * @see GridLoadBalancerClient#
- */
- @GET
- @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
- @Path("/grid/loadbalancer/delete")
- ListenableFuture<LoadBalancer> deleteById(@QueryParam(ID_KEY) Long id);
-
- /**
- * @see GridLoadBalancerClient#
- */
- @GET
- @ResponseParser(ParseLoadBalancerFromJsonResponse.class)
- @Path("/grid/loadbalancer/delete")
- ListenableFuture<LoadBalancer> deleteByName(@QueryParam(NAME_KEY) String name);
-
- /**
- * @see GridLoadBalancerClient#getDatacenters
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "loadbalancer.datacenter")
- ListenableFuture<Set<Option>> getDatacenters();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java
deleted file mode 100644
index a5abd42..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import java.util.List;
-import java.util.Set;
-import org.jclouds.gogrid.domain.IpPortPair;
-import org.jclouds.gogrid.domain.LoadBalancer;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.options.AddLoadBalancerOptions;
-
-/**
- * @author Oleksiy Yarmula
- */
-public interface GridLoadBalancerClient {
-
- /**
- * Returns all load balancers found for the current user.
- *
- * @return load balancers found
- */
- Set<LoadBalancer> getLoadBalancerList();
-
- /**
- * Returns the load balancer(s) by unique name(s).
- *
- * Given a name or a set of names, finds one or multiple load balancers.
- *
- * @param names
- * to get the load balancers
- * @return load balancer(s) matching the name(s)
- */
- Set<LoadBalancer> getLoadBalancersByName(String... names);
-
- /**
- * Returns the load balancer(s) by unique id(s).
- *
- * Given an id or a set of ids, finds one or multiple load balancers.
- *
- * @param ids
- * to get the load balancers
- * @return load balancer(s) matching the ids
- */
- Set<LoadBalancer> getLoadBalancersById(Long... ids);
-
- /**
- * Creates a load balancer with given properties.
- *
- * @param name
- * name of the load balancer
- * @param virtualIp
- * virtual IP with IP address set in {@link org.jclouds.gogrid.domain.Ip#ip} and port
- * set in {@link IpPortPair#port}
- * @param realIps
- * real IPs to bind the virtual IP to, with IP address set in
- * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
- * @param options
- * options that specify load balancer's type (round robin, least load), persistence
- * strategy, or description.
- * @return created load balancer object
- */
- LoadBalancer addLoadBalancer(String name, IpPortPair virtualIp, List<IpPortPair> realIps,
- AddLoadBalancerOptions... options);
-
- /**
- * Edits the existing load balancer to change the real IP mapping.
- *
- * @param id
- * id of the existing load balancer
- * @param realIps
- * real IPs to bind the virtual IP to, with IP address set in
- * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
- * @return edited object
- */
- LoadBalancer editLoadBalancer(long id, List<IpPortPair> realIps);
-
- /**
- * Edits the existing load balancer to change the real IP mapping.
- *
- * @param name
- * name of the existing load balancer
- * @param realIps
- * real IPs to bind the virtual IP to, with IP address set in
- * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port}
- * @return edited object
- */
- LoadBalancer editLoadBalancerNamed(String name, List<IpPortPair> realIps);
-
- /**
- * Deletes the load balancer by Id
- *
- * @param id
- * id of the load balancer to delete
- * @return load balancer before the command is executed
- */
- LoadBalancer deleteById(Long id);
-
- /**
- * Deletes the load balancer by name;
- *
- * NOTE: Using this parameter may generate an error if one or more load balancers share a
- * non-unique name.
- *
- * @param name
- * name of the load balancer to be deleted
- *
- * @return load balancer before the command is executed
- */
- LoadBalancer deleteByName(String name);
-
- /**
- * Retrieves the list of supported Datacenters to launch servers into. The objects will have
- * datacenter ID, name and description. In most cases, id or name will be used for
- * {@link #addLoadBalancer}.
- *
- * @return supported datacenters
- */
- Set<Option> getDatacenters();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java
deleted file mode 100644
index cab4e38..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerAsyncClient.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
-import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.domain.Credentials;
-import org.jclouds.gogrid.binders.BindIdsToQueryParams;
-import org.jclouds.gogrid.binders.BindNamesToQueryParams;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.domain.PowerCommand;
-import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
-import org.jclouds.gogrid.options.AddServerOptions;
-import org.jclouds.gogrid.options.GetServerListOptions;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.OnlyElement;
-import org.jclouds.rest.annotations.QueryParams;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.SelectJson;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to GoGrid via their REST API.
- * <p/>
- *
- * @see GridServerClient
- * @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
- * @author Adrian Cole
- * @author Oleksiy Yarmula
- */
-@RequestFilters(SharedKeyLiteAuthentication.class)
-@QueryParams(keys = VERSION, values = "1.6")
-public interface GridServerAsyncClient {
-
- /**
- * @see GridServerClient#getServerList(org.jclouds.gogrid.options.GetServerListOptions...)
- */
- @GET
- @SelectJson("list")
- @Fallback(EmptySetOnNotFoundOr404.class)
- @Path("/grid/server/list")
- ListenableFuture<Set<Server>> getServerList(GetServerListOptions... getServerListOptions);
-
- /**
- * @see GridServerClient#getServersByName(String...)
- */
- @GET
- @SelectJson("list")
- @Fallback(EmptySetOnNotFoundOr404.class)
- @Path("/grid/server/get")
- ListenableFuture<Set<Server>> getServersByName(
- @BinderParam(BindNamesToQueryParams.class) String... names);
-
- /**
- * @see GridServerClient#getServersById(Long...)
- */
- @GET
- @SelectJson("list")
- @Fallback(EmptySetOnNotFoundOr404.class)
- @Path("/grid/server/get")
- ListenableFuture<Set<Server>> getServersById(
- @BinderParam(BindIdsToQueryParams.class) long... ids);
-
- /**
- * @see GridServerClient#getServerCredentialsList
- */
- @GET
- @ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
- @Path("/support/password/list")
- ListenableFuture<Map<String, Credentials>> getServerCredentialsList();
-
- /**
- * @see GridServerClient#getServerCredentials
- */
- @GET
- @ResponseParser(ParseCredentialsFromJsonResponse.class)
- @Path("/support/grid/password/get")
- ListenableFuture<Credentials> getServerCredentials(@QueryParam("id") long id);
-
- /**
- * @see GridServerClient#addServer(String, String, String, String,
- * org.jclouds.gogrid.options.AddServerOptions...)
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/add")
- ListenableFuture<Server> addServer(@QueryParam(NAME_KEY) String name,
- @QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
- @QueryParam(IP_KEY) String ip, AddServerOptions... addServerOptions);
-
- /**
- * @see GridServerClient#power(String, org.jclouds.gogrid.domain.PowerCommand)
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/power")
- ListenableFuture<Server> power(
- @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName,
- @QueryParam(POWER_KEY) PowerCommand power);
-
- /**
- * @see GridServerClient#deleteById(Long)
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/delete")
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Server> deleteById(@QueryParam(ID_KEY) long id);
-
- /**
- * @see GridServerClient#deleteByName(String)
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/delete")
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Server> deleteByName(@QueryParam(NAME_KEY) String name);
-
- /**
- * @see GridServerClient#getRamSizes
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
- ListenableFuture<Set<Option>> getRamSizes();
-
- /**
- * @see GridServerClient#getTypes
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.type")
- ListenableFuture<Set<Option>> getTypes();
-
- /**
- * @see GridServerClient#getDatacenters
- */
- @GET
- @ResponseParser(ParseOptionsFromJsonResponse.class)
- @Path("/common/lookup/list")
- @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
- ListenableFuture<Set<Option>> getDatacenters();
-
-
- /**
- * @see GridServerClient#editServerDescription
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/edit")
- ListenableFuture<Server> editServerDescription(@QueryParam("id") long id,
- @QueryParam("description") String newDescription);
-
- /**
- * @see GridServerClient#editServerRam
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/edit")
- ListenableFuture<Server> editServerRam(@QueryParam("id") long id,
- @QueryParam("server.ram") String ram);
-
- /**
- * @see GridServerClient#editServerType
- */
- @GET
- @SelectJson("list")
- @OnlyElement
- @Path("/grid/server/edit")
- ListenableFuture<Server> editServerType(@QueryParam("id") long id,
- @QueryParam("server.type") String newType);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerClient.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerClient.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerClient.java
deleted file mode 100644
index 5318e70..0000000
--- a/providers/gogrid/src/main/java/org/jclouds/gogrid/services/GridServerClient.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import java.util.Map;
-import java.util.Set;
-import org.jclouds.domain.Credentials;
-import org.jclouds.gogrid.domain.Option;
-import org.jclouds.gogrid.domain.PowerCommand;
-import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.options.AddServerOptions;
-import org.jclouds.gogrid.options.GetServerListOptions;
-
-/**
- * Provides synchronous access to GoGrid.
- * <p/>
- *
- * @see GridServerAsyncClient
- * @see <a href="http://wiki.gogrid.com/wiki/index.php/API" />
- *
- * @author Adrian Cole
- * @author Oleksiy Yarmula
- */
-public interface GridServerClient {
-
- /**
- * Returns the list of all servers.
- *
- * The result can be narrowed down by providing the options.
- *
- * @param getServerListOptions
- * options to narrow down the result
- * @return servers found by the request
- */
- Set<Server> getServerList(GetServerListOptions... getServerListOptions);
-
- /**
- * Returns the server(s) by unique name(s).
- *
- * Given a name or a set of names, finds one or multiple servers.
- *
- * @param names
- * to get the servers
- * @return server(s) matching the name(s)
- */
- Set<Server> getServersByName(String... names);
-
- /**
- * Returns the server(s) by unique id(s).
- *
- * Given an id or a set of ids, finds one or multiple servers.
- *
- * @param ids
- * to get the servers
- * @return server(s) matching the ids
- */
- Set<Server> getServersById(long... ids);
-
- /**
- * Returns a map of running servers' names to the log in credentials.
- *
- * @return map <String server name => Credentials>
- */
- Map<String, Credentials> getServerCredentialsList();
-
- /**
- *
- * @return the login user and password of a server, or null if none found
- */
- Credentials getServerCredentials(long id);
-
- /**
- * Adds a server with specified attributes
- *
- * @param name
- * name of the server
- * @param image
- * image (id or name)
- * @param ram
- * ram type (id or name)
- * @param ip
- * ip address
- * @param addServerOptions
- * options to make it a sandbox instance or/and description
- * @return created server
- */
- Server addServer(String name, String image, String ram, String ip,
- AddServerOptions... addServerOptions);
-
- /**
- * Changes the server's state according to {@link PowerCommand}
- *
- * @param idOrName
- * id or name of the server to apply the command
- * @param power
- * new desired state
- * @return server immediately after applying the command
- */
- Server power(String idOrName, PowerCommand power);
-
- /**
- * Deletes the server by Id
- *
- * @param id
- * id of the server to delete
- * @return server before the command is executed
- */
- Server deleteById(long id);
-
- /**
- * Deletes the server by name;
- *
- * NOTE: Using this parameter may generate an error if one or more servers
- * share a non-unique name.
- *
- * @param name
- * name of the server to be deleted
- *
- * @return server before the command is executed
- */
- Server deleteByName(String name);
-
- /**
- * Edits an existing server
- *
- * @param id
- * id of the existing server
- * @param newDescription
- * description to replace the current one
- * @return edited server
- */
- Server editServerDescription(long id, String newDescription);
-
- /**
- * Edits an existing server
- *
- * @param id
- * id of the existing server
- * @param idOrNameOfType
- * type to replace the current one
- * @return edited server
- */
- Server editServerType(long id, String idOrNameOfType);
-
- /**
- * Edits an existing server
- *
- * @param id
- * id of the existing server
- * @param idOrNameOfRam
- * ram to replace the current one
- * @return edited server
- */
- Server editServerRam(long id, String idOrNameOfRam);
-
- /**
- * Retrieves the list of supported RAM configurations. The objects will have
- * RAM ID, name and description. In most cases, id or name will be used for
- * {@link #addServer}.
- *
- * To see how RAM maps to CPU and disk space (as of March 2010), see
- * {@link org.jclouds.gogrid.compute.config.GoGridComputeServiceContextModule#provideSizeToRam}
- * .
- *
- * @return supported ram sizes
- */
- Set<Option> getRamSizes();
-
- /**
- * Retrieves the list of supported server types, for example Web/App Server and Database Server. In most cases, id
- * or name will be used for {@link #editServerType}.
- *
- * @return supported server types
- */
- Set<Option> getTypes();
-
- /**
- * Retrieves the list of supported Datacenters to launch servers into. The
- * objects will have datacenter ID, name and description. In most cases, id
- * or name will be used for {@link #addServer}.
- *
- * @return supported datacenters
- */
- Set<Option> getDatacenters();
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java
new file mode 100644
index 0000000..0691a5d
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridApiTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutionException;
+
+import org.jclouds.gogrid.features.BaseGoGridApiTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code GoGridApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GoGridApiTest")
+public class GoGridApiTest extends BaseGoGridApiTest<GoGridApi> {
+
+ private GoGridApi syncClient;
+
+ public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException,
+ ExecutionException {
+ assert syncClient.getImageServices() != null;
+ assert syncClient.getIpServices() != null;
+ assert syncClient.getJobServices() != null;
+ assert syncClient.getLoadBalancerServices() != null;
+ assert syncClient.getServerServices() != null;
+ }
+
+ @BeforeClass
+ @Override
+ protected void setupFactory() throws IOException {
+ super.setupFactory();
+ syncClient = injector.getInstance(GoGridApi.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java
deleted file mode 100644
index 24ec1c5..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridAsyncClientTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-
-import org.jclouds.gogrid.services.BaseGoGridAsyncClientTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code GoGridAsyncClient}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GoGridAsyncClientTest")
-public class GoGridAsyncClientTest extends BaseGoGridAsyncClientTest<GoGridAsyncClient> {
-
- private GoGridAsyncClient asyncClient;
- private GoGridClient syncClient;
-
- public void testSync() throws SecurityException, NoSuchMethodException, InterruptedException,
- ExecutionException {
- assert syncClient.getImageServices() != null;
- assert syncClient.getIpServices() != null;
- assert syncClient.getJobServices() != null;
- assert syncClient.getLoadBalancerServices() != null;
- assert syncClient.getServerServices() != null;
- }
-
- public void testAsync() throws SecurityException, NoSuchMethodException, InterruptedException,
- ExecutionException {
- assert asyncClient.getImageServices() != null;
- assert asyncClient.getIpServices() != null;
- assert asyncClient.getJobServices() != null;
- assert asyncClient.getLoadBalancerServices() != null;
- assert asyncClient.getServerServices() != null;
- }
-
- @BeforeClass
- @Override
- protected void setupFactory() throws IOException {
- super.setupFactory();
- asyncClient = injector.getInstance(GoGridAsyncClient.class);
- syncClient = injector.getInstance(GoGridClient.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java
index 0fa2057..6111c23 100644
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java
@@ -72,7 +72,7 @@ import com.google.inject.Guice;
* @author Oleksiy Yarmula
*/
@Test(enabled = false, groups = "live", singleThreaded = true, testName = "GoGridLiveTestDisabled")
-public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridClient> {
+public class GoGridLiveTestDisabled extends BaseApiLiveTest<GoGridApi> {
public GoGridLiveTestDisabled() {
provider = "gogrid";
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java
index 0b4ba2d..2ab7a87 100644
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java
@@ -28,7 +28,7 @@ import static org.testng.Assert.assertNotNull;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
-import org.jclouds.gogrid.GoGridClient;
+import org.jclouds.gogrid.GoGridApi;
import org.jclouds.gogrid.domain.Server;
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
import org.jclouds.sshj.config.SshjSshClientModule;
@@ -68,7 +68,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public void testResizeRam() throws Exception {
String group = this.group + "ram";
- GoGridClient api = view.utils().injector().getInstance(GoGridClient.class);
+ GoGridApi api = view.utils().injector().getInstance(GoGridApi.class);
try {
client.destroyNodesMatching(inGroup(group));
} catch (Exception e) {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java
new file mode 100644
index 0000000..9f96e26
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiLiveTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.gogrid.GoGridApi;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@code GoGridApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "BaseGoGridApiLiveTest")
+public class BaseGoGridApiLiveTest extends BaseApiLiveTest<GoGridApi> {
+ public BaseGoGridApiLiveTest() {
+ provider = "gogrid";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java
new file mode 100644
index 0000000..dbd0b16
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridApiTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.date.TimeStamp;
+import org.jclouds.gogrid.GoGridProviderMetadata;
+import org.jclouds.gogrid.config.GoGridHttpApiModule;
+import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Module;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit")
+public abstract class BaseGoGridApiTest<T> extends BaseAsyncClientTest<T> {
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), SharedKeyLiteAuthentication.class);
+ }
+
+ @ConfiguresRestClient
+ protected static final class TestGoGridHttpApiModule extends GoGridHttpApiModule {
+ @Override
+ protected void configure() {
+ super.configure();
+ }
+
+ @Override
+ protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
+ return 1267243795L;
+ }
+ }
+
+ @Override
+ protected Module createModule() {
+ return new TestGoGridHttpApiModule();
+ }
+
+ @Override
+ public ProviderMetadata createProviderMetadata() {
+ return new GoGridProviderMetadata();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridHttpApiExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridHttpApiExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridHttpApiExpectTest.java
new file mode 100644
index 0000000..eaf7bb1
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/BaseGoGridHttpApiExpectTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import org.jclouds.date.TimeStamp;
+import org.jclouds.gogrid.GoGridApi;
+import org.jclouds.gogrid.config.GoGridHttpApiModule;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.internal.BaseRestClientExpectTest;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Module;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class BaseGoGridHttpApiExpectTest extends BaseRestClientExpectTest<GoGridApi> {
+
+ public BaseGoGridHttpApiExpectTest() {
+ provider = "gogrid";
+ }
+
+ @ConfiguresRestClient
+ protected static final class TestGoGridHttpApiModule extends GoGridHttpApiModule {
+
+ @Override
+ protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
+ return 1267243795L;
+ }
+ }
+
+ @Override
+ protected Module createModule() {
+ return new TestGoGridHttpApiModule();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiLiveTest.java
new file mode 100644
index 0000000..556d7e8
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiLiveTest.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.jclouds.gogrid.domain.Ip;
+import org.jclouds.gogrid.domain.Server;
+import org.jclouds.gogrid.domain.ServerImage;
+import org.jclouds.gogrid.domain.ServerImageState;
+import org.jclouds.gogrid.options.SaveImageOptions;
+import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "GridImageApiLiveTest")
+public class GridImageApiLiveTest extends BaseGoGridApiLiveTest {
+
+ public void testListImages() throws Exception {
+ Set<ServerImage> response = api.getImageServices().getImageList();
+ assert null != response;
+ for (ServerImage image : response) {
+ assert image.getId() >= 0 : image;
+ checkImage(image);
+
+ ServerImage query = Iterables.getOnlyElement(api.getImageServices()
+ .getImagesById(image.getId()));
+ assertEquals(query.getId(), image.getId());
+
+ checkImage(query);
+ }
+ }
+
+ private void checkImage(ServerImage image) {
+ assert image.getArchitecture() != null : image;
+ assert image.getBillingTokens() != null : image;
+ if (image.getCreatedTime() == null)
+ Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdTime field");
+ assert image.getDescription() != null : image;
+ assert image.getFriendlyName() != null : image;
+ assert image.getId() >= 0 : image;
+ assert image.getLocation() != null : image;
+ assert image.getName() != null : image;
+ assert image.getOs() != null : image;
+ assert image.getOwner() != null : image;
+ assert image.getPrice() >= 0 : image;
+ assert image.getState() != null : image;
+ assert image.getType() != null : image;
+ if (image.getUpdatedTime() == null)
+ Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedTime field");
+ }
+
+ @Test
+ public void testSaveServerToImage() throws IOException {
+ Predicate<Server> serverLatestJobCompleted = retry(new ServerLatestJobCompleted(api
+ .getJobServices()), 800, 20, SECONDS);
+
+ final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
+ ServerImage image = null;
+ try {
+ Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
+ Ip availableIp = Iterables.getLast(availableIps);
+
+ Server createdServer = api.getServerServices()
+ .addServer(nameOfServer, "5489", "1", availableIp.getIp());
+ assertNotNull(createdServer);
+ assert serverLatestJobCompleted.apply(createdServer);
+ image = api
+ .getImageServices()
+ .saveImageFromServer("friendlyName", createdServer.getName(),
+ SaveImageOptions.Builder.withDescription("description"));
+
+ assertEquals(image.getFriendlyName(), "friendlyName");
+ assertEquals(image.getDescription(), "description");
+ assertFalse(image.isPublic());
+
+ assertEventuallyImageStateEquals(image, ServerImageState.AVAILABLE);
+
+ api.getImageServices().deleteById(image.getId());
+
+ assertEventuallyImageStateEquals(image, ServerImageState.TRASH);
+
+ image = null;
+ } finally {
+ if (image != null)
+ try {
+ api.getImageServices().deleteById(image.getId());
+ } catch (Exception e) {
+ // not failing so that we can ensure server below deletes
+ e.printStackTrace();
+ }
+ // delete the server
+ api.getServerServices().deleteByName(nameOfServer);
+ }
+
+ }
+
+ protected void assertEventuallyImageStateEquals(ServerImage image, final ServerImageState state) {
+ assertTrue(retry(new Predicate<ServerImage>() {
+ public boolean apply(ServerImage input) {
+ return Iterables.getOnlyElement(api.getImageServices().getImagesById(input.getId()))
+ .getState() == state;
+ }
+ }, 600, 1, SECONDS).apply(image));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java
new file mode 100644
index 0000000..9b1a45b
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridImageApiTest.java
@@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.gogrid.domain.ServerImageState;
+import org.jclouds.gogrid.domain.ServerImageType;
+import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
+import org.jclouds.gogrid.options.GetImageListOptions;
+import org.jclouds.gogrid.options.SaveImageOptions;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridImageApi}
+ *
+ * @author Oleksiy Yarmula
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during
+// surefire
+@Test(groups = "unit", testName = "GridImageApiTest")
+public class GridImageApiTest extends BaseGoGridApiTest<GridImageApi> {
+
+ @Test
+ public void testGetImageListWithOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "getImageList", GetImageListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(
+ method, ImmutableList.<Object> of(
+ new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE)
+ .setType(ServerImageType.WEB_APPLICATION_SERVER)));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?v=1.5&"
+ + "isPublic=true&image.state=Available&" + "image.type=Web%20Server HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?"
+ + "v=1.5&isPublic=true&image.state=Available&" + "image.type=Web%20Server&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetImagesByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "getImagesByName", String[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name1", "name2"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
+ + "name=name1&name=name2 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
+ + "name=name1&name=name2&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditImageDescription() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "editImageDescription", String.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newDesc"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
+ + "image=imageName&description=newDesc HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
+ + "image=imageName&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditImageFriendlyName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "editImageFriendlyName", String.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newFriendlyName"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
+ + "image=imageName&friendlyName=newFriendlyName HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
+ + "image=imageName&friendlyName=newFriendlyName&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity "
+ + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testDeleteById() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "deleteById", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+ }
+
+ @Test
+ public void testSaveImageFromServerNoOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "saveImageFromServer", String.class, String.class,
+ SaveImageOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName"));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ }
+
+ @Test
+ public void testSaveImageOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridImageApi.class, "saveImageFromServer", String.class, String.class,
+ SaveImageOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName",
+ new SaveImageOptions().withDescription("fooy")));
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName&description=fooy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java
new file mode 100644
index 0000000..cf08247
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridIpApiTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.gogrid.domain.IpType;
+import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
+import org.jclouds.gogrid.options.GetIpListOptions;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridIpApi}
+ *
+ * @author Oleksiy Yarmula
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridIpApiTest")
+public class GridIpApiTest extends BaseGoGridApiTest<GridIpApi> {
+
+ @Test
+ public void testGetIpListWithOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridIpApi.class, "getIpList", GetIpListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(new GetIpListOptions()
+ .onlyUnassigned().onlyWithType(IpType.PUBLIC)));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
+ + "ip.type=Public HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
+ + "ip.type=Public&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetAssignedIpList() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridIpApi.class, "getAssignedIpList");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java
new file mode 100644
index 0000000..ad7a467
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiLiveTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Set;
+
+import org.jclouds.gogrid.domain.Job;
+import org.jclouds.gogrid.options.GetJobListOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridJobApiLiveTest")
+public class GridJobApiLiveTest extends BaseGoGridApiLiveTest {
+
+ public void testListJobs() throws Exception {
+ Set<Job> response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10));
+ assert null != response;
+ assert response.size() <= 10 : response;
+ for (Job job : response) {
+ assert job.getId() >= 0 : job;
+ checkJob(job);
+
+ Job query = Iterables.getOnlyElement(api.getJobServices().getJobsById(job.getId()));
+ assertEquals(query.getId(), job.getId());
+
+ checkJob(query);
+ }
+ }
+
+ private void checkJob(Job job) {
+ assert job.getAttempts() >= 0 : job;
+ assert job.getCommand() != null : job;
+ assert job.getCreatedOn() != null : job;
+ assert job.getCreatedOn() != null : job;
+ assert job.getDetails() != null : job;
+ assert job.getHistory() != null : job;
+ assert job.getId() >= 0 : job;
+ assert job.getLastUpdatedOn() != null : job;
+ assert job.getObjectType() != null : job;
+ assert job.getOwner() != null : job;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java
new file mode 100644
index 0000000..1d0b5e6
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridJobApiTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate;
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.util.Date;
+
+import org.jclouds.gogrid.domain.JobState;
+import org.jclouds.gogrid.domain.ObjectType;
+import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
+import org.jclouds.gogrid.options.GetJobListOptions;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridJobApi}
+ *
+ * @author Oleksiy Yarmula
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridJobApiTest")
+public class GridJobApiTest extends BaseGoGridApiTest<GridJobApi> {
+
+ @Test
+ public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridJobApi.class, "getJobList", GetJobListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor
+ .createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
+ .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING)));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
+ + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
+ + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetJobListNoOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridJobApi.class, "getJobList", GetJobListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetJobsForServerName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridJobApi.class, "getJobsForObjectName", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("MyServer"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
+ + "object=MyServer HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
+ + "object=MyServer&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetJobsById() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridJobApi.class, "getJobsById", long[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L, 456L));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
+ + "id=123&id=456 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
+ + "id=123&id=456&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java
new file mode 100644
index 0000000..6fc3b25
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridLoadBalancerApiTest.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.jclouds.gogrid.domain.Ip;
+import org.jclouds.gogrid.domain.IpPortPair;
+import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
+import org.jclouds.gogrid.domain.LoadBalancerType;
+import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
+import org.jclouds.gogrid.options.AddLoadBalancerOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridLoadBalancerApi}
+ *
+ * @author Oleksiy Yarmula
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridLoadBalancerApiTest")
+public class GridLoadBalancerApiTest extends BaseGoGridApiTest<GridLoadBalancerApi> {
+
+ @Test
+ public void testGetLoadBalancerList() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "getLoadBalancerList");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ HttpRequest addLoadBalancer = HttpRequest.builder().method("GET")
+ .endpoint("https://api.gogrid.com/api/grid/loadbalancer/add")
+ .addQueryParam("v", "1.5")
+ .addQueryParam("name", "BalanceIt")
+ .addQueryParam("loadbalancer.type", "Least Connect")
+ .addQueryParam("loadbalancer.persistence", "SSL Sticky")
+ .addQueryParam("virtualip.ip", "127.0.0.1")
+ .addQueryParam("virtualip.port", "80")
+ .addQueryParam("realiplist.0.ip", "127.0.0.1")
+ .addQueryParam("realiplist.0.port", "8080")
+ .addQueryParam("realiplist.1.ip", "127.0.0.1")
+ .addQueryParam("realiplist.1.port", "9090")
+ .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
+ .addQueryParam("api_key", "identity").build();
+
+ @Test
+ public void testAddLoadBalancer() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "addLoadBalancer", String.class, IpPortPair.class,
+ List.class, AddLoadBalancerOptions[].class);
+ GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt",
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(),
+ ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()),
+ new AddLoadBalancerOptions.Builder().create(
+ LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY)));
+
+ request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
+
+ assertRequestLineEquals(request, addLoadBalancer.getRequestLine());
+ assertNonPayloadHeadersEqual(request, "");
+ assertPayloadEquals(request, null, null, false);
+
+ assertResponseParserClassEquals(method, request, ParseLoadBalancerFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(request);
+ }
+
+ @Test
+ public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "editLoadBalancer", long.class, List.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1l, ImmutableList.of(
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&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");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "editLoadBalancerNamed", String.class, List.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", ImmutableList.of(
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
+ IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ + "edit?v=1.5&name=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");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(
+ httpRequest,
+ "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "getLoadBalancersByName", String[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ "My Load Balancer", "My Load Balancer 2"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridLoadBalancerApi.class, "deleteById", Long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(55L));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
+ + "delete?v=1.5&id=55 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" + "delete?v=1.5&id=55&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+}
[06/10] Remove async from gogrid
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
new file mode 100644
index 0000000..be06c8d
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.gogrid.domain.PowerCommand;
+import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.options.GetServerListOptions;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridServerApi}
+ *
+ * @author Oleksiy Yarmula, Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridServerApiTest")
+public class GridServerApiTest extends BaseGoGridApiTest<GridServerApi> {
+
+ @Test
+ public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServerList", GetServerListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ new GetServerListOptions.Builder().onlySandboxServers()));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/server/list?v=1.6&isSandbox=true HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
+ + "v=1.6&isSandbox=true&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetServersByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServersByName", String[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("server1"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&name=server1&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetServersById() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServersById", long[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&id=123&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+
+ @Test
+ public void testPowerServer() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "power", String.class, PowerCommand.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer",
+ PowerCommand.RESTART));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
+ + "server=PowerServer&power=restart " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
+ + "server=PowerServer&power=restart&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testDeleteByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "deleteByName", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
+ + "name=PowerServer " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
+ + "name=PowerServer&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetRamSizes() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getRamSizes");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram "
+ + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testServerCredentials() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServerCredentials", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/support/grid/password/get?v=1.6&id=1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseCredentialsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+ }
+
+ @Test
+ public void testTypes() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getTypes");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.type HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+ }
+
+ @Test
+ public void testEditServerDescription() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerDescription", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "newDesc"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&description=newDesc HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditServerRam() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerRam", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "1GB"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.ram=1GB HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.ram=1GB&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditServerType() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerType", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "web"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.type=web HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.type=web&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
new file mode 100644
index 0000000..bdcf3e6
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.gogrid.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.net.URI;
+
+import org.jclouds.gogrid.GoGridApi;
+import org.jclouds.gogrid.options.AddServerOptions;
+import org.jclouds.gogrid.options.GetServerListOptions;
+import org.jclouds.gogrid.parse.ParseServerListTest;
+import org.jclouds.gogrid.parse.ParseServerTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "GridServerClientExpectTest")
+public class GridServerClientExpectTest extends BaseGoGridHttpApiExpectTest {
+
+ HttpRequest addServer = HttpRequest.builder().method("GET")
+ .endpoint("https://api.gogrid.com/api/grid/server/add")
+ .addQueryParam("v", "1.6")
+ .addQueryParam("name", "serverName")
+ .addQueryParam("image", "img55")
+ .addQueryParam("server.ram", "memory")
+ .addQueryParam("ip", "127.0.0.1")
+ .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
+ .addQueryParam("api_key", "identity").build();
+
+ public void testAddServerWhenResponseIs2xx() throws Exception {
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi addServerWorked = requestSendsResponse(addServer, listGridServersResponse);
+
+ assertEquals(addServerWorked.getServerServices().addServer("serverName", "img55", "memory", "127.0.0.1")
+ .toString(), new ParseServerTest().expected().toString());
+ }
+
+ HttpRequest addServerOptions = HttpRequest.builder().method("GET")
+ .endpoint("https://api.gogrid.com/api/grid/server/add")
+ .addQueryParam("v", "1.6")
+ .addQueryParam("name", "serverName")
+ .addQueryParam("image", "img55")
+ .addQueryParam("server.ram", "memory")
+ .addQueryParam("ip", "127.0.0.1")
+ .addQueryParam("isSandbox", "true")
+ .addQueryParam("description", "fooy")
+ .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
+ .addQueryParam("api_key", "identity").build();
+
+ public void testAddServerWithOptionsWhenResponseIs2xx() throws Exception {
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi addServerWithOptionsWorked = requestSendsResponse(addServerOptions, listGridServersResponse);
+
+ assertEquals(addServerWithOptionsWorked.getServerServices().addServer("serverName", "img55", "memory",
+ "127.0.0.1", new AddServerOptions().asSandboxType().withDescription("fooy")).toString(),
+ new ParseServerTest().expected().toString());
+ }
+
+ public void testGetServerListWhenResponseIs2xx() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertEquals(clientWhenGridServersExist.getServerServices().getServerList().toString(), new ParseServerListTest()
+ .expected().toString());
+ }
+
+ public void testGetServerListWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload(
+ payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
+
+ GoGridApi clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty());
+ }
+
+ public void testGetServerListWithOptionsWhenResponseIs2xx() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&isSandbox=true&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertEquals(clientWhenGridServersExist.getServerServices().getServerList(
+ new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest()
+ .expected().toString());
+ }
+
+ public void testGetServerCredentialsWhenNotFoundThrowsResourceNotFoundExceptionWithNiceMessage() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/support/grid/password/get?" + "v=1.6&id=11&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload(
+ payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
+ try {
+ clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
+ fail("should have failed");
+ } catch (ResourceNotFoundException e) {
+ assertEquals(e.getMessage(), "No object found that matches your input criteria.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
index 44f2479..1f5f03b 100644
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
@@ -25,7 +25,7 @@ import static org.testng.Assert.assertTrue;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.services.GridJobClient;
+import org.jclouds.gogrid.features.GridJobApi;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@@ -46,7 +46,7 @@ public class ServerLatestJobCompletedTest {
Job job = createMock(Job.class);
expect(job.getCurrentState()).andReturn(JobState.SUCCEEDED);
- GridJobClient client = createMock(GridJobClient.class);
+ GridJobApi client = createMock(GridJobApi.class);
expect(client.getJobList(latestJobForObjectByName(serverName))).andReturn(ImmutableSet.<Job> of(job));
replay(job);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
deleted file mode 100644
index f498fd5..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.date.TimeStamp;
-import org.jclouds.gogrid.GoGridProviderMetadata;
-import org.jclouds.gogrid.config.GoGridRestClientModule;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public abstract class BaseGoGridAsyncClientTest<T> extends BaseAsyncClientTest<T> {
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), SharedKeyLiteAuthentication.class);
- }
-
- @ConfiguresRestClient
- protected static final class TestGoGridRestClientModule extends GoGridRestClientModule {
- @Override
- protected void configure() {
- super.configure();
- }
-
- @Override
- protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
- return 1267243795L;
- }
- }
-
- @Override
- protected Module createModule() {
- return new TestGoGridRestClientModule();
- }
-
- @Override
- public ProviderMetadata createProviderMetadata() {
- return new GoGridProviderMetadata();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
deleted file mode 100644
index a92b3f0..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import org.jclouds.apis.BaseApiLiveTest;
-import org.jclouds.gogrid.GoGridClient;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code GoGridClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest")
-public class BaseGoGridClientLiveTest extends BaseApiLiveTest<GoGridClient> {
- public BaseGoGridClientLiveTest() {
- provider = "gogrid";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
deleted file mode 100644
index 8135e44..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import org.jclouds.date.TimeStamp;
-import org.jclouds.gogrid.GoGridClient;
-import org.jclouds.gogrid.config.GoGridRestClientModule;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.internal.BaseRestClientExpectTest;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoGridClient> {
-
- public BaseGoGridRestClientExpectTest() {
- provider = "gogrid";
- }
-
- @ConfiguresRestClient
- protected static final class TestGoGridRestClientModule extends GoGridRestClientModule {
-
- @Override
- protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
- return 1267243795L;
- }
- }
-
- @Override
- protected Module createModule() {
- return new TestGoGridRestClientModule();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
deleted file mode 100644
index a52b8c8..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.gogrid.domain.ServerImageState;
-import org.jclouds.gogrid.domain.ServerImageType;
-import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
-import org.jclouds.gogrid.options.GetImageListOptions;
-import org.jclouds.gogrid.options.SaveImageOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridImageAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "GridImageAsyncClientTest")
-public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImageAsyncClient> {
-
- @Test
- public void testGetImageListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImageList", GetImageListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(
- method, ImmutableList.<Object> of(
- new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE)
- .setType(ServerImageType.WEB_APPLICATION_SERVER)));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?v=1.5&"
- + "isPublic=true&image.state=Available&" + "image.type=Web%20Server HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?"
- + "v=1.5&isPublic=true&image.state=Available&" + "image.type=Web%20Server&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetImagesByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImagesByName", String[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name1", "name2"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
- + "name=name1&name=name2 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
- + "name=name1&name=name2&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditImageDescription() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageDescription", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newDesc"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&description=newDesc HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditImageFriendlyName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageFriendlyName", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newFriendlyName"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&friendlyName=newFriendlyName HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&friendlyName=newFriendlyName&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity "
- + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testDeleteById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "deleteById", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
- }
-
- @Test
- public void testSaveImageFromServerNoOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class,
- SaveImageOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName"));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- }
-
- @Test
- public void testSaveImageOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class,
- SaveImageOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName",
- new SaveImageOptions().withDescription("fooy")));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName&description=fooy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
deleted file mode 100644
index 188a2ba..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.domain.ServerImage;
-import org.jclouds.gogrid.domain.ServerImageState;
-import org.jclouds.gogrid.options.SaveImageOptions;
-import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "GridImageClientLiveTest")
-public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
-
- public void testListImages() throws Exception {
- Set<ServerImage> response = api.getImageServices().getImageList();
- assert null != response;
- for (ServerImage image : response) {
- assert image.getId() >= 0 : image;
- checkImage(image);
-
- ServerImage query = Iterables.getOnlyElement(api.getImageServices()
- .getImagesById(image.getId()));
- assertEquals(query.getId(), image.getId());
-
- checkImage(query);
- }
- }
-
- private void checkImage(ServerImage image) {
- assert image.getArchitecture() != null : image;
- assert image.getBillingTokens() != null : image;
- if (image.getCreatedTime() == null)
- Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdTime field");
- assert image.getDescription() != null : image;
- assert image.getFriendlyName() != null : image;
- assert image.getId() >= 0 : image;
- assert image.getLocation() != null : image;
- assert image.getName() != null : image;
- assert image.getOs() != null : image;
- assert image.getOwner() != null : image;
- assert image.getPrice() >= 0 : image;
- assert image.getState() != null : image;
- assert image.getType() != null : image;
- if (image.getUpdatedTime() == null)
- Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedTime field");
- }
-
- @Test
- public void testSaveServerToImage() throws IOException {
- Predicate<Server> serverLatestJobCompleted = retry(new ServerLatestJobCompleted(api
- .getJobServices()), 800, 20, SECONDS);
-
- final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
- ServerImage image = null;
- try {
- Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
- Ip availableIp = Iterables.getLast(availableIps);
-
- Server createdServer = api.getServerServices()
- .addServer(nameOfServer, "5489", "1", availableIp.getIp());
- assertNotNull(createdServer);
- assert serverLatestJobCompleted.apply(createdServer);
- image = api
- .getImageServices()
- .saveImageFromServer("friendlyName", createdServer.getName(),
- SaveImageOptions.Builder.withDescription("description"));
-
- assertEquals(image.getFriendlyName(), "friendlyName");
- assertEquals(image.getDescription(), "description");
- assertFalse(image.isPublic());
-
- assertEventuallyImageStateEquals(image, ServerImageState.AVAILABLE);
-
- api.getImageServices().deleteById(image.getId());
-
- assertEventuallyImageStateEquals(image, ServerImageState.TRASH);
-
- image = null;
- } finally {
- if (image != null)
- try {
- api.getImageServices().deleteById(image.getId());
- } catch (Exception e) {
- // not failing so that we can ensure server below deletes
- e.printStackTrace();
- }
- // delete the server
- api.getServerServices().deleteByName(nameOfServer);
- }
-
- }
-
- protected void assertEventuallyImageStateEquals(ServerImage image, final ServerImageState state) {
- assertTrue(retry(new Predicate<ServerImage>() {
- public boolean apply(ServerImage input) {
- return Iterables.getOnlyElement(api.getImageServices().getImagesById(input.getId()))
- .getState() == state;
- }
- }, 600, 1, SECONDS).apply(image));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
deleted file mode 100644
index 1fa2ba8..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.gogrid.domain.IpType;
-import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
-import org.jclouds.gogrid.options.GetIpListOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridIpAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridIpAsyncClientTest")
-public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsyncClient> {
-
- @Test
- public void testGetIpListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridIpAsyncClient.class, "getIpList", GetIpListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(new GetIpListOptions()
- .onlyUnassigned().onlyWithType(IpType.PUBLIC)));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
- + "ip.type=Public HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
- + "ip.type=Public&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetAssignedIpList() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridIpAsyncClient.class, "getAssignedIpList");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
deleted file mode 100644
index 3a6973f..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate;
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.jclouds.gogrid.domain.JobState;
-import org.jclouds.gogrid.domain.ObjectType;
-import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
-import org.jclouds.gogrid.options.GetJobListOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridJobAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridJobAsyncClientTest")
-public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsyncClient> {
-
- @Test
- public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class);
- GeneratedHttpRequest httpRequest = processor
- .createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
- .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING)));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
- + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
- + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobListNoOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobsForServerName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsForObjectName", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("MyServer"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
- + "object=MyServer HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
- + "object=MyServer&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobsById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsById", long[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L, 456L));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
- + "id=123&id=456 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
- + "id=123&id=456&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java
deleted file mode 100644
index 4397611..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Set;
-
-import org.jclouds.gogrid.domain.Job;
-import org.jclouds.gogrid.options.GetJobListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-/**
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridJobClientLiveTest")
-public class GridJobClientLiveTest extends BaseGoGridClientLiveTest {
-
- public void testListJobs() throws Exception {
- Set<Job> response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10));
- assert null != response;
- assert response.size() <= 10 : response;
- for (Job job : response) {
- assert job.getId() >= 0 : job;
- checkJob(job);
-
- Job query = Iterables.getOnlyElement(api.getJobServices().getJobsById(job.getId()));
- assertEquals(query.getId(), job.getId());
-
- checkJob(query);
- }
- }
-
- private void checkJob(Job job) {
- assert job.getAttempts() >= 0 : job;
- assert job.getCommand() != null : job;
- assert job.getCreatedOn() != null : job;
- assert job.getCreatedOn() != null : job;
- assert job.getDetails() != null : job;
- assert job.getHistory() != null : job;
- assert job.getId() >= 0 : job;
- assert job.getLastUpdatedOn() != null : job;
- assert job.getObjectType() != null : job;
- assert job.getOwner() != null : job;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
deleted file mode 100644
index 911ee0c..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.IpPortPair;
-import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
-import org.jclouds.gogrid.domain.LoadBalancerType;
-import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
-import org.jclouds.gogrid.options.AddLoadBalancerOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridLoadBalancerAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridLoadBalancerAsyncClientTest")
-public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<GridLoadBalancerAsyncClient> {
-
- @Test
- public void testGetLoadBalancerList() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancerList");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- HttpRequest addLoadBalancer = HttpRequest.builder().method("GET")
- .endpoint("https://api.gogrid.com/api/grid/loadbalancer/add")
- .addQueryParam("v", "1.5")
- .addQueryParam("name", "BalanceIt")
- .addQueryParam("loadbalancer.type", "Least Connect")
- .addQueryParam("loadbalancer.persistence", "SSL Sticky")
- .addQueryParam("virtualip.ip", "127.0.0.1")
- .addQueryParam("virtualip.port", "80")
- .addQueryParam("realiplist.0.ip", "127.0.0.1")
- .addQueryParam("realiplist.0.port", "8080")
- .addQueryParam("realiplist.1.ip", "127.0.0.1")
- .addQueryParam("realiplist.1.port", "9090")
- .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
- .addQueryParam("api_key", "identity").build();
-
- @Test
- public void testAddLoadBalancer() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "addLoadBalancer", String.class, IpPortPair.class,
- List.class, AddLoadBalancerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt",
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(),
- ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()),
- new AddLoadBalancerOptions.Builder().create(
- LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY)));
-
- request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
-
- assertRequestLineEquals(request, addLoadBalancer.getRequestLine());
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Test
- public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancer", long.class, List.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1l, ImmutableList.of(
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&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");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancerNamed", String.class, List.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", ImmutableList.of(
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "edit?v=1.5&name=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");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancersByName", String[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- "My Load Balancer", "My Load Balancer 2"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "deleteById", Long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(55L));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "delete?v=1.5&id=55 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" + "delete?v=1.5&id=55&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
[02/10] git commit: Removed async from elasticstack
Posted by ab...@apache.org.
Removed async from elasticstack
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/a2af31c4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/a2af31c4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/a2af31c4
Branch: refs/heads/master
Commit: a2af31c419ed98fc704d98c9f9693fb3816d18eb
Parents: 1a6071a
Author: Andrew Bayer <an...@gmail.com>
Authored: Fri Aug 2 07:56:48 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Fri Aug 2 07:57:41 2013 -0700
----------------------------------------------------------------------
.../jclouds/elasticstack/ElasticStackApi.java | 343 ++++++++++++++
.../elasticstack/ElasticStackApiMetadata.java | 23 +-
.../elasticstack/ElasticStackAsyncClient.java | 259 -----------
.../elasticstack/ElasticStackClient.java | 237 ----------
.../ElasticStackComputeServiceAdapter.java | 9 +-
...ElasticStackComputeServiceContextModule.java | 6 +-
.../config/ElasticStackHttpApiModule.java | 90 ++++
.../config/ElasticStackRestClientModule.java | 91 ----
.../elasticstack/predicates/DriveClaimed.java | 6 +-
.../elasticstack/ElasticStackApiLiveTest.java | 350 ++++++++++++++
.../elasticstack/ElasticStackApiTest.java | 451 +++++++++++++++++++
.../ElasticStackAsyncClientTest.java | 451 -------------------
.../ElasticStackClientLiveTest.java | 350 --------------
.../ElasticHostsPeer1LosAngelesApiLiveTest.java | 32 ++
...asticHostsPeer1LosAngelesClientLiveTest.java | 32 --
...ElasticHostsBlueSquareLondonApiLiveTest.java | 31 ++
...sticHostsBlueSquareLondonClientLiveTest.java | 31 --
.../ElasticHostsPeer1LondonApiLiveTest.java | 31 ++
.../ElasticHostsPeer1LondonClientLiveTest.java | 31 --
.../ElasticHostsPeer1SanAntonioApiLiveTest.java | 31 ++
...asticHostsPeer1SanAntonioClientLiveTest.java | 31 --
.../ElasticHostsPeer1TorontoApiLiveTest.java | 31 ++
.../ElasticHostsPeer1TorontoClientLiveTest.java | 31 --
.../Go2CloudJohannesburg1ApiLiveTest.java | 31 ++
.../Go2CloudJohannesburg1ClientLiveTest.java | 31 --
.../OpenHostingEast1ApiLiveTest.java | 31 ++
.../OpenHostingEast1ClientLiveTest.java | 31 --
.../ServerloveManchesterApiLiveTest.java | 38 ++
.../ServerloveManchesterClientLiveTest.java | 38 --
.../SkaliCloudMalaysiaApiLiveTest.java | 31 ++
.../SkaliCloudMalaysiaClientLiveTest.java | 31 --
31 files changed, 1537 insertions(+), 1703 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java
new file mode 100644
index 0000000..bc6fe39
--- /dev/null
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApi.java
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elasticstack;
+
+import java.io.Closeable;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.elasticstack.binders.BindDriveDataToPlainTextString;
+import org.jclouds.elasticstack.binders.BindDriveToPlainTextString;
+import org.jclouds.elasticstack.binders.BindServerToPlainTextString;
+import org.jclouds.elasticstack.domain.Drive;
+import org.jclouds.elasticstack.domain.DriveData;
+import org.jclouds.elasticstack.domain.DriveInfo;
+import org.jclouds.elasticstack.domain.ImageConversionType;
+import org.jclouds.elasticstack.domain.Server;
+import org.jclouds.elasticstack.domain.ServerInfo;
+import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.elasticstack.functions.ReturnPayload;
+import org.jclouds.elasticstack.functions.SplitNewlines;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.io.Payload;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * Provides synchronous access to elasticstack via their REST API.
+ * <p/>
+ *
+ * @see <a href="TODO: insert URL of provider documentation" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Consumes(MediaType.TEXT_PLAIN)
+public interface ElasticStackApi extends Closeable {
+
+ /**
+ * list of server uuids in your account
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listServers();
+
+ /**
+ * Get all servers info
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
+ Set<ServerInfo> listServerInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/info")
+ ServerInfo getServerInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new server
+ *
+ * @param createServer
+ * @return newly created server
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/create/stopped")
+ ServerInfo createServer(
+ @BinderParam(BindServerToPlainTextString.class) Server createServer);
+
+ /**
+ * set server configuration
+ *
+ * @param uuid
+ * what server to change
+ * @param setServer
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/set")
+ ServerInfo setServerConfiguration(@PathParam("uuid") String uuid,
+ @BinderParam(BindServerToPlainTextString.class) Server setServer);
+
+ /**
+ * Destroy a server
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @POST
+ @Path("/servers/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Start a server
+ *
+ * @param uuid
+ * what to start
+ */
+ @POST
+ @Path("/servers/{uuid}/start")
+ void startServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Stop a server
+ * <p/>
+ * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
+ * status if it is persistent and is automatically destroyed otherwise.
+ *
+ * @param uuid
+ * what to stop
+ */
+ @POST
+ @Path("/servers/{uuid}/stop")
+ void stopServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Shutdown a server
+ * <p/>
+ * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
+ * persistent and is automatically destroyed otherwise.
+ * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
+ * ACPI power button signal.
+ *
+ * @param uuid
+ * what to shutdown
+ */
+ @POST
+ @Path("/servers/{uuid}/shutdown")
+ void shutdownServer(@PathParam("uuid") String uuid);
+
+
+ /**
+ * Reset a server
+ *
+ * @param uuid
+ * what to reset
+ */
+ @POST
+ @Path("/servers/{uuid}/reset")
+ void resetServer(@PathParam("uuid") String uuid);
+
+ /**
+ * list of drive uuids in your account
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listDrives();
+
+ /**
+ * Get all drives info
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
+ Set<DriveInfo> listDriveInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/info")
+ DriveInfo getDriveInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new drive
+ *
+ * @param createDrive
+ * required parameters: name, size
+ * @return newly created drive
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/create")
+ DriveInfo createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
+
+ /**
+ * set extra drive data
+ *
+ * @param uuid
+ * what drive to change
+ * @param setDrive
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/set")
+ DriveInfo setDriveData(@PathParam("uuid") String uuid,
+ @BinderParam(BindDriveDataToPlainTextString.class) DriveData setDrive);
+
+ /**
+ * Destroy a drive
+ *
+ * @param uuid
+ * what to delete
+ */
+ @POST
+ @Path("/drives/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyDrive(@PathParam("uuid") String uuid);
+
+ /**
+ * create and start a new server
+ *
+ * @param createServer
+ * @return newly created server
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/create")
+ ServerInfo createAndStartServer(
+ @BinderParam(BindServerToPlainTextString.class) Server createServer);
+
+ /**
+ * Image a drive from another drive. The actual imaging process is asynchronous, with progress
+ * reported via drive info.
+ *
+ * @param source
+ * drive to copy from
+ * @param destination
+ * drive to copy to
+ */
+ @POST
+ @Path("/drives/{destination}/image/{source}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void imageDrive(@PathParam("source") String source, @PathParam("destination") String destination);
+
+ /**
+ * @see #imageDrive(String, String)
+ * @param conversionType
+ * Supports 'gzip' or 'gunzip' conversions.
+ */
+ @POST
+ @Path("/drives/{destination}/image/{source}/{conversion}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void imageDrive(@PathParam("source") String source, @PathParam("destination") String destination,
+ @PathParam("conversion") ImageConversionType conversionType);
+
+ /**
+ * Read binary data from a drive
+ *
+ * @param uuid
+ * drive to read
+ * @param offset
+ * start at the specified offset in bytes
+ * @param size
+ * the specified size in bytes; must be <=4096k
+ * @return binary content of the drive.
+ */
+ @POST
+ @Consumes(MediaType.APPLICATION_OCTET_STREAM)
+ @Path("/drives/{uuid}/read/{offset}/{size}")
+ @ResponseParser(ReturnPayload.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ Payload readDrive(@PathParam("uuid") String uuid, @PathParam("offset") long offset,
+ @PathParam("size") long size);
+
+ /**
+ * Write binary data to a drive
+ *
+ * @param uuid
+ * drive to write
+ * @param content
+ * what to write.
+ * <ul>
+ * <li>Binary data (Content-Type: application/octet-stream)</li>
+ * <li>Supports raw data or Content-Encoding: gzip</li>
+ * <li>Does not support Transfer-Encoding: chunked</li>
+ * </ul>
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ @Path("/drives/{uuid}/write")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void writeDrive(@PathParam("uuid") String uuid, Payload content);
+
+ /**
+ * @see ElasticStackApi#writeDrive(String, Payload)
+ * @param offset
+ * the byte offset in the target drive at which to start writing, not an offset in the
+ * input stream.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_OCTET_STREAM)
+ @Path("/drives/{uuid}/write/{offset}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void writeDrive(@PathParam("uuid") String uuid, Payload content, @PathParam("offset") long offset);
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java
index 2e5f91a..ed42e7d 100644
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackApiMetadata.java
@@ -25,11 +25,10 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule;
-import org.jclouds.elasticstack.config.ElasticStackRestClientModule;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.elasticstack.config.ElasticStackHttpApiModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -37,17 +36,8 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class ElasticStackApiMetadata extends BaseRestApiMetadata {
+public class ElasticStackApiMetadata extends BaseHttpApiMetadata<ElasticStackApi> {
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(ElasticStackClient.class)} as
- * {@link ElasticStackAsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<ElasticStackClient, ElasticStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<ElasticStackClient, ElasticStackAsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -62,7 +52,7 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
// passwords are set post-boot, so auth failures are possible
// from a race condition applying the password set script
@@ -71,11 +61,10 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata {
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<ElasticStackApi, Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
- super(ElasticStackClient.class, ElasticStackAsyncClient.class);
id("elasticstack")
.name("ElasticStack API")
.identityName("UUID")
@@ -85,7 +74,7 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata {
.defaultEndpoint("https://api-lon-p.elastichosts.com")
.defaultProperties(ElasticStackApiMetadata.defaultProperties())
.view(typeToken(ComputeServiceContext.class))
- .defaultModules(ImmutableSet.<Class<? extends Module>>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class));
+ .defaultModules(ImmutableSet.<Class<? extends Module>>of(ElasticStackHttpApiModule.class, ElasticStackComputeServiceContextModule.class));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackAsyncClient.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackAsyncClient.java
deleted file mode 100644
index a348a83..0000000
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackAsyncClient.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elasticstack;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.elasticstack.binders.BindDriveDataToPlainTextString;
-import org.jclouds.elasticstack.binders.BindDriveToPlainTextString;
-import org.jclouds.elasticstack.binders.BindServerToPlainTextString;
-import org.jclouds.elasticstack.domain.Drive;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.DriveInfo;
-import org.jclouds.elasticstack.domain.ImageConversionType;
-import org.jclouds.elasticstack.domain.Server;
-import org.jclouds.elasticstack.domain.ServerInfo;
-import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
-import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
-import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
-import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
-import org.jclouds.elasticstack.functions.ReturnPayload;
-import org.jclouds.elasticstack.functions.SplitNewlines;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.io.Payload;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to elasticstack via their REST API.
- * <p/>
- *
- * @see ElasticStackClient
- * @see <a href="TODO: insert URL of provider documentation" />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(ElasticStackClient.class)} as
- * {@link ElasticStackAsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@RequestFilters(BasicAuthentication.class)
-@Consumes(MediaType.TEXT_PLAIN)
-public interface ElasticStackAsyncClient extends Closeable {
-
- /**
- * @see ElasticStackClient#listServers()
- */
- @GET
- @Path("/servers/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listServers();
-
- /**
- * @see ElasticStackClient#listServerInfo()
- */
- @GET
- @Path("/servers/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
- ListenableFuture<Set<ServerInfo>> listServerInfo();
-
- /**
- * @see ElasticStackClient#getServerInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/info")
- ListenableFuture<ServerInfo> getServerInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#createServer
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/create/stopped")
- ListenableFuture<ServerInfo> createServer(
- @BinderParam(BindServerToPlainTextString.class) Server createServer);
-
- /**
- * @see ElasticStackClient#setServerConfiguration
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/set")
- ListenableFuture<ServerInfo> setServerConfiguration(@PathParam("uuid") String uuid,
- @BinderParam(BindServerToPlainTextString.class) Server setServer);
-
- /**
- * @see ElasticStackClient#destroyServer
- */
- @POST
- @Path("/servers/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyServer(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#startServer
- */
- @POST
- @Path("/servers/{uuid}/start")
- ListenableFuture<Void> startServer(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#stopServer
- */
- @POST
- @Path("/servers/{uuid}/stop")
- ListenableFuture<Void> stopServer(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#shutdownServer
- */
- @POST
- @Path("/servers/{uuid}/shutdown")
- ListenableFuture<Void> shutdownServer(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#resetServer
- */
- @POST
- @Path("/servers/{uuid}/reset")
- ListenableFuture<Void> resetServer(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#listDrives()
- */
- @GET
- @Path("/drives/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listDrives();
-
- /**
- * @see ElasticStackClient#listDriveInfo()
- */
- @GET
- @Path("/drives/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
- ListenableFuture<Set<DriveInfo>> listDriveInfo();
-
- /**
- * @see ElasticStackClient#getDriveInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/info")
- ListenableFuture<DriveInfo> getDriveInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#createDrive
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/create")
- ListenableFuture<DriveInfo> createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
-
- /**
- * @see ElasticStackClient#setDriveData
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/set")
- ListenableFuture<DriveInfo> setDriveData(@PathParam("uuid") String uuid,
- @BinderParam(BindDriveDataToPlainTextString.class) DriveData setDrive);
-
- /**
- * @see ElasticStackClient#destroyDrive
- */
- @POST
- @Path("/drives/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyDrive(@PathParam("uuid") String uuid);
-
- /**
- * @see ElasticStackClient#createAndStartServer
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/create")
- ListenableFuture<ServerInfo> createAndStartServer(
- @BinderParam(BindServerToPlainTextString.class) Server createServer);
-
- /**
- * @see ElasticStackClient#imageDrive(String,String)
- */
- @POST
- @Path("/drives/{destination}/image/{source}")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> imageDrive(@PathParam("source") String source, @PathParam("destination") String destination);
-
- /**
- * @see ElasticStackClient#imageDrive(String,String,ImageConversionType)
- */
- @POST
- @Path("/drives/{destination}/image/{source}/{conversion}")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> imageDrive(@PathParam("source") String source, @PathParam("destination") String destination,
- @PathParam("conversion") ImageConversionType conversionType);
-
- /**
- * @see ElasticStackClient#readDrive
- */
- @POST
- @Consumes(MediaType.APPLICATION_OCTET_STREAM)
- @Path("/drives/{uuid}/read/{offset}/{size}")
- @ResponseParser(ReturnPayload.class)
- @Fallback(NullOnNotFoundOr404.class)
- ListenableFuture<Payload> readDrive(@PathParam("uuid") String uuid, @PathParam("offset") long offset,
- @PathParam("size") long size);
-
- /**
- * @see ElasticStackClient#writeDrive(String, Payload)
- */
- @POST
- @Produces(MediaType.APPLICATION_OCTET_STREAM)
- @Path("/drives/{uuid}/write")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> writeDrive(@PathParam("uuid") String uuid, Payload content);
-
- /**
- * @see ElasticStackClient#writeDrive(String, Payload, long)
- */
- @POST
- @Produces(MediaType.APPLICATION_OCTET_STREAM)
- @Path("/drives/{uuid}/write/{offset}")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> writeDrive(@PathParam("uuid") String uuid, Payload content, @PathParam("offset") long offset);
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackClient.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackClient.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackClient.java
deleted file mode 100644
index 5f4666d..0000000
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/ElasticStackClient.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elasticstack;
-
-import java.io.Closeable;
-import java.util.Set;
-import org.jclouds.elasticstack.domain.Drive;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.DriveInfo;
-import org.jclouds.elasticstack.domain.ImageConversionType;
-import org.jclouds.elasticstack.domain.Server;
-import org.jclouds.elasticstack.domain.ServerInfo;
-import org.jclouds.io.Payload;
-
-/**
- * Provides synchronous access to elasticstack.
- * <p/>
- *
- * @see ElasticStackAsyncClient
- * @see <a href="TODO: insert URL of elasticstack documentation" />
- * @author Adrian Cole
- */
-public interface ElasticStackClient extends Closeable {
- /**
- * list of server uuids in your account
- *
- * @return or empty set if no servers are found
- */
- Set<String> listServers();
-
- /**
- * Get all servers info
- *
- * @return or empty set if no servers are found
- */
- Set<? extends ServerInfo> listServerInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- ServerInfo getServerInfo(String uuid);
-
- /**
- * create a new server
- *
- * @param server
- * @return newly created server
- */
- ServerInfo createServer(Server server);
-
- /**
- * set server configuration
- *
- * @param uuid
- * what server to change
- * @param serverData
- * what values to change
- * @return new data
- */
- ServerInfo setServerConfiguration(String uuid, Server server);
-
- /**
- * Destroy a server
- *
- * @param uuid
- * what to destroy
- */
- void destroyServer(String uuid);
-
- /**
- * Start a server
- *
- * @param uuid
- * what to start
- */
- void startServer(String uuid);
-
- /**
- * Stop a server
- * <p/>
- * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
- * status if it is persistent and is automatically destroyed otherwise.
- *
- * @param uuid
- * what to stop
- */
- void stopServer(String uuid);
-
- /**
- * Shutdown a server
- * <p/>
- * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
- * persistent and is automatically destroyed otherwise.
- * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
- * ACPI power button signal.
- *
- * @param uuid
- * what to shutdown
- */
- void shutdownServer(String uuid);
-
- /**
- * Reset a server
- *
- * @param uuid
- * what to reset
- */
- void resetServer(String uuid);
-
- /**
- * list of drive uuids in your account
- *
- * @return or empty set if no drives are found
- */
- Set<String> listDrives();
-
- /**
- * Get all drives info
- *
- * @return or empty set if no drives are found
- */
- Set<? extends DriveInfo> listDriveInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- DriveInfo getDriveInfo(String uuid);
-
- /**
- * create a new drive
- *
- * @param createDrive
- * required parameters: name, size
- * @return newly created drive
- */
- DriveInfo createDrive(Drive createDrive);
-
- /**
- * set extra drive data
- *
- * @param uuid
- * what drive to change
- * @param driveData
- * what values to change
- * @return new data
- */
- DriveInfo setDriveData(String uuid, DriveData driveData);
-
- /**
- * Destroy a drive
- *
- * @param uuid
- * what to delete
- */
- void destroyDrive(String uuid);
-
- /**
- * create and start a new server
- *
- * @param server
- * @return newly created server
- */
- ServerInfo createAndStartServer(Server server);
-
- /**
- * Image a drive from another drive. The actual imaging process is asynchronous, with progress
- * reported via drive info.
- *
- * @param source
- * drive to copy from
- * @param destination
- * drive to copy to
- */
- void imageDrive(String source, String destination);
-
- /**
- * @see #imageDrive(String, String)
- * @param conversionType
- * Supports 'gzip' or 'gunzip' conversions.
- */
- void imageDrive(String source, String destination, ImageConversionType conversionType);
-
- /**
- * Read binary data from a drive
- *
- * @param uuid
- * drive to read
- * @param offset
- * start at the specified offset in bytes
- * @param size
- * the specified size in bytes; must be <=4096k
- * @return binary content of the drive.
- */
- Payload readDrive(String uuid, long offset, long size);
-
- /**
- * Write binary data to a drive
- *
- * @param uuid
- * drive to write
- * @param content
- * what to write.
- * <ul>
- * <li>Binary data (Content-Type: application/octet-stream)</li>
- * <li>Supports raw data or Content-Encoding: gzip</li>
- * <li>Does not support Transfer-Encoding: chunked</li>
- * </ul>
- */
- void writeDrive(String uuid, Payload content);
-
- /**
- * @see ElasticStackClient#writeDrive(String, Payload)
- * @param offset
- * the byte offset in the target drive at which to start writing, not an offset in the
- * input stream.
- */
- void writeDrive(String uuid, Payload content, long offset);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java
index 8b7cfba..94a46b9 100644
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/ElasticStackComputeServiceAdapter.java
@@ -44,7 +44,7 @@ import org.jclouds.compute.domain.internal.VolumeImpl;
import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
-import org.jclouds.elasticstack.ElasticStackClient;
+import org.jclouds.elasticstack.ElasticStackApi;
import org.jclouds.elasticstack.domain.Device;
import org.jclouds.elasticstack.domain.Drive;
import org.jclouds.elasticstack.domain.DriveInfo;
@@ -64,21 +64,20 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.UncheckedExecutionException;
/**
- * defines the connection between the {@link ElasticStackClient} implementation
+ * defines the connection between the {@link org.jclouds.elasticstack.ElasticStackApi} implementation
* and the jclouds {@link ComputeService}
*
*/
@Singleton
public class ElasticStackComputeServiceAdapter implements
ComputeServiceAdapter<ServerInfo, Hardware, DriveInfo, Location> {
- private final ElasticStackClient client;
+ private final ElasticStackApi client;
private final Predicate<DriveInfo> driveNotClaimed;
private final Map<String, WellKnownImage> preinstalledImages;
private final LoadingCache<String, DriveInfo> cache;
@@ -90,7 +89,7 @@ public class ElasticStackComputeServiceAdapter implements
protected Logger logger = Logger.NULL;
@Inject
- public ElasticStackComputeServiceAdapter(ElasticStackClient client, Predicate<DriveInfo> driveNotClaimed,
+ public ElasticStackComputeServiceAdapter(ElasticStackApi client, Predicate<DriveInfo> driveNotClaimed,
Map<String, WellKnownImage> preinstalledImages, LoadingCache<String, DriveInfo> cache,
@Named(ElasticStackConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java
index 5b68fde..4aba9af 100644
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/compute/config/ElasticStackComputeServiceContextModule.java
@@ -34,7 +34,7 @@ import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Volume;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.Location;
-import org.jclouds.elasticstack.ElasticStackClient;
+import org.jclouds.elasticstack.ElasticStackApi;
import org.jclouds.elasticstack.compute.ElasticStackComputeServiceAdapter;
import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata;
import org.jclouds.elasticstack.compute.functions.ServerInfoToNodeMetadata.DeviceToVolume;
@@ -98,10 +98,10 @@ public class ElasticStackComputeServiceContextModule extends
@Singleton
public static class GetDrive extends CacheLoader<String, DriveInfo> {
- private final ElasticStackClient client;
+ private final ElasticStackApi client;
@Inject
- public GetDrive(ElasticStackClient client) {
+ public GetDrive(ElasticStackApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackHttpApiModule.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackHttpApiModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackHttpApiModule.java
new file mode 100644
index 0000000..bfbce04
--- /dev/null
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackHttpApiModule.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elasticstack.config;
+
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.elasticstack.ElasticStackApi;
+import org.jclouds.elasticstack.domain.Device;
+import org.jclouds.elasticstack.domain.Drive;
+import org.jclouds.elasticstack.domain.DriveData;
+import org.jclouds.elasticstack.domain.DriveMetrics;
+import org.jclouds.elasticstack.domain.NIC;
+import org.jclouds.elasticstack.domain.Server;
+import org.jclouds.elasticstack.domain.ServerMetrics;
+import org.jclouds.elasticstack.functions.CreateDriveRequestToMap;
+import org.jclouds.elasticstack.functions.DriveDataToMap;
+import org.jclouds.elasticstack.functions.MapToDevices;
+import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId;
+import org.jclouds.elasticstack.functions.MapToDriveMetrics;
+import org.jclouds.elasticstack.functions.MapToNICs;
+import org.jclouds.elasticstack.functions.MapToServerMetrics;
+import org.jclouds.elasticstack.functions.ServerToMap;
+import org.jclouds.elasticstack.handlers.ElasticStackErrorHandler;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.HttpApiModule;
+
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Configures the elasticstack connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresRestClient
+public class ElasticStackHttpApiModule extends HttpApiModule<ElasticStackApi> {
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(new TypeLiteral<Function<Drive, Map<String, String>>>() {
+ }).to(CreateDriveRequestToMap.class);
+ bind(new TypeLiteral<Function<DriveData, Map<String, String>>>() {
+ }).to(DriveDataToMap.class);
+ bind(new TypeLiteral<Function<Map<String, String>, List<NIC>>>() {
+ }).to(MapToNICs.class);
+ bind(new TypeLiteral<Function<Map<String, String>, Map<String, ? extends Device>>>() {
+ }).to(MapToDevices.class);
+ bind(new TypeLiteral<Function<Map<String, String>, Map<String, ? extends DriveMetrics>>>() {
+ }).to(MapToDriveMetrics.class);
+ bind(new TypeLiteral<Function<Map<String, String>, ServerMetrics>>() {
+ }).to(MapToServerMetrics.class);
+ bind(new TypeLiteral<Function<Device, String>>() {
+ }).to(DeviceToId.class);
+ bind(new TypeLiteral<Function<Server, Map<String, String>>>() {
+ }).to(ServerToMap.class);
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ElasticStackErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ElasticStackErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ElasticStackErrorHandler.class);
+ }
+
+ @Override
+ protected void bindRetryHandlers() {
+ // TODO
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java
deleted file mode 100644
index 961bc14..0000000
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/config/ElasticStackRestClientModule.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.elasticstack.config;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.elasticstack.ElasticStackAsyncClient;
-import org.jclouds.elasticstack.ElasticStackClient;
-import org.jclouds.elasticstack.domain.Device;
-import org.jclouds.elasticstack.domain.Drive;
-import org.jclouds.elasticstack.domain.DriveData;
-import org.jclouds.elasticstack.domain.DriveMetrics;
-import org.jclouds.elasticstack.domain.NIC;
-import org.jclouds.elasticstack.domain.Server;
-import org.jclouds.elasticstack.domain.ServerMetrics;
-import org.jclouds.elasticstack.functions.CreateDriveRequestToMap;
-import org.jclouds.elasticstack.functions.DriveDataToMap;
-import org.jclouds.elasticstack.functions.MapToDevices;
-import org.jclouds.elasticstack.functions.MapToDriveMetrics;
-import org.jclouds.elasticstack.functions.MapToNICs;
-import org.jclouds.elasticstack.functions.MapToServerMetrics;
-import org.jclouds.elasticstack.functions.ServerToMap;
-import org.jclouds.elasticstack.functions.MapToDevices.DeviceToId;
-import org.jclouds.elasticstack.handlers.ElasticStackErrorHandler;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.annotation.ClientError;
-import org.jclouds.http.annotation.Redirection;
-import org.jclouds.http.annotation.ServerError;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
-
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
-
-/**
- * Configures the elasticstack connection.
- *
- * @author Adrian Cole
- */
-@ConfiguresRestClient
-public class ElasticStackRestClientModule extends RestClientModule<ElasticStackClient, ElasticStackAsyncClient> {
-
- @Override
- protected void configure() {
- super.configure();
- bind(new TypeLiteral<Function<Drive, Map<String, String>>>() {
- }).to(CreateDriveRequestToMap.class);
- bind(new TypeLiteral<Function<DriveData, Map<String, String>>>() {
- }).to(DriveDataToMap.class);
- bind(new TypeLiteral<Function<Map<String, String>, List<NIC>>>() {
- }).to(MapToNICs.class);
- bind(new TypeLiteral<Function<Map<String, String>, Map<String, ? extends Device>>>() {
- }).to(MapToDevices.class);
- bind(new TypeLiteral<Function<Map<String, String>, Map<String, ? extends DriveMetrics>>>() {
- }).to(MapToDriveMetrics.class);
- bind(new TypeLiteral<Function<Map<String, String>, ServerMetrics>>() {
- }).to(MapToServerMetrics.class);
- bind(new TypeLiteral<Function<Device, String>>() {
- }).to(DeviceToId.class);
- bind(new TypeLiteral<Function<Server, Map<String, String>>>() {
- }).to(ServerToMap.class);
- }
-
- @Override
- protected void bindErrorHandlers() {
- bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ElasticStackErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ElasticStackErrorHandler.class);
- bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ElasticStackErrorHandler.class);
- }
-
- @Override
- protected void bindRetryHandlers() {
- // TODO
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/main/java/org/jclouds/elasticstack/predicates/DriveClaimed.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/predicates/DriveClaimed.java b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/predicates/DriveClaimed.java
index ce7c08c..575a336 100644
--- a/apis/elasticstack/src/main/java/org/jclouds/elasticstack/predicates/DriveClaimed.java
+++ b/apis/elasticstack/src/main/java/org/jclouds/elasticstack/predicates/DriveClaimed.java
@@ -22,7 +22,7 @@ import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.elasticstack.ElasticStackClient;
+import org.jclouds.elasticstack.ElasticStackApi;
import org.jclouds.elasticstack.domain.DriveInfo;
import org.jclouds.logging.Logger;
@@ -35,13 +35,13 @@ import com.google.common.base.Predicate;
@Singleton
public class DriveClaimed implements Predicate<DriveInfo> {
- private final ElasticStackClient client;
+ private final ElasticStackApi client;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public DriveClaimed(ElasticStackClient client) {
+ public DriveClaimed(ElasticStackApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java
new file mode 100644
index 0000000..2ce94fe
--- /dev/null
+++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiLiveTest.java
@@ -0,0 +1,350 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elasticstack;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.elasticstack.domain.ClaimType;
+import org.jclouds.elasticstack.domain.CreateDriveRequest;
+import org.jclouds.elasticstack.domain.DriveData;
+import org.jclouds.elasticstack.domain.DriveInfo;
+import org.jclouds.elasticstack.domain.DriveStatus;
+import org.jclouds.elasticstack.domain.IDEDevice;
+import org.jclouds.elasticstack.domain.ImageConversionType;
+import org.jclouds.elasticstack.domain.Model;
+import org.jclouds.elasticstack.domain.Server;
+import org.jclouds.elasticstack.domain.ServerInfo;
+import org.jclouds.elasticstack.domain.ServerStatus;
+import org.jclouds.elasticstack.predicates.DriveClaimed;
+import org.jclouds.elasticstack.util.Servers;
+import org.jclouds.io.Payloads;
+import org.jclouds.predicates.SocketOpen;
+import org.jclouds.ssh.SshClient;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.jclouds.util.Strings2;
+import org.testng.annotations.AfterGroups;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.net.HostAndPort;
+import com.google.gson.Gson;
+import com.google.inject.Guice;
+
+/**
+ * Tests behavior of {@code ElasticStackApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "ElasticStackApiLiveTest")
+public class ElasticStackApiLiveTest extends BaseComputeServiceContextLiveTest {
+
+ public ElasticStackApiLiveTest() {
+ provider = "elasticstack";
+ }
+
+ protected long driveSize = 1 * 1024 * 1024 * 1024l;
+ protected int maxDriveImageTime = 360;
+ protected String vncPassword = "Il0veVNC";
+ protected ElasticStackApi client;
+ protected Predicate<HostAndPort> socketTester;
+ protected Predicate<DriveInfo> driveNotClaimed;
+ protected String imageId;
+
+ @Override
+ @BeforeClass(groups = { "integration", "live" })
+ public void setupContext() {
+ super.setupContext();
+ imageId = view.getComputeService().templateBuilder().build().getImage().getId();
+
+ client = view.utils().injector().getInstance(ElasticStackApi.class);
+ driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
+ SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
+ socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);
+ }
+
+ @Test
+ public void testListServers() throws Exception {
+ Set<String> servers = client.listServers();
+ assertNotNull(servers);
+ }
+
+ @Test
+ public void testListServerInfo() throws Exception {
+ Set<? extends ServerInfo> servers = client.listServerInfo();
+ assertNotNull(servers);
+ }
+
+ @Test
+ public void testGetServer() throws Exception {
+ for (String serverUUID : client.listServers()) {
+ assert !"".equals(serverUUID);
+ assertNotNull(client.getServerInfo(serverUUID));
+ }
+ }
+
+ @Test
+ public void testListDrives() throws Exception {
+ Set<String> drives = client.listDrives();
+ assertNotNull(drives);
+ }
+
+ @Test
+ public void testListDriveInfo() throws Exception {
+ Set<? extends DriveInfo> drives = client.listDriveInfo();
+ assertNotNull(drives);
+ }
+
+ @Test
+ public void testGetDrive() throws Exception {
+ for (String driveUUID : client.listDrives()) {
+ assert !"".equals(driveUUID) : driveUUID;
+ assert client.getDriveInfo(driveUUID) != null : driveUUID;
+ }
+ }
+
+ protected String prefix = System.getProperty("user.name") + ".test";
+ protected DriveInfo drive;
+
+ @Test
+ public void testCreateDrive() throws Exception {
+ drive = client.createDrive(new CreateDriveRequest.Builder().name(prefix).size(driveSize).build());
+ checkCreatedDrive();
+
+ DriveInfo newInfo = client.getDriveInfo(drive.getUuid());
+ checkDriveMatchesGet(newInfo);
+
+ }
+
+ protected void checkDriveMatchesGet(DriveInfo newInfo) {
+ assertEquals(newInfo.getUuid(), drive.getUuid());
+ }
+
+ protected void checkCreatedDrive() {
+ assertNotNull(drive.getUuid());
+ assertNotNull(drive.getUser());
+ assertEquals(drive.getName(), prefix);
+ assertEquals(drive.getSize(), driveSize);
+ assertEquals(drive.getStatus(), DriveStatus.ACTIVE);
+ // for some reason, these occasionally return as 4096,1
+ // assertEquals(info.getReadBytes(), 0l);
+ // assertEquals(info.getWriteBytes(), 0l);
+ // assertEquals(info.getReadRequests(), 0l);
+ // assertEquals(info.getWriteRequests(), 0l);
+ assertEquals(drive.getEncryptionCipher(), "aes-xts-plain");
+ }
+
+ @Test(dependsOnMethods = "testCreateDrive")
+ public void testSetDriveData() throws Exception {
+
+ DriveInfo drive2 = client.setDriveData(drive.getUuid(), new DriveData.Builder().claimType(ClaimType.SHARED).name(
+ "rediculous").readers(ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff")).tags(
+ ImmutableSet.of("networking", "security", "gateway")).userMetadata(ImmutableMap.of("foo", "bar"))
+ .build());
+
+ assertNotNull(drive2.getUuid(), drive.getUuid());
+ assertEquals(drive2.getName(), "rediculous");
+ assertEquals(drive2.getClaimType(), ClaimType.SHARED);
+ assertEquals(drive2.getReaders(), ImmutableSet.of("ffffffff-ffff-ffff-ffff-ffffffffffff"));
+ assertEquals(drive2.getTags(), ImmutableSet.of("networking", "security", "gateway"));
+ assertEquals(drive2.getUserMetadata(), ImmutableMap.of("foo", "bar"));
+ drive = drive2;
+ }
+
+ protected ServerInfo server;
+
+ @Test(dependsOnMethods = "testSetDriveData")
+ public void testCreateAndStartServer() throws Exception {
+ Logger.getAnonymousLogger().info("preparing drive");
+ prepareDrive();
+
+ Server serverRequest = Servers.small(prefix, drive.getUuid(), vncPassword).build();
+
+ Logger.getAnonymousLogger().info("starting server");
+ server = client.createServer(serverRequest);
+ client.startServer(server.getUuid());
+ server = client.getServerInfo(server.getUuid());
+ checkStartedServer();
+
+ Server newInfo = client.getServerInfo(server.getUuid());
+ checkServerMatchesGet(newInfo);
+
+ }
+
+ protected void checkServerMatchesGet(Server newInfo) {
+ assertEquals(newInfo.getUuid(), server.getUuid());
+ }
+
+ protected void checkStartedServer() {
+ System.out.println(new Gson().toJson(server));
+ assertNotNull(server.getUuid());
+ assertNotNull(server.getUser());
+ assertEquals(server.getName(), prefix);
+ assertEquals(server.isPersistent(), true);
+ assertEquals(server.getDevices(), ImmutableMap.of("ide:0:0", new IDEDevice.Builder(0, 0).uuid(drive.getUuid())
+ .build()));
+ assertEquals(server.getBootDeviceIds(), ImmutableSet.of("ide:0:0"));
+ assertEquals(server.getNics().get(0).getDhcp(), server.getVnc().getIp());
+ assertEquals(server.getNics().get(0).getModel(), Model.E1000);
+ assertEquals(server.getStatus(), ServerStatus.ACTIVE);
+ }
+
+ @Test(dependsOnMethods = "testCreateAndStartServer")
+ public void testConnectivity() throws Exception {
+ HostAndPort vncsocket = HostAndPort.fromParts(server.getVnc().getIp(), 5900);
+ Logger.getAnonymousLogger().info("awaiting vnc: " + vncsocket);
+ assert socketTester.apply(vncsocket) : server;
+ HostAndPort sshsocket = HostAndPort.fromParts(server.getNics().get(0).getDhcp(), 22);
+ Logger.getAnonymousLogger().info("awaiting ssh: " + sshsocket);
+ assert socketTester.apply(sshsocket) : server;
+ doConnectViaSsh(server, getSshCredentials(server));
+ }
+
+ @Test(dependsOnMethods = "testConnectivity")
+ public void testLifeCycle() throws Exception {
+ client.stopServer(server.getUuid());
+ assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
+
+ client.startServer(server.getUuid());
+ assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
+
+ client.resetServer(server.getUuid());
+ assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
+
+ client.shutdownServer(server.getUuid());
+ // behavior on shutdown depends on how your server OS is set up to respond to an ACPI power
+ // button signal
+ assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
+ server.getUuid()).getStatus() == ServerStatus.STOPPED);
+ }
+
+ @Test(dependsOnMethods = "testLifeCycle")
+ public void testSetServerConfiguration() throws Exception {
+ client.stopServer(server.getUuid());
+ assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.STOPPED);
+
+ ServerInfo server2 = client.setServerConfiguration(server.getUuid(), Server.Builder.fromServer(server).name(
+ "rediculous").tags(ImmutableSet.of("networking", "security", "gateway")).userMetadata(
+ ImmutableMap.of("foo", "bar")).build());
+
+ assertNotNull(server2.getUuid(), server.getUuid());
+ assertEquals(server2.getName(), "rediculous");
+ checkTagsAndMetadata(server2);
+ server = server2;
+ }
+
+ protected void checkTagsAndMetadata(ServerInfo server2) {
+ assertEquals(server2.getTags(), ImmutableSet.of("networking", "security", "gateway"));
+ assertEquals(server2.getUserMetadata(), ImmutableMap.of("foo", "bar"));
+ }
+
+ @Test(dependsOnMethods = "testSetServerConfiguration")
+ public void testDestroyServer() throws Exception {
+ client.destroyServer(server.getUuid());
+ assertEquals(client.getServerInfo(server.getUuid()), null);
+ }
+
+ @Test(dependsOnMethods = "testDestroyServer")
+ public void testDestroyDrive() throws Exception {
+ client.destroyDrive(drive.getUuid());
+ assertEquals(client.getDriveInfo(drive.getUuid()), null);
+ }
+
+ protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException {
+ SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create(
+ HostAndPort.fromParts(server.getVnc().getIp(), 22), creds);
+ try {
+ ssh.connect();
+ ExecResponse hello = ssh.exec("echo hello");
+ assertEquals(hello.getOutput().trim(), "hello");
+ System.err.println(ssh.exec("df -k").getOutput());
+ System.err.println(ssh.exec("mount").getOutput());
+ System.err.println(ssh.exec("uname -a").getOutput());
+ } finally {
+ if (ssh != null)
+ ssh.disconnect();
+ }
+ }
+
+ @AfterGroups(groups = "live")
+ @Override
+ protected void tearDownContext() {
+ try {
+ client.destroyServer(server.getUuid());
+ } catch (Exception e) {
+ // no need to check null or anything as we swallow all
+ }
+ try {
+ client.destroyDrive(drive.getUuid());
+ } catch (Exception e) {
+
+ }
+ super.tearDownContext();
+ }
+
+ private DriveInfo drive2;
+ private DriveInfo drive3;
+
+ public void testWeCanReadAndWriteToDrive() throws IOException {
+ drive2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1 * 1024 * 1024l).build());
+ client.writeDrive(drive2.getUuid(), Payloads.newStringPayload("foo"));
+ assertEquals(Strings2.toString(client.readDrive(drive2.getUuid(), 0, 3)), "foo");
+ }
+
+ @Test(dependsOnMethods = "testWeCanReadAndWriteToDrive")
+ public void testWeCopyADriveContentsViaGzip() throws IOException {
+ try {
+ drive3 = client
+ .createDrive(new CreateDriveRequest.Builder().name(prefix + "3").size(1 * 1024 * 1024l).build());
+ System.err.println("before image; drive 2" + client.getDriveInfo(drive2.getUuid()));
+ System.err.println("before image; drive 3" + client.getDriveInfo(drive3.getUuid()));
+ client.imageDrive(drive2.getUuid(), drive3.getUuid());
+ assert driveNotClaimed.apply(drive3) : client.getDriveInfo(drive3.getUuid());
+ assert driveNotClaimed.apply(drive2) : client.getDriveInfo(drive2.getUuid());
+ System.err.println("after image; drive 2" + client.getDriveInfo(drive2.getUuid()));
+ System.err.println("after image; drive 3" + client.getDriveInfo(drive3.getUuid()));
+ assertEquals(Strings2.toString(client.readDrive(drive3.getUuid(), 0, 3)), "foo");
+ } finally {
+ client.destroyDrive(drive2.getUuid());
+ client.destroyDrive(drive3.getUuid());
+ }
+ }
+
+ protected LoginCredentials getSshCredentials(Server server) {
+ return LoginCredentials.builder().user("toor").password(server.getVnc().getPassword()).build();
+ }
+
+ protected void prepareDrive() {
+ System.err.println("before prepare" + client.getDriveInfo(drive.getUuid()));
+ client.imageDrive(imageId, drive.getUuid(), ImageConversionType.GUNZIP);
+ assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
+ System.err.println("after prepare" + client.getDriveInfo(drive.getUuid()));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/a2af31c4/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java
----------------------------------------------------------------------
diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java
new file mode 100644
index 0000000..aa62b83
--- /dev/null
+++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackApiTest.java
@@ -0,0 +1,451 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.elasticstack;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.elasticstack.binders.BindServerToPlainTextStringTest;
+import org.jclouds.elasticstack.domain.CreateDriveRequest;
+import org.jclouds.elasticstack.domain.Drive;
+import org.jclouds.elasticstack.domain.DriveData;
+import org.jclouds.elasticstack.domain.ImageConversionType;
+import org.jclouds.elasticstack.domain.Server;
+import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.elasticstack.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.elasticstack.functions.ReturnPayload;
+import org.jclouds.elasticstack.functions.SplitNewlines;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.io.Payload;
+import org.jclouds.io.Payloads;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code ElasticStackApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "ElasticStackApiTest")
+public class ElasticStackApiTest extends BaseAsyncClientTest<ElasticStackApi> {
+ public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "listServers");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "listServerInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "getServerInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/servers/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateAndStartServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "createAndStartServer", Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "createServer", Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/create/stopped HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "setServerConfiguration", String.class, Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
+ BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "destroyServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "startServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/start HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "stopServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/stop HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "shutdownServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/shutdown HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "resetServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/servers/uuid/reset HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "listDrives");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "listDriveInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "getDriveInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api-lon-p.elastichosts.com/drives/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "createDrive", Drive.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ new CreateDriveRequest.Builder().name("foo").size(10000l).build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "setDriveData", String.class, DriveData.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
+ new DriveData.Builder().name("foo").size(10000l).tags(ImmutableList.of("production", "candy")).build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000\ntags production candy", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "destroyDrive", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testImageDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "imageDrive", String.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testImageDriveWithConversion() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "imageDrive", String.class, String.class,
+ ImageConversionType.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "200",
+ ImageConversionType.GUNZIP));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/200/image/100/gunzip HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testReadDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "readDrive", String.class, long.class, long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", 1024, 2048));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/read/1024/2048 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: application/octet-stream\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReturnPayload.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testWriteDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "writeDrive", String.class, Payload.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
+ Payloads.newStringPayload("foo")));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "foo", MediaType.APPLICATION_OCTET_STREAM, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testWriteDriveOffset() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(ElasticStackApi.class, "writeDrive", String.class, Payload.class, long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100",
+ Payloads.newStringPayload("foo"), 2048));
+
+ assertRequestLineEquals(httpRequest, "POST https://api-lon-p.elastichosts.com/drives/100/write/2048 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "foo", MediaType.APPLICATION_OCTET_STREAM, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new ElasticStackApiMetadata();
+ }
+
+}
[05/10] Remove async from gogrid
Posted by ab...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java
deleted file mode 100644
index 23a9489..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerAsyncClientTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.gogrid.domain.PowerCommand;
-import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
-import org.jclouds.gogrid.options.GetServerListOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridServerAsyncClient}
- *
- * @author Oleksiy Yarmula, Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridServerAsyncClientTest")
-public class GridServerAsyncClientTest extends BaseGoGridAsyncClientTest<GridServerAsyncClient> {
-
- @Test
- public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServerList", GetServerListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- new GetServerListOptions.Builder().onlySandboxServers()));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/server/list?v=1.6&isSandbox=true HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
- + "v=1.6&isSandbox=true&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetServersByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServersByName", String[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("server1"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&name=server1&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetServersById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServersById", long[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&id=123&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
-
- @Test
- public void testPowerServer() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "power", String.class, PowerCommand.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer",
- PowerCommand.RESTART));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
- + "server=PowerServer&power=restart " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
- + "server=PowerServer&power=restart&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testDeleteByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "deleteByName", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
- + "name=PowerServer " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
- + "name=PowerServer&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetRamSizes() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getRamSizes");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram "
- + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testServerCredentials() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getServerCredentials", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/support/grid/password/get?v=1.6&id=1 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseCredentialsFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
- }
-
- @Test
- public void testTypes() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "getTypes");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.type HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
- }
-
- @Test
- public void testEditServerDescription() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerDescription", long.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "newDesc"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&description=newDesc HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditServerRam() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerRam", long.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "1GB"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&server.ram=1GB HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&server.ram=1GB&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditServerType() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridServerAsyncClient.class, "editServerType", long.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "web"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&server.type=web HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
- + "id=2&server.type=web&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java
deleted file mode 100644
index e724512..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridServerClientExpectTest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.gogrid.services;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.net.URI;
-
-import org.jclouds.gogrid.GoGridClient;
-import org.jclouds.gogrid.options.AddServerOptions;
-import org.jclouds.gogrid.options.GetServerListOptions;
-import org.jclouds.gogrid.parse.ParseServerListTest;
-import org.jclouds.gogrid.parse.ParseServerTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "GridServerClientExpectTest")
-public class GridServerClientExpectTest extends BaseGoGridRestClientExpectTest {
-
- HttpRequest addServer = HttpRequest.builder().method("GET")
- .endpoint("https://api.gogrid.com/api/grid/server/add")
- .addQueryParam("v", "1.6")
- .addQueryParam("name", "serverName")
- .addQueryParam("image", "img55")
- .addQueryParam("server.ram", "memory")
- .addQueryParam("ip", "127.0.0.1")
- .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
- .addQueryParam("api_key", "identity").build();
-
- public void testAddServerWhenResponseIs2xx() throws Exception {
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
- payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
-
- GoGridClient addServerWorked = requestSendsResponse(addServer, listGridServersResponse);
-
- assertEquals(addServerWorked.getServerServices().addServer("serverName", "img55", "memory", "127.0.0.1")
- .toString(), new ParseServerTest().expected().toString());
- }
-
- HttpRequest addServerOptions = HttpRequest.builder().method("GET")
- .endpoint("https://api.gogrid.com/api/grid/server/add")
- .addQueryParam("v", "1.6")
- .addQueryParam("name", "serverName")
- .addQueryParam("image", "img55")
- .addQueryParam("server.ram", "memory")
- .addQueryParam("ip", "127.0.0.1")
- .addQueryParam("isSandbox", "true")
- .addQueryParam("description", "fooy")
- .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
- .addQueryParam("api_key", "identity").build();
-
- public void testAddServerWithOptionsWhenResponseIs2xx() throws Exception {
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
- payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
-
- GoGridClient addServerWithOptionsWorked = requestSendsResponse(addServerOptions, listGridServersResponse);
-
- assertEquals(addServerWithOptionsWorked.getServerServices().addServer("serverName", "img55", "memory",
- "127.0.0.1", new AddServerOptions().asSandboxType().withDescription("fooy")).toString(),
- new ParseServerTest().expected().toString());
- }
-
- public void testGetServerListWhenResponseIs2xx() throws Exception {
- HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
- URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
-
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
- payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
-
- GoGridClient clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
-
- assertEquals(clientWhenGridServersExist.getServerServices().getServerList().toString(), new ParseServerListTest()
- .expected().toString());
- }
-
- public void testGetServerListWhenReponseIs404IsEmpty() throws Exception {
- HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
- URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
-
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload(
- payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
-
- GoGridClient clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
-
- assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty());
- }
-
- public void testGetServerListWithOptionsWhenResponseIs2xx() throws Exception {
- HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
- URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&isSandbox=true&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
-
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
- payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
-
- GoGridClient clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
-
- assertEquals(clientWhenGridServersExist.getServerServices().getServerList(
- new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest()
- .expected().toString());
- }
-
- public void testGetServerCredentialsWhenNotFoundThrowsResourceNotFoundExceptionWithNiceMessage() throws Exception {
- HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
- URI.create("https://api.gogrid.com/api/support/grid/password/get?" + "v=1.6&id=11&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
-
- HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload(
- payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
-
- GoGridClient clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
- try {
- clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
- fail("should have failed");
- } catch (ResourceNotFoundException e) {
- assertEquals(e.getMessage(), "No object found that matches your input criteria.");
- }
- }
-}
[04/10] git commit: Removed async from cloudsigma
Posted by ab...@apache.org.
Removed async from cloudsigma
Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/1a6071ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/1a6071ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/1a6071ab
Branch: refs/heads/master
Commit: 1a6071ab9294a1bf06eb62d7320470e4575fc74e
Parents: a9cb3cf
Author: Andrew Bayer <an...@gmail.com>
Authored: Fri Aug 2 07:56:31 2013 -0700
Committer: Andrew Bayer <an...@gmail.com>
Committed: Fri Aug 2 07:57:41 2013 -0700
----------------------------------------------------------------------
.../org/jclouds/cloudsigma/CloudSigmaApi.java | 448 +++++++++++++
.../cloudsigma/CloudSigmaApiMetadata.java | 21 +-
.../cloudsigma/CloudSigmaAsyncClient.java | 352 ----------
.../jclouds/cloudsigma/CloudSigmaClient.java | 304 ---------
.../CloudSigmaComputeServiceAdapter.java | 9 +-
.../CloudSigmaComputeServiceContextModule.java | 6 +-
.../config/CloudSigmaRestClientModule.java | 7 +-
.../cloudsigma/predicates/DriveClaimed.java | 6 +-
.../org/jclouds/cloudsigma/util/Servers.java | 3 +-
.../jclouds/cloudsigma/CloudSigmaApiTest.java | 646 +++++++++++++++++++
.../cloudsigma/CloudSigmaAsyncClientTest.java | 646 -------------------
.../cloudsigma/CloudSigmaClientLiveTest.java | 6 +-
.../CloudSigmaZurichComputeServiceLiveTest.java | 6 +-
13 files changed, 1118 insertions(+), 1342 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
new file mode 100644
index 0000000..42ffd5e
--- /dev/null
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApi.java
@@ -0,0 +1,448 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudsigma;
+
+import java.io.Closeable;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
+import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.DriveInfo;
+import org.jclouds.cloudsigma.domain.ProfileInfo;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.domain.ServerInfo;
+import org.jclouds.cloudsigma.domain.StaticIPInfo;
+import org.jclouds.cloudsigma.domain.VLANInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
+import org.jclouds.cloudsigma.functions.SplitNewlines;
+import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+
+/**
+ * Provides synchronous access to CloudSigma via their REST API.
+ * <p/>
+ *
+ * @see <a href="http://cloudsigma.com/en/platform-details/the-api" />
+ * @author Adrian Cole
+ */
+@RequestFilters(BasicAuthentication.class)
+@Consumes(MediaType.TEXT_PLAIN)
+public interface CloudSigmaApi extends Closeable {
+
+ /**
+ * list of drive uuids that are in the library
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/standard/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardDrives();
+
+ /**
+ * list of cd uuids that are in the library
+ *
+ * @return or empty set if no cds are found
+ */
+ @GET
+ @Path("/drives/standard/cd/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardCds();
+
+ /**
+ * list of image uuids that are in the library
+ *
+ * @return or empty set if no images are found
+ */
+ @GET
+ @Path("/drives/standard/img/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listStandardImages();
+
+ /**
+ * Clone an existing drive. By default, the size is the same as the source
+ *
+ * @param sourceUuid
+ * source to clone
+ * @param newName
+ * name of the resulting drive
+ * @param options
+ * options to control size
+ * @return new drive
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/clone")
+ @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
+ DriveInfo cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName,
+ CloneDriveOptions... options);
+
+ /**
+ * Get profile info
+ *
+ * @return info or null, if not found
+ */
+ @GET
+ @Path("/profile/info")
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class)
+ ProfileInfo getProfileInfo();
+
+ /**
+ * Get all drives info
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
+ Set<DriveInfo> listDriveInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/info")
+ DriveInfo getDriveInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new drive
+ *
+ * @param createDrive
+ * required parameters: name, size
+ * @return newly created drive
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/create")
+ DriveInfo createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
+
+ /**
+ * set extra drive data
+ *
+ * @param uuid
+ * what drive to change
+ * @param createDrive
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
+ @Path("/drives/{uuid}/set")
+ DriveInfo setDriveData(@PathParam("uuid") String uuid,
+ @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive);
+
+ /**
+ * create a new server
+ *
+ * @param createServer
+ * @return newly created server
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/create")
+ ServerInfo createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
+
+ /**
+ * Get all servers info
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
+ Set<ServerInfo> listServerInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/info")
+ ServerInfo getServerInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * set server configuration
+ *
+ * @param uuid
+ * what server to change
+ * @param setServer
+ * what values to change
+ * @return new data
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
+ @Path("/servers/{uuid}/set")
+ ServerInfo setServerConfiguration(@PathParam("uuid") String uuid,
+ @BinderParam(BindServerToPlainTextString.class) Server setServer);
+
+ /**
+ * list of server uuids in your account
+ *
+ * @return or empty set if no servers are found
+ */
+ @GET
+ @Path("/servers/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listServers();
+
+ /**
+ * Destroy a server
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/servers/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Start a server
+ *
+ * @param uuid
+ * what to start
+ */
+ @POST
+ @Path("/servers/{uuid}/start")
+ void startServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Stop a server
+ * <p/>
+ * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
+ * status if it is persistent and is automatically destroyed otherwise.
+ *
+ * @param uuid
+ * what to stop
+ */
+ @POST
+ @Path("/servers/{uuid}/stop")
+ void stopServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Shutdown a server
+ * <p/>
+ * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
+ * persistent and is automatically destroyed otherwise.
+ * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
+ * ACPI power button signal.
+ *
+ * @param uuid
+ * what to shutdown
+ */
+ @POST
+ @Path("/servers/{uuid}/shutdown")
+ void shutdownServer(@PathParam("uuid") String uuid);
+
+ /**
+ * Reset a server
+ *
+ * @param uuid
+ * what to reset
+ */
+ @POST
+ @Path("/servers/{uuid}/reset")
+ void resetServer(@PathParam("uuid") String uuid);
+
+ /**
+ * list of drive uuids in your account
+ *
+ * @return or empty set if no drives are found
+ */
+ @GET
+ @Path("/drives/list")
+ @ResponseParser(SplitNewlines.class)
+ Set<String> listDrives();
+
+ /**
+ * Destroy a drive
+ *
+ * @param uuid
+ * what to delete
+ */
+ @GET
+ @Path("/drives/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyDrive(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new vlan
+ *
+ * @param name
+ * @return newly created vlan
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/create")
+ @Payload("name {name}\n")
+ @Produces(MediaType.TEXT_PLAIN)
+ VLANInfo createVLAN(@PayloadParam("name") String name);
+
+ /**
+ * Get all vlans info
+ *
+ * @return or empty set if no vlans are found
+ */
+ @GET
+ @Path("/resources/vlan/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class)
+ Set<VLANInfo> listVLANInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/{uuid}/info")
+ VLANInfo getVLANInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * set vlan configuration
+ *
+ * @param uuid
+ * what vlan to change
+ * @param name
+ * what the new name is
+ * @return new data
+ */
+ @POST
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
+ @Path("/resources/vlan/{uuid}/set")
+ @Payload("name {name}\n")
+ @Produces(MediaType.TEXT_PLAIN)
+ VLANInfo renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name);
+
+ /**
+ * list of vlan uuids in your account
+ *
+ * @return or empty set if no vlans are found
+ */
+ @GET
+ @Path("/resources/vlan/list")
+ @ResponseParser(SplitNewlinesAndReturnSecondField.class)
+ Set<String> listVLANs();
+
+ /**
+ * Destroy a vlan
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/resources/vlan/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyVLAN(@PathParam("uuid") String uuid);
+
+ /**
+ * create a new ip
+ *
+ * @return newly created ip
+ */
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
+ @Path("/resources/ip/create")
+ StaticIPInfo createStaticIP();
+
+ /**
+ * Get all ips info
+ *
+ * @return or empty set if no ips are found
+ */
+ @GET
+ @Path("/resources/ip/info")
+ @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class)
+ Set<StaticIPInfo> listStaticIPInfo();
+
+ /**
+ * @param uuid
+ * what to get
+ * @return null, if not found
+ */
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
+ @Path("/resources/ip/{uuid}/info")
+ StaticIPInfo getStaticIPInfo(@PathParam("uuid") String uuid);
+
+ /**
+ * list of ip uuids in your account
+ *
+ * @return or empty set if no ips are found
+ */
+ @GET
+ @Path("/resources/ip/list")
+ @ResponseParser(SplitNewlinesAndReturnSecondField.class)
+ Set<String> listStaticIPs();
+
+ /**
+ * Destroy a ip
+ *
+ * @param uuid
+ * what to destroy
+ */
+ @GET
+ @Path("/resources/ip/{uuid}/destroy")
+ @Fallback(VoidOnNotFoundOr404.class)
+ void destroyStaticIP(@PathParam("uuid") String uuid);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
index eea93cb..22fb6cf 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
@@ -26,10 +26,9 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.rest.internal.BaseRestApiMetadata;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
@@ -37,17 +36,9 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
+public class CloudSigmaApiMetadata extends BaseHttpApiMetadata<CloudSigmaApi> {
+
- /**
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
- * {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
- */
- @Deprecated
- public static final TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
- private static final long serialVersionUID = 1L;
- };
-
@Override
public Builder toBuilder() {
return new Builder().fromApiMetadata(this);
@@ -62,7 +53,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
}
public static Properties defaultProperties() {
- Properties properties = BaseRestApiMetadata.defaultProperties();
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
// passwords are set post-boot, so auth failures are possible
// from a race condition applying the password set script
@@ -72,11 +63,9 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
return properties;
}
- public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+ public static class Builder extends BaseHttpApiMetadata.Builder<CloudSigmaApi, Builder> {
- @SuppressWarnings("deprecation")
protected Builder() {
- super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
id("cloudsigma")
.name("CloudSigma API")
.identityName("Email")
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
deleted file mode 100644
index ca5ddb8..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaAsyncClient.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudsigma;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.cloudsigma.binders.BindCloneDriveOptionsToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindDriveDataToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindDriveToPlainTextString;
-import org.jclouds.cloudsigma.binders.BindServerToPlainTextString;
-import org.jclouds.cloudsigma.domain.Drive;
-import org.jclouds.cloudsigma.domain.DriveData;
-import org.jclouds.cloudsigma.domain.DriveInfo;
-import org.jclouds.cloudsigma.domain.ProfileInfo;
-import org.jclouds.cloudsigma.domain.Server;
-import org.jclouds.cloudsigma.domain.ServerInfo;
-import org.jclouds.cloudsigma.domain.StaticIPInfo;
-import org.jclouds.cloudsigma.domain.VLANInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
-import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
-import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
-import org.jclouds.cloudsigma.functions.SplitNewlines;
-import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
-import org.jclouds.cloudsigma.options.CloneDriveOptions;
-import org.jclouds.http.filters.BasicAuthentication;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.MapBinder;
-import org.jclouds.rest.annotations.Payload;
-import org.jclouds.rest.annotations.PayloadParam;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Provides asynchronous access to CloudSigma via their REST API.
- * <p/>
- *
- * @see CloudSigmaClient
- * @see <a href="http://cloudsigma.com/en/platform-details/the-api" />
- * @author Adrian Cole
- * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
- * {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
- */
-@Deprecated
-@RequestFilters(BasicAuthentication.class)
-@Consumes(MediaType.TEXT_PLAIN)
-public interface CloudSigmaAsyncClient extends Closeable {
-
- /**
- * @see CloudSigmaClient#listStandardDrives
- */
- @GET
- @Path("/drives/standard/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardDrives();
-
- /**
- * @see CloudSigmaClient#listStandardCds
- */
- @GET
- @Path("/drives/standard/cd/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardCds();
-
- /**
- * @see CloudSigmaClient#listStandardImages
- */
- @GET
- @Path("/drives/standard/img/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listStandardImages();
-
- /**
- * @see CloudSigmaClient#cloneDrive
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/clone")
- @MapBinder(BindCloneDriveOptionsToPlainTextString.class)
- ListenableFuture<DriveInfo> cloneDrive(@PathParam("uuid") String sourceUuid, @PayloadParam("name") String newName,
- CloneDriveOptions... options);
-
- /**
- * @see CloudSigmaClient#getProfileInfo
- */
- @GET
- @Path("/profile/info")
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToProfileInfo.class)
- ListenableFuture<ProfileInfo> getProfileInfo();
-
- /**
- * @see CloudSigmaClient#listDriveInfo
- */
- @GET
- @Path("/drives/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class)
- ListenableFuture<Set<DriveInfo>> listDriveInfo();
-
- /**
- * @see CloudSigmaClient#getDriveInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/info")
- ListenableFuture<DriveInfo> getDriveInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createDrive
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/create")
- ListenableFuture<DriveInfo> createDrive(@BinderParam(BindDriveToPlainTextString.class) Drive createDrive);
-
- /**
- * @see CloudSigmaClient#setDriveData
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToDriveInfo.class)
- @Path("/drives/{uuid}/set")
- ListenableFuture<DriveInfo> setDriveData(@PathParam("uuid") String uuid,
- @BinderParam(BindDriveDataToPlainTextString.class) DriveData createDrive);
-
- /**
- * @see CloudSigmaClient#createServer
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/create")
- ListenableFuture<ServerInfo> createServer(@BinderParam(BindServerToPlainTextString.class) Server createServer);
-
- /**
- * @see CloudSigmaClient#listServerInfo
- */
- @GET
- @Path("/servers/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class)
- ListenableFuture<Set<ServerInfo>> listServerInfo();
-
- /**
- * @see CloudSigmaClient#getServerInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/info")
- ListenableFuture<ServerInfo> getServerInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#setServerConfiguration
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToServerInfo.class)
- @Path("/servers/{uuid}/set")
- ListenableFuture<ServerInfo> setServerConfiguration(@PathParam("uuid") String uuid,
- @BinderParam(BindServerToPlainTextString.class) Server setServer);
-
- /**
- * @see CloudSigmaClient#listServers
- */
- @GET
- @Path("/servers/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listServers();
-
- /**
- * @see CloudSigmaClient#destroyServer
- */
- @GET
- @Path("/servers/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#startServer
- */
- @POST
- @Path("/servers/{uuid}/start")
- ListenableFuture<Void> startServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#stopServer
- */
- @POST
- @Path("/servers/{uuid}/stop")
- ListenableFuture<Void> stopServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#shutdownServer
- */
- @POST
- @Path("/servers/{uuid}/shutdown")
- ListenableFuture<Void> shutdownServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#resetServer
- */
- @POST
- @Path("/servers/{uuid}/reset")
- ListenableFuture<Void> resetServer(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#listDrives
- */
- @GET
- @Path("/drives/list")
- @ResponseParser(SplitNewlines.class)
- ListenableFuture<Set<String>> listDrives();
-
- /**
- * @see CloudSigmaClient#destroyDrive
- */
- @GET
- @Path("/drives/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyDrive(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createVLAN
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/create")
- @Payload("name {name}\n")
- @Produces(MediaType.TEXT_PLAIN)
- ListenableFuture<VLANInfo> createVLAN(@PayloadParam("name") String name);
-
- /**
- * @see CloudSigmaClient#listVLANInfo
- */
- @GET
- @Path("/resources/vlan/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class)
- ListenableFuture<Set<VLANInfo>> listVLANInfo();
-
- /**
- * @see CloudSigmaClient#getVLANInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/{uuid}/info")
- ListenableFuture<VLANInfo> getVLANInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#setVLANConfiguration
- */
- @POST
- @ResponseParser(KeyValuesDelimitedByBlankLinesToVLANInfo.class)
- @Path("/resources/vlan/{uuid}/set")
- @Payload("name {name}\n")
- @Produces(MediaType.TEXT_PLAIN)
- ListenableFuture<VLANInfo> renameVLAN(@PathParam("uuid") String uuid, @PayloadParam("name") String name);
-
- /**
- * @see CloudSigmaClient#listVLANs
- */
- @GET
- @Path("/resources/vlan/list")
- @ResponseParser(SplitNewlinesAndReturnSecondField.class)
- ListenableFuture<Set<String>> listVLANs();
-
- /**
- * @see CloudSigmaClient#destroyVLAN
- */
- @GET
- @Path("/resources/vlan/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyVLAN(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#createStaticIP
- */
- @POST
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
- @Path("/resources/ip/create")
- ListenableFuture<StaticIPInfo> createStaticIP();
-
- /**
- * @see CloudSigmaClient#listStaticIPInfo
- */
- @GET
- @Path("/resources/ip/info")
- @ResponseParser(ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class)
- ListenableFuture<Set<StaticIPInfo>> listStaticIPInfo();
-
- /**
- * @see CloudSigmaClient#getStaticIPInfo
- */
- @GET
- @Fallback(NullOnNotFoundOr404.class)
- @ResponseParser(KeyValuesDelimitedByBlankLinesToStaticIPInfo.class)
- @Path("/resources/ip/{uuid}/info")
- ListenableFuture<StaticIPInfo> getStaticIPInfo(@PathParam("uuid") String uuid);
-
- /**
- * @see CloudSigmaClient#listStaticIPs
- */
- @GET
- @Path("/resources/ip/list")
- @ResponseParser(SplitNewlinesAndReturnSecondField.class)
- ListenableFuture<Set<String>> listStaticIPs();
-
- /**
- * @see CloudSigmaClient#destroyStaticIP
- */
- @GET
- @Path("/resources/ip/{uuid}/destroy")
- @Fallback(VoidOnNotFoundOr404.class)
- ListenableFuture<Void> destroyStaticIP(@PathParam("uuid") String uuid);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
deleted file mode 100644
index b57095f..0000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaClient.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.cloudsigma;
-
-import java.io.Closeable;
-import java.util.Set;
-
-import org.jclouds.cloudsigma.domain.Drive;
-import org.jclouds.cloudsigma.domain.DriveData;
-import org.jclouds.cloudsigma.domain.DriveInfo;
-import org.jclouds.cloudsigma.domain.ProfileInfo;
-import org.jclouds.cloudsigma.domain.Server;
-import org.jclouds.cloudsigma.domain.ServerInfo;
-import org.jclouds.cloudsigma.domain.StaticIPInfo;
-import org.jclouds.cloudsigma.domain.VLANInfo;
-import org.jclouds.cloudsigma.options.CloneDriveOptions;
-
-/**
- * Provides synchronous access to CloudSigma.
- * <p/>
- *
- * @see CloudSigmaAsyncClient
- * @see <a href="TODO: insert URL of cloudsigma documentation" />
- * @author Adrian Cole
- */
-public interface CloudSigmaClient extends Closeable {
-
- /**
- * Get profile info
- *
- * @return info or null, if not found
- */
- ProfileInfo getProfileInfo();
-
- /**
- * list of server uuids in your account
- *
- * @return or empty set if no servers are found
- */
- Set<String> listServers();
-
- /**
- * Get all servers info
- *
- * @return or empty set if no servers are found
- */
- Set<? extends ServerInfo> listServerInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- ServerInfo getServerInfo(String uuid);
-
- /**
- * create a new server
- *
- * @param server
- * @return newly created server
- */
- ServerInfo createServer(Server server);
-
- /**
- * set server configuration
- *
- * @param uuid
- * what server to change
- * @param serverData
- * what values to change
- * @return new data
- */
- ServerInfo setServerConfiguration(String uuid, Server server);
-
- /**
- * Destroy a server
- *
- * @param uuid
- * what to destroy
- */
- void destroyServer(String uuid);
-
- /**
- * Start a server
- *
- * @param uuid
- * what to start
- */
- void startServer(String uuid);
-
- /**
- * Stop a server
- * <p/>
- * Kills the server immediately, equivalent to a power failure. Server reverts to a stopped
- * status if it is persistent and is automatically destroyed otherwise.
- *
- * @param uuid
- * what to stop
- */
- void stopServer(String uuid);
-
- /**
- * Shutdown a server
- * <p/>
- * Sends the server an ACPI power-down event. Server reverts to a stopped status if it is
- * persistent and is automatically destroyed otherwise.
- * <h4>note</h4> behaviour on shutdown depends on how your server OS is set up to respond to an
- * ACPI power button signal.
- *
- * @param uuid
- * what to shutdown
- */
- void shutdownServer(String uuid);
-
- /**
- * Reset a server
- *
- * @param uuid
- * what to reset
- */
- void resetServer(String uuid);
-
- /**
- * list of drive uuids in your account
- *
- * @return or empty set if no drives are found
- */
- Set<String> listDrives();
-
- /**
- * Get all drives info
- *
- * @return or empty set if no drives are found
- */
- Set<? extends DriveInfo> listDriveInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- DriveInfo getDriveInfo(String uuid);
-
- /**
- * create a new drive
- *
- * @param createDrive
- * required parameters: name, size
- * @return newly created drive
- */
- DriveInfo createDrive(Drive createDrive);
-
- /**
- * set extra drive data
- *
- * @param uuid
- * what drive to change
- * @param driveData
- * what values to change
- * @return new data
- */
- DriveInfo setDriveData(String uuid, DriveData driveData);
-
- /**
- * Destroy a drive
- *
- * @param uuid
- * what to delete
- */
- void destroyDrive(String uuid);
-
- /**
- * list of drive uuids that are in the library
- *
- * @return or empty set if no drives are found
- */
- Set<String> listStandardDrives();
-
- /**
- * list of cd uuids that are in the library
- *
- * @return or empty set if no cds are found
- */
- Set<String> listStandardCds();
-
- /**
- * list of image uuids that are in the library
- *
- * @return or empty set if no images are found
- */
- Set<String> listStandardImages();
-
- /**
- * Clone an existing drive. By default, the size is the same as the source
- *
- * @param sourceUuid
- * source to clone
- * @param newName
- * name of the resulting drive
- * @param options
- * options to control size
- * @return new drive
- */
- DriveInfo cloneDrive(String sourceUuid, String newName, CloneDriveOptions... options);
-
- /**
- * list of vlan uuids in your account
- *
- * @return or empty set if no vlans are found
- */
- Set<String> listVLANs();
-
- /**
- * Get all vlans info
- *
- * @return or empty set if no vlans are found
- */
- Set<? extends VLANInfo> listVLANInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- VLANInfo getVLANInfo(String uuid);
-
- /**
- * create a new vlan
- *
- * @param vlan
- * @return newly created vlan
- */
- VLANInfo createVLAN(String name);
-
- /**
- * set vlan configuration
- *
- * @param uuid
- * what vlan to change
- * @param newName
- * what the new name is
- * @return new data
- */
- VLANInfo renameVLAN(String uuid, String newName);
-
- /**
- * Destroy a vlan
- *
- * @param uuid
- * what to destroy
- */
- void destroyVLAN(String uuid);
-
- /**
- * list of ip uuids in your account
- *
- * @return or empty set if no ips are found
- */
- Set<String> listStaticIPs();
-
- /**
- * Get all ips info
- *
- * @return or empty set if no ips are found
- */
- Set<? extends StaticIPInfo> listStaticIPInfo();
-
- /**
- * @param uuid
- * what to get
- * @return null, if not found
- */
- StaticIPInfo getStaticIPInfo(String uuid);
-
- /**
- * create a new ip
- *
- * @return newly created ip
- */
- StaticIPInfo createStaticIP();
-
- /**
- * Destroy a ip
- *
- * @param uuid
- * what to destroy
- */
- void destroyStaticIP(String uuid);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
index 10c8e26..51240ff 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceAdapter.java
@@ -28,7 +28,7 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions;
import org.jclouds.cloudsigma.domain.AffinityType;
import org.jclouds.cloudsigma.domain.Device;
@@ -62,14 +62,13 @@ import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.UncheckedExecutionException;
/**
- * defines the connection between the {@link CloudSigmaClient} implementation
+ * defines the connection between the {@link org.jclouds.cloudsigma.CloudSigmaApi} implementation
* and the jclouds {@link ComputeService}
*
*/
@@ -85,7 +84,7 @@ public class CloudSigmaComputeServiceAdapter implements
}
});
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
private final Predicate<DriveInfo> driveNotClaimed;
private final String defaultVncPassword;
private final LoadingCache<String, DriveInfo> cache;
@@ -96,7 +95,7 @@ public class CloudSigmaComputeServiceAdapter implements
protected Logger logger = Logger.NULL;
@Inject
- public CloudSigmaComputeServiceAdapter(CloudSigmaClient client, Predicate<DriveInfo> driveNotClaimed,
+ public CloudSigmaComputeServiceAdapter(CloudSigmaApi client, Predicate<DriveInfo> driveNotClaimed,
@Named(CloudSigmaConstants.PROPERTY_VNC_PASSWORD) String defaultVncPassword,
LoadingCache<String, DriveInfo> cache, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor) {
this.client = checkNotNull(client, "client");
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
index f16a15e..d9ddeac 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/compute/config/CloudSigmaComputeServiceContextModule.java
@@ -22,7 +22,7 @@ import static org.jclouds.util.Predicates2.retry;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.compute.CloudSigmaComputeServiceAdapter;
import org.jclouds.cloudsigma.compute.CloudSigmaTemplateBuilderImpl;
import org.jclouds.cloudsigma.compute.functions.ParseOsFamilyVersion64BitFromImageName;
@@ -97,10 +97,10 @@ public class CloudSigmaComputeServiceContextModule extends
@Singleton
public static class GetDrive extends CacheLoader<String, DriveInfo> {
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
@Inject
- public GetDrive(CloudSigmaClient client) {
+ public GetDrive(CloudSigmaApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
index fd62d8a..3773fa3 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/config/CloudSigmaRestClientModule.java
@@ -19,8 +19,7 @@ package org.jclouds.cloudsigma.config;
import java.util.List;
import java.util.Map;
-import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.domain.Device;
import org.jclouds.cloudsigma.domain.Drive;
import org.jclouds.cloudsigma.domain.DriveData;
@@ -42,7 +41,7 @@ import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.config.RestClientModule;
+import org.jclouds.rest.config.HttpApiModule;
import com.google.common.base.Function;
import com.google.inject.TypeLiteral;
@@ -53,7 +52,7 @@ import com.google.inject.TypeLiteral;
* @author Adrian Cole
*/
@ConfiguresRestClient
-public class CloudSigmaRestClientModule extends RestClientModule<CloudSigmaClient, CloudSigmaAsyncClient> {
+public class CloudSigmaRestClientModule extends HttpApiModule<CloudSigmaApi> {
@Override
protected void bindErrorHandlers() {
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
index 3f7aa03..210c2ef 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/predicates/DriveClaimed.java
@@ -22,7 +22,7 @@ import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Singleton;
-import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.cloudsigma.CloudSigmaApi;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.logging.Logger;
@@ -35,13 +35,13 @@ import com.google.common.base.Predicate;
@Singleton
public class DriveClaimed implements Predicate<DriveInfo> {
- private final CloudSigmaClient client;
+ private final CloudSigmaApi client;
@Resource
protected Logger logger = Logger.NULL;
@Inject
- public DriveClaimed(CloudSigmaClient client) {
+ public DriveClaimed(CloudSigmaApi client) {
this.client = client;
}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
index 62a59a3..768f515 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/util/Servers.java
@@ -16,7 +16,6 @@
*/
package org.jclouds.cloudsigma.util;
-import org.jclouds.cloudsigma.CloudSigmaClient;
import org.jclouds.cloudsigma.domain.IDEDevice;
import org.jclouds.cloudsigma.domain.Model;
import org.jclouds.cloudsigma.domain.NIC;
@@ -69,7 +68,7 @@ public class Servers {
/**
* Takes the input server and changes its primary ip to a new address. To make this happen,
- * you'll need to invoke {@link CloudSigmaClient#setServerConfiguration}
+ * you'll need to invoke {@link org.jclouds.cloudsigma.CloudSigmaApi#setServerConfiguration}
*
* @param in
* server to change
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/1a6071ab/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
new file mode 100644
index 0000000..24c0c4d
--- /dev/null
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiTest.java
@@ -0,0 +1,646 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudsigma;
+
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
+import org.jclouds.cloudsigma.domain.CreateDriveRequest;
+import org.jclouds.cloudsigma.domain.Drive;
+import org.jclouds.cloudsigma.domain.DriveData;
+import org.jclouds.cloudsigma.domain.Server;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToDriveInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToProfileInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToServerInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToStaticIPInfo;
+import org.jclouds.cloudsigma.functions.KeyValuesDelimitedByBlankLinesToVLANInfo;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet;
+import org.jclouds.cloudsigma.functions.ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet;
+import org.jclouds.cloudsigma.functions.SplitNewlines;
+import org.jclouds.cloudsigma.functions.SplitNewlinesAndReturnSecondField;
+import org.jclouds.cloudsigma.options.CloneDriveOptions;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.filters.BasicAuthentication;
+import org.jclouds.http.functions.ReleasePayloadAndReturn;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code CloudSigmaApi}
+ *
+ * @author Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "CloudSigmaApiTest")
+public class CloudSigmaApiTest extends BaseAsyncClientTest<CloudSigmaApi> {
+
+ public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getProfileInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/profile/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToProfileInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStandardDrives() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardDrives");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListStandardCds() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardCds");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/cd/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListStandardImages() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStandardImages");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/standard/img/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testListDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listDriveInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetDriveInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getDriveInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createDrive", Drive.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ new CreateDriveRequest.Builder().name("foo").use(ImmutableList.of("production", "candy")).size(10000l)
+ .build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCloneDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class,
+ CloneDriveOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name newname", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCloneDriveOptions() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "cloneDrive", String.class, String.class,
+ CloneDriveOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("sourceid", "newname",
+ new CloneDriveOptions().size(1024l)));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/sourceid/clone HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name newname\nsize 1024", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetDriveData() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "setDriveData", String.class, DriveData.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", new DriveData.Builder().name("foo").size(10000l)
+ .use(ImmutableList.of("production", "candy")).build()));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/drives/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name foo\nsize 10000\nuse production candy", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToDriveInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListServers() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listServers");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listServerInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetServerInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getServerInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createServer", Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testSetServerConfiguration() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "setServerConfiguration", String.class, Server.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", BindServerToPlainTextStringTest.SERVER));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, BindServerToPlainTextStringTest.CREATED_SERVER, "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToServerInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/servers/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStartServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "startServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/start HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testStopServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "stopServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/stop HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testShutdownServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "shutdownServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/shutdown HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testResetServer() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "resetServer", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/servers/uuid/reset HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListDrives() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listDrives");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlines.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyDrive() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyDrive", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/drives/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListVLANs() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listVLANs");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listVLANInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetVLANInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getVLANInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createVLAN", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("poohbear"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testRenameVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "renameVLAN", String.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("100", "poohbear"));
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/vlan/100/set HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, "name poohbear\n", "text/plain", false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToVLANInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyVLAN() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyVLAN", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/vlan/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStaticIPs() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStaticIPs");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // now make sure request filters apply by replaying
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/list HTTP/1.1");
+ // for example, using basic authentication, we should get "only one"
+ // header
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\nAuthorization: Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ // TODO: insert expected response class, which probably extends ParseJson
+ assertResponseParserClassEquals(method, httpRequest, SplitNewlinesAndReturnSecondField.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testListStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "listStaticIPInfo");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ListOfKeyValuesDelimitedByBlankLinesToStaticIPInfoSet.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ }
+
+ public void testGetStaticIPInfo() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "getStaticIPInfo", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/info HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testCreateStaticIP() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "createStaticIP");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "POST https://api.cloudsigma.com/resources/ip/create HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, KeyValuesDelimitedByBlankLinesToStaticIPInfo.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ public void testDestroyStaticIP() throws SecurityException, NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(CloudSigmaApi.class, "destroyStaticIP", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("uuid"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.cloudsigma.com/resources/ip/uuid/destroy HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "Accept: text/plain\n");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+
+ }
+
+ @Override
+ protected void checkFilters(HttpRequest request) {
+ assertEquals(request.getFilters().size(), 1);
+ assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new CloudSigmaApiMetadata();
+ }
+
+}