You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2016/07/12 06:34:16 UTC
[1/3] jclouds-labs git commit: JCLOUDS-1124 oneandone-server-api
Repository: jclouds-labs
Updated Branches:
refs/heads/master 2b36a75f9 -> 7df28d259
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
new file mode 100644
index 0000000..2b04a80
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneApiMockTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.internal;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Resources;
+import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
+import com.google.gson.JsonParser;
+import com.google.inject.Module;
+import com.squareup.okhttp.mockwebserver.MockWebServer;
+import com.squareup.okhttp.mockwebserver.RecordedRequest;
+import java.io.IOException;
+import java.util.Properties;
+import java.util.Set;
+import org.apache.jclouds.oneandone.rest.OneAndOneApi;
+import org.apache.jclouds.oneandone.rest.OneAndOneProviderMetadata;
+import org.jclouds.ContextBuilder;
+import org.jclouds.concurrent.config.ExecutorServiceModule;
+import org.jclouds.json.Json;
+import org.jclouds.rest.ApiContext;
+import static org.testng.Assert.assertEquals;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+public class BaseOneAndOneApiMockTest {
+
+ private static final OneAndOneProviderMetadata METADATA = new OneAndOneProviderMetadata();
+ protected static final String AUTH_HEADER = "token";
+ private static final String DEFAULT_ENDPOINT = METADATA.getEndpoint();
+
+ private final Set<Module> modules = ImmutableSet.<Module>of(new ExecutorServiceModule(sameThreadExecutor()));
+
+ protected MockWebServer server;
+ protected OneAndOneApi api;
+ private Json json;
+
+ private final JsonParser parser = new JsonParser();
+
+ @BeforeMethod
+ public void start() throws IOException {
+ server = new MockWebServer();
+ server.play();
+ ApiContext<OneAndOneApi> ctx = ContextBuilder.newBuilder("oneandone")
+ .credentials("token", "password")
+ .endpoint(url(""))
+ .modules(modules)
+ .overrides(overrides())
+ .build();
+ json = ctx.utils().injector().getInstance(Json.class);
+ api = ctx.getApi();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void stop() throws IOException {
+ server.shutdown();
+ api.close();
+ }
+
+ protected Properties overrides() {
+ return new Properties();
+ }
+
+ protected String url(String path) {
+ return server.getUrl(path).toString();
+ }
+
+ protected String stringFromResource(String resourceName) {
+ try {
+ return Resources.toString(getClass().getResource(resourceName), Charsets.UTF_8)
+ .replace(DEFAULT_ENDPOINT, url(""));
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ protected RecordedRequest assertSent(MockWebServer server, String method, String path) throws InterruptedException {
+
+ RecordedRequest request = server.takeRequest();
+
+ assertEquals(request.getMethod(), method);
+ assertEquals(request.getPath(), path);
+ assertEquals(request.getHeader("X-TOKEN"), AUTH_HEADER);
+ return request;
+ }
+
+ protected RecordedRequest assertSent(MockWebServer server, String method, String path, String json)
+ throws InterruptedException {
+ RecordedRequest request = assertSent(server, method, path);
+
+ String expectedContentType = "application/json";
+
+ assertEquals(request.getHeader("Content-Type"), expectedContentType);
+ assertEquals(parser.parse(new String(request.getBody(), Charsets.UTF_8)), parser.parse(json));
+ return request;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
new file mode 100644
index 0000000..7045e45
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/internal/BaseOneAndOneLiveTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.internal;
+
+import com.google.common.base.Predicate;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import org.apache.jclouds.oneandone.rest.OneAndOneApi;
+import org.apache.jclouds.oneandone.rest.OneAndOneProviderMetadata;
+import org.apache.jclouds.oneandone.rest.config.OneAndOneConstants;
+import org.apache.jclouds.oneandone.rest.config.OneAndOneProperties;
+import org.apache.jclouds.oneandone.rest.domain.Hardware;
+import org.apache.jclouds.oneandone.rest.domain.Hdd;
+import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.ids.ServerPrivateNetworkRef;
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.util.Predicates2;
+import static org.testng.Assert.assertTrue;
+
+public class BaseOneAndOneLiveTest extends BaseApiLiveTest<OneAndOneApi> {
+
+ Predicate<Server> waitUntilServerReady;
+ Predicate<ServerPrivateNetworkRef> waitUntilPrivateNetworkReady;
+ private static final OneAndOneProviderMetadata METADATA = new OneAndOneProviderMetadata();
+ OneAndOneConstants constants;
+
+ public BaseOneAndOneLiveTest() {
+ provider = "oneandone";
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, OneAndOneProperties.AUTH_TOKEN);
+ return props;
+ }
+
+ @Override
+ protected OneAndOneApi create(Properties props, Iterable<Module> modules) {
+ Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
+ constants = injector.getInstance(OneAndOneConstants.class);
+ Predicate<Server> serverAvailableCheck = new Predicate<Server>() {
+ @Override
+ public boolean apply(Server currentServer) {
+ Server server = api.serverApi().get(currentServer.id());
+
+ if ((server.status().state() != Types.ServerState.POWERED_OFF
+ && server.status().state() != Types.ServerState.POWERED_ON)
+ || server.status().percent() != 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ };
+
+ Predicate<ServerPrivateNetworkRef> privateNetworkAvailableCheck = new Predicate<ServerPrivateNetworkRef>() {
+ @Override
+ public boolean apply(ServerPrivateNetworkRef networkRef) {
+ PrivateNetwork server = api.serverApi().getPrivateNetwork(networkRef.serverId(), networkRef.privateNetworkId());
+ return server.state() != Types.GenericState.ACTIVE;
+ }
+ };
+ waitUntilPrivateNetworkReady = Predicates2.retry(privateNetworkAvailableCheck, constants.pollTimeout(), constants.pollPeriod(), constants.pollMaxPeriod(), TimeUnit.SECONDS);
+ waitUntilServerReady = Predicates2.retry(serverAvailableCheck, constants.pollTimeout(), constants.pollPeriod(), constants.pollMaxPeriod(), TimeUnit.SECONDS);
+ return injector.getInstance(OneAndOneApi.class);
+ }
+
+ protected Server createServer(String serverName) {
+
+ List<Hdd.CreateHdd> hdds = new ArrayList<Hdd.CreateHdd>();
+ Hdd.CreateHdd hdd = Hdd.CreateHdd.create(30, Boolean.TRUE);
+ hdds.add(hdd);
+ Hardware.CreateHardware hardware = Hardware.CreateHardware.create(4.0, 1.0, 2.0, hdds);
+ return api.serverApi().create(Server.CreateServer.builder()
+ .name(serverName)
+ .description("testing with jclouds")
+ .hardware(hardware)
+ .applianceId("81504C620D98BCEBAA5202D145203B4B")
+ .dataCenterId("908DC2072407C94C8054610AD5A53B8C")
+ .password("Test123!")
+ .powerOn(Boolean.TRUE).build());
+ }
+
+ protected void assertNodeAvailable(Server server) {
+ assertTrue(waitUntilServerReady.apply(server), String.format("Server %s is not Ready", server));
+ }
+
+ protected void assertPrivateNetworkAvailable(ServerPrivateNetworkRef ref) {
+ assertTrue(waitUntilPrivateNetworkReady.apply(ref), String.format("ServerPrivateNetworkRef %s is not Ready", ref));
+ }
+
+ protected Server deleteServer(String serverId) {
+ return api.serverApi().delete(serverId);
+ }
+
+ protected Server turnOnServer(String serverId) {
+ return api.serverApi().updateStatus(serverId, Server.UpdateStatus.create(Types.ServerAction.POWER_ON, Types.ServerActionMethod.SOFTWARE));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/add.hdds.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/add.hdds.json b/oneandone/src/test/resources/server/add.hdds.json
new file mode 100644
index 0000000..1e96fd5
--- /dev/null
+++ b/oneandone/src/test/resources/server/add.hdds.json
@@ -0,0 +1,54 @@
+{
+ "id": "4B86A3ACC4CEB7A89E012E49FC17F312",
+ "cloudpanel_id": "FE7ED7D",
+ "name": "My Server remame",
+ "description": "My server rename description",
+ "datacenter": {
+ "id": "D0F6D8C8ED29D3036F94C27BBB7BAD36",
+ "location": "USA",
+ "country_code": "US"
+ },
+ "creation_date": "2015-05-07T08:25:37+00:00",
+ "first_password": "Nm4gP97xSw",
+ "status": {
+ "state": "CONFIGURING",
+ "percent": 10
+ },
+ "hardware": {
+ "fixed_instance_size_id": 0,
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [
+ {
+ "id": "0DDE06DFA47743DF928E76AE7DC195C1",
+ "size": 40,
+ "is_main": true
+ },
+ {
+ "id": "B6DAEB7FA4D0CABFD8FE878EC467CA7E",
+ "size": 20,
+ "is_main": false
+ }
+ ]
+ },
+ "image": {
+ "id": "07C170D67C8EC776933FCFF1C299C1C5",
+ "name": "w2012r2datacenter64min"
+ },
+ "dvd": null,
+ "snapshot": null,
+ "ips": [
+ {
+ "id": "D609028BC090EE05665072C721EA4A7A",
+ "ip": "10.4.141.43",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": null,
+ "load_balancers": []
+ }
+ ],
+ "alerts": [],
+ "monitoring_policy": null,
+ "private_networks": null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/delete.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/delete.json b/oneandone/src/test/resources/server/delete.json
new file mode 100644
index 0000000..c29f865
--- /dev/null
+++ b/oneandone/src/test/resources/server/delete.json
@@ -0,0 +1,51 @@
+{
+ "id": "D2522497990A9FDCB26CE579524E4024",
+ "cloudpanel_id": "01CFD25",
+ "name": "Updatedjava",
+ "description": "Updated desc",
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-18T20:42:44+00:00",
+ "first_password": null,
+ "status": {
+ "state": "REMOVING",
+ "percent": 0
+ },
+ "hardware": {
+ "fixed_instance_size_id": null,
+ "vcore": 4,
+ "cores_per_processor": 2,
+ "ram": 4,
+ "hdds": [{
+ "id": "7840E7C4DFF5972625720E297AAF870E",
+ "size": 30,
+ "is_main": true
+ }]
+ },
+ "image": {
+ "id": "81504C620D98BCEBAA5202D145203B4B",
+ "name": "w2012r2datacenter64iso"
+ },
+ "dvd": {
+ "id": "81504C620D98BCEBAA5202D145203B4B",
+ "name": "w2012r2datacenter64iso"
+ },
+ "snapshot": null,
+ "ips": [{
+ "id": "8C4F2B7115EB90C585EE6FFB6A5904A8",
+ "ip": "70.35.203.100",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": {
+ "id": "34A7E423DA3253E6D38563ED06F1041F",
+ "name": "Linux"
+ },
+ "load_balancers": []
+ }],
+ "alerts": [],
+ "monitoring_policy": null,
+ "private_networks": null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.dvd.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.dvd.json b/oneandone/src/test/resources/server/get.dvd.json
new file mode 100644
index 0000000..58f3fa4
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.dvd.json
@@ -0,0 +1,4 @@
+{
+ "id": "B77E19E062D5818532EFF11C747BD104",
+ "name": "Windows 2012 - 64 bits"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.flavour.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.flavour.json b/oneandone/src/test/resources/server/get.flavour.json
new file mode 100644
index 0000000..e7c7128
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.flavour.json
@@ -0,0 +1,15 @@
+{
+ "id": "65929629F35BBFBA63022008F773F3EB",
+ "name": "M",
+ "hardware": {
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "unit": "GB",
+ "hdds": [{
+ "size": 40,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.hardware.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.hardware.json b/oneandone/src/test/resources/server/get.hardware.json
new file mode 100644
index 0000000..21d92ba
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.hardware.json
@@ -0,0 +1,13 @@
+{
+ "fixed_instance_size_id": 0,
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [
+ {
+ "id": "8C626C1A7005D0D1F527143C413D461E",
+ "size": 40,
+ "is_main": true
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.hdd.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.hdd.json b/oneandone/src/test/resources/server/get.hdd.json
new file mode 100644
index 0000000..82732d8
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.hdd.json
@@ -0,0 +1,5 @@
+{
+ "id": "1964560F458D95DE1884E443B00E33E7",
+ "size": 40,
+ "is_main": true
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.image.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.image.json b/oneandone/src/test/resources/server/get.image.json
new file mode 100644
index 0000000..9fbc001
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.image.json
@@ -0,0 +1,4 @@
+{
+ "id": "76EBF29C1250167C8754B2B3D1C05F68",
+ "name": "centos7-64std"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.ip.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.ip.json b/oneandone/src/test/resources/server/get.ip.json
new file mode 100644
index 0000000..2003c20
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.ip.json
@@ -0,0 +1,8 @@
+{
+ "id": "01D4A802798AB77AA72DA2D05E1379E1",
+ "ip": "10.5.135.140",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": null,
+ "load_balancers": []
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.json b/oneandone/src/test/resources/server/get.json
new file mode 100644
index 0000000..0251576
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.json
@@ -0,0 +1,48 @@
+{
+ "id": "C68F3BB07BCBE6191F0ACE996AE4F4F5",
+ "cloudpanel_id": "14DD4DD",
+ "name": "Docs\/Content Test Server: CentOS 7",
+ "description": "",
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-05T08:51:48+00:00",
+ "first_password": "Wb3MvEJHOv",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "hardware": {
+ "fixed_instance_size_id": "3D4C49EAEDD42FBC23DB58FE3DEF464F",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 0.5,
+ "hdds": [{
+ "id": "DD4587ABB3433F93F895638054899F91",
+ "size": 30,
+ "is_main": true
+ }]
+ },
+ "image": {
+ "id": "B5F778B85C041347BCDCFC3172AB3F3C",
+ "name": "centos7-64std"
+ },
+ "dvd": null,
+ "snapshot": null,
+ "ips": [{
+ "id": "5B0BB42CBAF62A454B25D21545CD9ACD",
+ "ip": "70.35.199.18",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": null,
+ "load_balancers": [{
+ "id": "13C3F75BA55AF28B8B2B4E508786F48B",
+ "name": "My Load Balancer 1"
+ }]
+ }],
+ "alerts": [],
+ "monitoring_policy": null,
+ "private_networks": null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.privatenetwork.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.privatenetwork.json b/oneandone/src/test/resources/server/get.privatenetwork.json
new file mode 100644
index 0000000..2d20624
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.privatenetwork.json
@@ -0,0 +1,20 @@
+{
+ "id": "40D2C8D5029BF03F7C9D02D54C9F237D",
+ "name": "puppetnet",
+ "description": null,
+ "network_address": "192.168.45.0",
+ "subnet_mask": "255.255.255.0",
+ "state": "CONFIGURING",
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-09T13:21:43+00:00",
+ "servers": [{
+ "id": "56EAA98A07C3D1ECE4C3F352938853B4",
+ "name": "jclouds operations test",
+ "lock": 6
+ }],
+ "cloudpanel_id": "pnFF88C_2"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/get.status.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/get.status.json b/oneandone/src/test/resources/server/get.status.json
new file mode 100644
index 0000000..d6bcd9a
--- /dev/null
+++ b/oneandone/src/test/resources/server/get.status.json
@@ -0,0 +1,4 @@
+{
+ "state": "POWERED_ON",
+ "percent": null
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.flavours.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.flavours.json b/oneandone/src/test/resources/server/list.flavours.json
new file mode 100644
index 0000000..51b4b63
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.flavours.json
@@ -0,0 +1,113 @@
+[{
+ "id": "65929629F35BBFBA63022008F773F3EB",
+ "name": "M",
+ "hardware": {
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "unit": "GB",
+ "hdds": [{
+ "size": 40,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "591A7FEF641A98B38D1C4F7C99910121",
+ "name": "L",
+ "hardware": {
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "unit": "GB",
+ "hdds": [{
+ "size": 80,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "E903FA4F907B5AAF17A7E987FFCDCC6B",
+ "name": "XL",
+ "hardware": {
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 4,
+ "unit": "GB",
+ "hdds": [{
+ "size": 120,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "57862AE452473D551B1673938DD3DFFE",
+ "name": "XXL",
+ "hardware": {
+ "vcore": 4,
+ "cores_per_processor": 1,
+ "ram": 8,
+ "unit": "GB",
+ "hdds": [{
+ "size": 160,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "3D4C49EAEDD42FBC23DB58FE3DEF464F",
+ "name": "S",
+ "hardware": {
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 0.5,
+ "unit": "GB",
+ "hdds": [{
+ "size": 30,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "6A2383038420110058C77057D261A07C",
+ "name": "3XL",
+ "hardware": {
+ "vcore": 8,
+ "cores_per_processor": 1,
+ "ram": 16,
+ "unit": "GB",
+ "hdds": [{
+ "size": 240,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "EED49B709368C3715382730A604E9F6A",
+ "name": "4XL",
+ "hardware": {
+ "vcore": 12,
+ "cores_per_processor": 1,
+ "ram": 32,
+ "unit": "GB",
+ "hdds": [{
+ "size": 360,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }, {
+ "id": "EE48ACD55FEFE57E2651862A348D1254",
+ "name": "5XL",
+ "hardware": {
+ "vcore": 16,
+ "cores_per_processor": 1,
+ "ram": 48,
+ "unit": "GB",
+ "hdds": [{
+ "size": 500,
+ "unit": "GB",
+ "is_main": true
+ }]
+ }
+ }]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.hardware.hdds.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.hardware.hdds.json b/oneandone/src/test/resources/server/list.hardware.hdds.json
new file mode 100644
index 0000000..059ab6b
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.hardware.hdds.json
@@ -0,0 +1,7 @@
+[
+ {
+ "id": "1964560F458D95DE1884E443B00E33E7",
+ "size": 40,
+ "is_main": true
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.ip.firewallPolicies.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.ip.firewallPolicies.json b/oneandone/src/test/resources/server/list.ip.firewallPolicies.json
new file mode 100644
index 0000000..bbeedf5
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.ip.firewallPolicies.json
@@ -0,0 +1,8 @@
+[{
+ "id": "3C4F21EDFEEDD6ABB728EA5CE684E1AF",
+ "name": "Windows"
+ }, {
+ "id": "3C4F21EDFEEDD6ABB728EA5CE684E1AF",
+ "name": "Windows"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.ip.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.ip.json b/oneandone/src/test/resources/server/list.ip.json
new file mode 100644
index 0000000..f5eee49
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.ip.json
@@ -0,0 +1,10 @@
+[
+ {
+ "id": "01D4A802798AB77AA72DA2D05E1379E1",
+ "ip": "10.5.135.140",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": null,
+ "load_balancers": []
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.ip.loadBalancers.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.ip.loadBalancers.json b/oneandone/src/test/resources/server/list.ip.loadBalancers.json
new file mode 100644
index 0000000..68354ba
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.ip.loadBalancers.json
@@ -0,0 +1,6 @@
+[
+ {
+ "id": "37E2FDEB2945990CEE4B7927FB1ED425",
+ "name": "My load balancer"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.json b/oneandone/src/test/resources/server/list.json
new file mode 100644
index 0000000..f1d3495
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.json
@@ -0,0 +1,341 @@
+[{
+ "id": "C68F3BB07BCBE6191F0ACE996AE4F4F5",
+ "name": "Docs\/Content Test Server: CentOS 7",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-05T08:51:48+00:00",
+ "image": {
+ "id": "B5F778B85C041347BCDCFC3172AB3F3C",
+ "name": "centos7-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "3D4C49EAEDD42FBC23DB58FE3DEF464F",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 0.5,
+ "hdds": [{
+ "id": "DD4587ABB3433F93F895638054899F91",
+ "size": 30,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "5B0BB42CBAF62A454B25D21545CD9ACD",
+ "ip": "70.35.199.18"
+ }],
+ "alerts": null
+ }, {
+ "id": "C547B6BFF993428B72448330883B9A9F",
+ "name": "Doc\/Content Test Server: Ubuntu 14.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-04T22:05:03+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "0BAE1AF79A047D0E903012298142AFD8",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "8F6D690623443F28E91C770F4D2D2727",
+ "ip": "70.35.202.196"
+ }],
+ "alerts": null
+ }, {
+ "id": "E7D36EC025C73796035BF4F171379025",
+ "name": "Docs\/Content Test Server: CentOS 7 (2)",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-05T17:39:50+00:00",
+ "image": {
+ "id": "B5F778B85C041347BCDCFC3172AB3F3C",
+ "name": "centos7-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "F841D521B453B539314D54323AFA6B48",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "FDBE99EDD57F8596CBF71B6B64BD0A92",
+ "ip": "62.151.179.99"
+ }],
+ "alerts": null
+ }, {
+ "id": "4ADC7A1550FBF4F9A75E16D1BF483273",
+ "name": "Docs\/Content Test Server: Win 2012",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-02-25T20:17:49+00:00",
+ "image": {
+ "id": "540D1FA7A714715FC4F0C8558580D2C1",
+ "name": "w2012r2datacenter64std+SQL2012express+Plesk12unlimited"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "591A7FEF641A98B38D1C4F7C99910121",
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [{
+ "id": "DF5BBF27FC71462FFDD347BAB331A58C",
+ "size": 80,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "9C44C6E37937F4C7F0877B45D032D4C6",
+ "ip": "70.35.203.229"
+ }],
+ "alerts": null
+ }, {
+ "id": "DDDC4CCA34AAB08132FA1E40F9FEAC25",
+ "name": "App Dev Server 5",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-04T21:29:00+00:00",
+ "image": {
+ "id": "96D5CEB497043FD54E834DEC4B8FF70A",
+ "name": "centos7-64cpanel"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "5E23F849DD3D6A47615D8EE441FE74CC",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "E193E9D2213088B3CCE8AD69646CEF18",
+ "ip": "70.35.206.196"
+ }],
+ "alerts": null
+ }, {
+ "id": "8122D014AE7E8B4E5D9337C215F48A19",
+ "name": "Doc\/Content Test Server: Debian 7",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-10T21:17:38+00:00",
+ "image": {
+ "id": "D04943D702F82A1FC29B42FD635ACB51",
+ "name": "debian7-64std+Plesk12.5unlimited"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "AC8FEF977EEC56F63C84E78176BD5051",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "D7D42B5E81F649F83AFAF250317A8F64",
+ "ip": "70.35.203.151"
+ }],
+ "alerts": null
+ }, {
+ "id": "BFA8EBD2BE60D224FA87D9AD952C0E1F",
+ "name": "Docs\/Content Test Server: CentOS 6 (2)",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-16T21:29:08+00:00",
+ "image": {
+ "id": "C598EAD5691CDADD1501A2AF29A2E91C",
+ "name": "centos6-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "591A7FEF641A98B38D1C4F7C99910121",
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [{
+ "id": "C59751A93DB3D41230379292D7977B1F",
+ "size": 80,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "39158AED402DB608969D9B4F6D7BAC13",
+ "ip": "70.35.198.225"
+ }],
+ "alerts": null
+ }, {
+ "id": "55561BAF1FAFBD65600C61D1008C1AC7",
+ "name": "Doc\/Content Test Server: Ubuntu 12.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-04-15T18:23:49+00:00",
+ "image": {
+ "id": "84E3B902821F911BE6B43FA36ADA8199",
+ "name": "ubuntu1204-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "84ACD1CD506439F051A163209967EDAE",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "734AACB346D6443BDFF3826E720C995F",
+ "ip": "62.151.176.181"
+ }],
+ "alerts": null
+ }, {
+ "id": "79DF0AD5F3B3EC37E9E0B16806081C13",
+ "name": "Doc\/Content Test Server 2: Ubuntu 14.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-22T20:50:23+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "8B9685555516904EF13D41B76FDBD602",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "A7E78CC8584D515D0F2F82DCA26701F5",
+ "ip": "62.151.180.105"
+ }],
+ "alerts": null
+ }, {
+ "id": "B7860D2E2015AFFD633435C7A2A7AC28",
+ "name": "testin",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-15T22:42:21+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "5B99E4AF5E20106A8226356B1C36ACB6",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "924B7E76DEF6EFB47D6C416E4BF62013",
+ "ip": "70.35.207.184"
+ }],
+ "alerts": null
+ }]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.options-query-test.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.options-query-test.json b/oneandone/src/test/resources/server/list.options-query-test.json
new file mode 100644
index 0000000..f613fad
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.options-query-test.json
@@ -0,0 +1,309 @@
+
+[{
+ "id": "C68F3BB07BCBE6191F0ACE996AE4F4F5",
+ "name": "Docs\/Content Test Server: CentOS 7",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-05T08:51:48+00:00",
+ "image": {
+ "id": "B5F778B85C041347BCDCFC3172AB3F3C",
+ "name": "centos7-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "3D4C49EAEDD42FBC23DB58FE3DEF464F",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 0.5,
+ "hdds": [{
+ "id": "DD4587ABB3433F93F895638054899F91",
+ "size": 30,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "5B0BB42CBAF62A454B25D21545CD9ACD",
+ "ip": "70.35.199.18"
+ }],
+ "alerts": null
+ }, {
+ "id": "C547B6BFF993428B72448330883B9A9F",
+ "name": "Doc\/Content Test Server: Ubuntu 14.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-04T22:05:03+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "0BAE1AF79A047D0E903012298142AFD8",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "8F6D690623443F28E91C770F4D2D2727",
+ "ip": "70.35.202.196"
+ }],
+ "alerts": null
+ }, {
+ "id": "E7D36EC025C73796035BF4F171379025",
+ "name": "Docs\/Content Test Server: CentOS 7 (2)",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-05T17:39:50+00:00",
+ "image": {
+ "id": "B5F778B85C041347BCDCFC3172AB3F3C",
+ "name": "centos7-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "F841D521B453B539314D54323AFA6B48",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "FDBE99EDD57F8596CBF71B6B64BD0A92",
+ "ip": "62.151.179.99"
+ }],
+ "alerts": null
+ }, {
+ "id": "4ADC7A1550FBF4F9A75E16D1BF483273",
+ "name": "Docs\/Content Test Server: Win 2012",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-02-25T20:17:49+00:00",
+ "image": {
+ "id": "540D1FA7A714715FC4F0C8558580D2C1",
+ "name": "w2012r2datacenter64std+SQL2012express+Plesk12unlimited"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "591A7FEF641A98B38D1C4F7C99910121",
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [{
+ "id": "DF5BBF27FC71462FFDD347BAB331A58C",
+ "size": 80,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "9C44C6E37937F4C7F0877B45D032D4C6",
+ "ip": "70.35.203.229"
+ }],
+ "alerts": null
+ }, {
+ "id": "8122D014AE7E8B4E5D9337C215F48A19",
+ "name": "Doc\/Content Test Server: Debian 7",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-10T21:17:38+00:00",
+ "image": {
+ "id": "D04943D702F82A1FC29B42FD635ACB51",
+ "name": "debian7-64std+Plesk12.5unlimited"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "AC8FEF977EEC56F63C84E78176BD5051",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "D7D42B5E81F649F83AFAF250317A8F64",
+ "ip": "70.35.203.151"
+ }],
+ "alerts": null
+ }, {
+ "id": "BFA8EBD2BE60D224FA87D9AD952C0E1F",
+ "name": "Docs\/Content Test Server: CentOS 6 (2)",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-16T21:29:08+00:00",
+ "image": {
+ "id": "C598EAD5691CDADD1501A2AF29A2E91C",
+ "name": "centos6-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "591A7FEF641A98B38D1C4F7C99910121",
+ "vcore": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "hdds": [{
+ "id": "C59751A93DB3D41230379292D7977B1F",
+ "size": 80,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "39158AED402DB608969D9B4F6D7BAC13",
+ "ip": "70.35.198.225"
+ }],
+ "alerts": null
+ }, {
+ "id": "55561BAF1FAFBD65600C61D1008C1AC7",
+ "name": "Doc\/Content Test Server: Ubuntu 12.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-04-15T18:23:49+00:00",
+ "image": {
+ "id": "84E3B902821F911BE6B43FA36ADA8199",
+ "name": "ubuntu1204-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "84ACD1CD506439F051A163209967EDAE",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "734AACB346D6443BDFF3826E720C995F",
+ "ip": "62.151.176.181"
+ }],
+ "alerts": null
+ }, {
+ "id": "79DF0AD5F3B3EC37E9E0B16806081C13",
+ "name": "Doc\/Content Test Server 2: Ubuntu 14.04",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-03-22T20:50:23+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "8B9685555516904EF13D41B76FDBD602",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "A7E78CC8584D515D0F2F82DCA26701F5",
+ "ip": "62.151.180.105"
+ }],
+ "alerts": null
+ }, {
+ "id": "B7860D2E2015AFFD633435C7A2A7AC28",
+ "name": "testin",
+ "description": "",
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-15T22:42:21+00:00",
+ "image": {
+ "id": "72A90ECC29F718404AC3093A3D78327C",
+ "name": "ubuntu1404-64std"
+ },
+ "hardware": {
+ "fixed_instance_size_id": "65929629F35BBFBA63022008F773F3EB",
+ "vcore": 1,
+ "cores_per_processor": 1,
+ "ram": 1,
+ "hdds": [{
+ "id": "5B99E4AF5E20106A8226356B1C36ACB6",
+ "size": 40,
+ "is_main": true
+ }]
+ },
+ "ips": [{
+ "id": "924B7E76DEF6EFB47D6C416E4BF62013",
+ "ip": "70.35.207.184"
+ }],
+ "alerts": null
+ }]
+
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.privatenetwork.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.privatenetwork.json b/oneandone/src/test/resources/server/list.privatenetwork.json
new file mode 100644
index 0000000..8e70dca
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.privatenetwork.json
@@ -0,0 +1,6 @@
+[
+ {
+ "id": "6B7051F17199EF9EA994CD3E4AA450E6",
+ "name": "New private network 1"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/list.snapshot.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/list.snapshot.json b/oneandone/src/test/resources/server/list.snapshot.json
new file mode 100644
index 0000000..04a8863
--- /dev/null
+++ b/oneandone/src/test/resources/server/list.snapshot.json
@@ -0,0 +1,7 @@
+[
+ {
+ "id": "B77E19E062D5818532EFF11C747BD104",
+ "creation_date": "2015-04-06T23:48:38Z",
+ "deletion_date": "2015-04-09T23:48:38Z"
+ }
+]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/update.image.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/update.image.json b/oneandone/src/test/resources/server/update.image.json
new file mode 100644
index 0000000..9e55fd1
--- /dev/null
+++ b/oneandone/src/test/resources/server/update.image.json
@@ -0,0 +1,73 @@
+{
+ "id": "B2C48C21526E16E3FAF59ACD083DC470",
+ "name": "690929B",
+ "public_name": "java test fixed instance 1",
+ "description": "testing with jclouds",
+ "state_id": 0,
+ "state": "DEPLOYING",
+ "vcpu": 2,
+ "cores_per_processor": 1,
+ "ram": 2,
+ "appliance_id": "7C5FA1D21B98DE39D7516333AAB7DA54",
+ "appliance_name": "w2012r2datacenter64std+SQL2012express",
+ "os_name": "Windows2012R2",
+ "dvd_appliance_id": null,
+ "datacenter_id": "908DC2072407C94C8054610AD5A53B8C",
+ "lock_for_action": null,
+ "configuration_id": "591A7FEF641A98B38D1C4F7C99910121",
+ "configuration_name": "VPS_L",
+ "snapshot_id": null,
+ "start_date": "2016-06-26T15:43:43+00:00",
+ "hdds": [{
+ "id": "B6A5488F233BCE8BFA6B7B48886EA025",
+ "technical_id": 2000,
+ "size": 80,
+ "type_id": 1,
+ "is_main": true,
+ "vm_id": "B2C48C21526E16E3FAF59ACD083DC470"
+ }],
+ "hdd": 80,
+ "ips": ["50.21.182.115"],
+ "hw_version": null,
+ "first_password": null,
+ "rsa_key": 0,
+ "alerts": [],
+ "alerts_count": [],
+ "resize_limits": {
+ "vcpu_min": 2,
+ "vcpu_max": "16.00",
+ "vcpu_step": 1,
+ "ram_min": 2,
+ "ram_max": 32,
+ "ram_step": "0.50",
+ "vcpu_restrictions": ["RESIZE_RESTRICTION_HOT_VCPU_DECREASE_NOT_ALLOWED"],
+ "ram_restrictions": ["RESIZE_RESTRICTION_HOT_RAM_DECREASE_NOT_ALLOWED", "RESIZE_RESTRICTION_HOT_RAM_X16"],
+ "hdd_restrictions": ["RESIZE_RESTRICTION_APPLIANCE_MINIMUM_HDD_SIZE"],
+ "hdd_min": 80,
+ "hdd_max": "500.00",
+ "hdd_step": "10.00"
+ },
+ "monitoring_policy": [],
+ "licenses": [{
+ "name": "Windows_2012_Datacenter",
+ "activation_code": "",
+ "resource": "ngcs.licenses.win"
+ }],
+ "private_networks": [],
+ "vmware_tools_state_id": 11,
+ "last_logs": [{
+ "id": "2F7707D35651A70BA7A64B8332D26713",
+ "date": "2016-06-26T15:49:53+00:00",
+ "action": "REINSTALL",
+ "time": 2,
+ "result": "CONFIGURING",
+ "type": "VM"
+ }, {
+ "id": "D244452F7CAC82B82A74484007F17617",
+ "date": "2016-06-26T15:43:43+00:00",
+ "action": "CREATEVM",
+ "time": 261,
+ "result": "OK",
+ "type": "VM"
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/resources/server/update.json
----------------------------------------------------------------------
diff --git a/oneandone/src/test/resources/server/update.json b/oneandone/src/test/resources/server/update.json
new file mode 100644
index 0000000..7f8f93f
--- /dev/null
+++ b/oneandone/src/test/resources/server/update.json
@@ -0,0 +1,51 @@
+{
+ "id": "D2522497990A9FDCB26CE579524E4024",
+ "cloudpanel_id": "01CFD25",
+ "name": "Updatedjava",
+ "description": "Updated desc",
+ "datacenter": {
+ "id": "908DC2072407C94C8054610AD5A53B8C",
+ "country_code": "US",
+ "location": "United States of America"
+ },
+ "creation_date": "2016-05-18T20:42:44+00:00",
+ "first_password": null,
+ "status": {
+ "state": "POWERED_ON",
+ "percent": null
+ },
+ "hardware": {
+ "fixed_instance_size_id": null,
+ "vcore": 4,
+ "cores_per_processor": 2,
+ "ram": 4,
+ "hdds": [{
+ "id": "7840E7C4DFF5972625720E297AAF870E",
+ "size": 30,
+ "is_main": true
+ }]
+ },
+ "image": {
+ "id": "81504C620D98BCEBAA5202D145203B4B",
+ "name": "w2012r2datacenter64iso"
+ },
+ "dvd": {
+ "id": "81504C620D98BCEBAA5202D145203B4B",
+ "name": "w2012r2datacenter64iso"
+ },
+ "snapshot": null,
+ "ips": [{
+ "id": "8C4F2B7115EB90C585EE6FFB6A5904A8",
+ "ip": "70.35.203.100",
+ "type": "IPV4",
+ "reverse_dns": null,
+ "firewall_policy": {
+ "id": "34A7E423DA3253E6D38563ED06F1041F",
+ "name": "Linux"
+ },
+ "load_balancers": []
+ }],
+ "alerts": [],
+ "monitoring_policy": null,
+ "private_networks": null
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 716eac6..eefd791 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,8 +16,7 @@
See the License for the specific language governing permissions and
limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jclouds</groupId>
@@ -83,6 +82,7 @@
<module>joyentcloud</module>
<module>abiquo</module>
<module>profitbricks-rest</module>
+ <module>oneandone</module>
</modules>
<build>
@@ -194,5 +194,4 @@
</build>
</profile>
</profiles>
-</project>
-
+</project>
\ No newline at end of file
[2/3] jclouds-labs git commit: JCLOUDS-1124 oneandone-server-api
Posted by na...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/ServerApi.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/ServerApi.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/ServerApi.java
new file mode 100644
index 0000000..5992f43
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/features/ServerApi.java
@@ -0,0 +1,386 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.TypeAdapter;
+import com.google.gson.TypeAdapterFactory;
+import com.google.gson.reflect.TypeToken;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Type;
+import java.util.List;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import org.apache.jclouds.oneandone.rest.domain.Dvd;
+import org.apache.jclouds.oneandone.rest.domain.Hardware;
+import org.apache.jclouds.oneandone.rest.domain.HardwareFlavour;
+import org.apache.jclouds.oneandone.rest.domain.Hdd;
+import org.apache.jclouds.oneandone.rest.domain.Image;
+import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.Server.CreateFixedInstanceServer;
+import org.apache.jclouds.oneandone.rest.domain.Server.CreateServer;
+import org.apache.jclouds.oneandone.rest.domain.ServerFirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.ServerIp;
+import org.apache.jclouds.oneandone.rest.domain.ServerLoadBalancer;
+import org.apache.jclouds.oneandone.rest.domain.ServerPrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Snapshot;
+import org.apache.jclouds.oneandone.rest.domain.Status;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.filters.AuthenticateRequest;
+import org.apache.jclouds.oneandone.rest.util.ServerFirewallPolicyAdapter;
+import org.apache.jclouds.oneandone.rest.util.SnapshotAdapter;
+import org.jclouds.Fallbacks;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.rest.annotations.BinderParam;
+import org.jclouds.rest.annotations.Fallback;
+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.binders.BindToJsonPayload;
+import org.jclouds.util.Strings2;
+
+@Path("servers")
+@Produces("application/json")
+@Consumes("application/json")
+@RequestFilters(AuthenticateRequest.class)
+public interface ServerApi extends Closeable {
+
+ @Named("servers:list")
+ @GET
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<Server> list();
+
+ @Named("servers:list")
+ @GET
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+
+ List<Server> list(GenericQueryOptions options);
+
+ @Named("servers:flavours:list")
+ @GET
+ @Path("/fixed_instance_sizes")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+
+ List<HardwareFlavour> listHardwareFlavours();
+
+ @Named("servers:flavours:get")
+ @GET
+ @Path("fixed_instance_sizes/{id}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ HardwareFlavour getHardwareFlavour(@PathParam("id") String flavourId);
+
+ @Named("servers:get")
+ @GET
+ @Path("/{serverId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Server get(@PathParam("serverId") String serverId);
+
+ @Named("servers:status:get")
+ @GET
+ @Path("/{serverId}/status")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Status getStatus(@PathParam("serverId") String serverId);
+
+ @Named("servers:create")
+ @POST
+ Server create(@BinderParam(BindToJsonPayload.class) CreateServer server);
+
+ @Named("servers:fixedinstace:create")
+ @POST
+ Server createFixedInstanceServer(@BinderParam(BindToJsonPayload.class) CreateFixedInstanceServer server);
+
+ @Named("server:update")
+ @PUT
+ @Path("/{serverId}")
+ Server update(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Server.UpdateServer server);
+
+ @Named("server:Status:update")
+ @PUT
+ @Path("/{serverId}/status/action")
+ Server updateStatus(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Server.UpdateStatus server);
+
+ @Named("server:delete")
+ @DELETE
+ @Path("/{serverId}")
+ @MapBinder(BindToJsonPayload.class)
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Server delete(@PathParam("serverId") String serverId);
+
+ @Named("servers:hardware:get")
+ @GET
+ @Path("/{serverId}/hardware")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Hardware getHardware(@PathParam("serverId") String serverId);
+
+ @Named("server:hardware:update")
+ @PUT
+ @Path("/{serverId}/hardware")
+ Server updateHardware(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Hardware.UpdateHardware server);
+
+ @Named("servers:hardware:hdd:list")
+ @GET
+ @Path("/{serverId}/hardware/hdds")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<Hdd> listHdds(@PathParam("serverId") String serverId);
+
+ @Named("servers:hardware:hdds:create")
+ @POST
+ @Path("/{serverId}/hardware/hdds")
+ Server addHdd(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Hdd.CreateHddList hdds);
+
+ @Named("servers:hardware:hdds:get")
+ @GET
+ @Path("/{serverId}/hardware/hdds/{hddId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Hdd getHdd(@PathParam("serverId") String serverId, @PathParam("hddId") String hddId);
+
+ @Named("server:hardware:hdds:update")
+ @PUT
+ @Path("/{serverId}/hardware/hdds/{hddId}")
+ @MapBinder(BindToJsonPayload.class)
+ Server updateHdd(@PathParam("serverId") String serverId, @PathParam("hddId") String hddId, @PayloadParam("size") double size);
+
+ @Named("server:hardware:hdds:delete")
+ @DELETE
+ @Path("/{serverId}/hardware/hdds/{hddId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deleteHdd(@PathParam("serverId") String serverId, @PathParam("hddId") String hddId);
+
+ @Named("servers:image:get")
+ @GET
+ @Path("/{serverId}/image")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Image getImage(@PathParam("serverId") String serverId);
+
+ @Named("server:image:update")
+ @PUT
+ @Path("/{serverId}/image")
+ Server.UpdateServerResponse updateImage(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Server.UpdateImage server);
+
+ @Named("servers:ip:list")
+ @GET
+ @Path("/{serverId}/ips")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<ServerIp> listIps(@PathParam("serverId") String serverId);
+
+ @Named("servers:ip:create")
+ @POST
+ @Path("/{serverId}/ips")
+ @MapBinder(BindToJsonPayload.class)
+ Server addIp(@PathParam("serverId") String serverId, @PayloadParam("type") Types.IPType type);
+
+ @Named("servers:ip:get")
+ @GET
+ @Path("/{serverId}/ips/{ipId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ ServerIp getIp(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId);
+
+ @Named("server:ip:delete")
+ @DELETE
+ @Path("/{serverId}/ips/{ipId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deleteIp(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId);
+
+ @Named("servers:ip:firewallPolicy:list")
+ @GET
+ @Path("/{serverId}/ips/{ipId}/firewall_policy")
+ @ResponseParser(ServerApi.FirewallPolicyListParser.class)
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<ServerFirewallPolicy> listIpFirewallPolicies(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId);
+
+ @Named("servers:ip:firewallPolicy:update")
+ @PUT
+ @Path("/{serverId}/ips/{ipId}/firewall_policy")
+ @MapBinder(BindToJsonPayload.class)
+ Server addFirewallPolicy(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId, @PayloadParam("id") String policyId);
+
+ @Named("servers:ip:firewallPolicy:delete")
+ @DELETE
+ @Path("/{serverId}/ips/{ipId}/firewall_policy")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deleteIpFirewallPolicy(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId);
+
+ @Named("servers:ip:loadBalancer:list")
+ @GET
+ @Path("/{serverId}/ips/{ipId}/load_balancers")
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<ServerLoadBalancer> listIpLoadBalancer(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId);
+
+ @Named("servers:ip:loadBalancer:create")
+ @POST
+ @Path("/{serverId}/ips/{ipId}/load_balancers")
+ @MapBinder(BindToJsonPayload.class)
+ Server addIpLoadBalancer(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId, @PayloadParam("load_balancer_id") String loadBalancerId);
+
+ @Named("servers:ip:loadBalancer:delete")
+ @DELETE
+ @Path("/{serverId}/ips/{ipId}/load_balancers/{loadBalancerId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deleteIpLoadBalancer(@PathParam("serverId") String serverId, @PathParam("ipId") String ipId, @PathParam("loadBalancerId") String loadBalancerId);
+
+ @Named("servers:dvd:get")
+ @GET
+ @Path("/{serverId}/dvd")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ Dvd getDvd(@PathParam("serverId") String serverId);
+
+ @Named("servers:dvd:delete")
+ @DELETE
+ @Path("/{serverId}/dvd")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server unloadDvd(@PathParam("serverId") String serverId);
+
+ @Named("servers:dvd:update")
+ @PUT
+ @Path("/{serverId}/dvd")
+ @MapBinder(BindToJsonPayload.class)
+ Server loadDvd(@PathParam("serverId") String serverId, @PayloadParam("id") String dvdId);
+
+ @Named("servers:privatenetwork:list")
+ @GET
+ @Path("/{serverId}/private_networks")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ List<ServerPrivateNetwork> listPrivateNetworks(@PathParam("serverId") String serverId);
+
+ @Named("servers:privatenetwork:create")
+ @POST
+ @Path("/{serverId}/private_networks")
+ @MapBinder(BindToJsonPayload.class)
+ Server assignPrivateNetwork(@PathParam("serverId") String serverId, @PayloadParam("id") String privateNetworkId);
+
+ @Named("servers:privatenetwork:get")
+ @GET
+ @Path("/{serverId}/private_networks/{privateNetworkId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ PrivateNetwork getPrivateNetwork(@PathParam("serverId") String serverId, @PathParam("privateNetworkId") String privateNetworkId);
+
+ @Named("servers:privatenetwork:delete")
+ @DELETE
+ @Path("/{serverId}/private_networks/{privateNetworkId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deletePrivateNetwork(@PathParam("serverId") String serverId, @PathParam("privateNetworkId") String privateNetworkId);
+
+ @Named("servers:snapshot:list")
+ @GET
+ @Path("/{serverId}/snapshots")
+ @ResponseParser(ServerApi.SnapshotListParser.class)
+ @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
+ List<Snapshot> listSnapshots(@PathParam("serverId") String serverId);
+
+ @Named("servers:snapshot:create")
+ @POST
+ @Path("/{serverId}/snapshots")
+ Server createSnapshot(@PathParam("serverId") String serverId);
+
+ @Named("servers:snapshot:update")
+ @PUT
+ @Path("/{serverId}/snapshots/{snapshotId}")
+ @MapBinder(BindToJsonPayload.class)
+ Server restoreSnapshot(@PathParam("serverId") String serverId, @PathParam("snapshotId") String snapshotId);
+
+ @Named("servers:snapshot:delete")
+ @DELETE
+ @Path("/{serverId}/snapshots/{snapshotId}")
+ @Fallback(Fallbacks.NullOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ Server deleteSnapshot(@PathParam("serverId") String serverId, @PathParam("snapshotId") String snapshotId);
+
+ @Named("servers:clone:create")
+ @POST
+ @Path("/{serverId}/clone")
+ Server clone(@PathParam("serverId") String serverId, @BinderParam(BindToJsonPayload.class) Server.Clone clone);
+
+ static final class FirewallPolicyListParser extends ParseJson<List<ServerFirewallPolicy>> {
+
+ static final TypeLiteral<List<ServerFirewallPolicy>> list = new TypeLiteral<List<ServerFirewallPolicy>>() {
+ };
+
+ @Inject
+ FirewallPolicyListParser(Json json) {
+ super(json, list);
+ }
+
+ @Override
+ public <V> V apply(InputStream stream, Type type) throws IOException {
+ try {
+ GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapterFactory(new TypeAdapterFactory() {
+ @Override
+ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> tt) {
+ return new ServerFirewallPolicyAdapter(tt);
+ }
+ });
+ Gson gson = gsonBuilder.create();
+ return (V) gson.fromJson(Strings2.toStringAndClose(stream), type);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
+ }
+
+ static final class SnapshotListParser extends ParseJson<List<Snapshot>> {
+
+ static final TypeLiteral<List<Snapshot>> list = new TypeLiteral<List<Snapshot>>() {
+ };
+
+ @Inject
+ SnapshotListParser(Json json) {
+ super(json, list);
+ }
+
+ @Override
+ public <V> V apply(InputStream stream, Type type) throws IOException {
+ try {
+ GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapterFactory(new TypeAdapterFactory() {
+ @Override
+ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> tt) {
+ return new SnapshotAdapter(tt);
+ }
+ });
+ Gson gson = gsonBuilder.create();
+ return (V) gson.fromJson(Strings2.toStringAndClose(stream), type);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/filters/AuthenticateRequest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/filters/AuthenticateRequest.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/filters/AuthenticateRequest.java
new file mode 100644
index 0000000..941387a
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/filters/AuthenticateRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.filters;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+import javax.inject.Singleton;
+import org.apache.jclouds.oneandone.rest.refrence.AuthHeaders;
+import org.jclouds.domain.Credentials;
+import org.jclouds.http.HttpException;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpRequestFilter;
+import org.jclouds.location.Provider;
+
+@Singleton
+public class AuthenticateRequest implements HttpRequestFilter {
+
+ private final Credentials authToken;
+
+ @Inject
+ AuthenticateRequest(@Provider Supplier<Credentials> splr) {
+ authToken = splr.get();
+ checkNotNull(authToken.identity, "credential returned null");
+
+ }
+
+ @Override
+ public HttpRequest filter(HttpRequest request) throws HttpException {
+ return request.toBuilder().replaceHeader(AuthHeaders.AUTH_TOKEN, authToken.identity).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/handlers/OneAndOneHttpErrorHandler.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/handlers/OneAndOneHttpErrorHandler.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/handlers/OneAndOneHttpErrorHandler.java
new file mode 100644
index 0000000..f92927c
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/handlers/OneAndOneHttpErrorHandler.java
@@ -0,0 +1,72 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.handlers;
+
+import javax.inject.Singleton;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceNotFoundException;
+import static org.jclouds.util.Closeables2.closeQuietly;
+
+@Singleton
+public class OneAndOneHttpErrorHandler implements HttpErrorHandler {
+
+ @Override
+ public void handleError(final HttpCommand command, final HttpResponse response) {
+ Exception exception = null;
+ try {
+ switch (response.getStatusCode()) {
+ case 400:
+ case 405:
+ exception = new IllegalArgumentException(response.getMessage(), exception);
+ break;
+ case 401:
+ exception = new AuthorizationException("This request requires authentication.", exception);
+ break;
+ case 402:
+ case 409:
+ exception = new IllegalStateException(response.getMessage(), exception);
+ break;
+ case 404:
+ case 410:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(response.getMessage(), exception);
+ }
+ break;
+ case 413:
+ case 503:
+ // if nothing (default message was OK) was parsed from command executor, assume it was an 503 (Maintenance) html response.
+ if (response.getMessage().equals("OK")) {
+ exception = new HttpResponseException("The OneAndOne team is currently carrying out maintenance.", command, response);
+ } else {
+ exception = new InsufficientResourcesException(response.getMessage(), exception);
+ }
+ break;
+ default:
+ exception = new HttpResponseException("A generic error occured.", command, response);
+ break;
+ }
+ } finally {
+ closeQuietly(response.getPayload());
+ command.setException(exception);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/ids/ServerPrivateNetworkRef.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/ids/ServerPrivateNetworkRef.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/ids/ServerPrivateNetworkRef.java
new file mode 100644
index 0000000..275f9d8
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/ids/ServerPrivateNetworkRef.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.apache.jclouds.oneandone.rest.ids;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class ServerPrivateNetworkRef {
+
+ public abstract String serverId();
+
+ public abstract String privateNetworkId();
+
+ public static ServerPrivateNetworkRef create(String serverId, String privateNetworkId) {
+ return new AutoValue_ServerPrivateNetworkRef(serverId, privateNetworkId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/refrence/AuthHeaders.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/refrence/AuthHeaders.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/refrence/AuthHeaders.java
new file mode 100644
index 0000000..917fe9d
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/refrence/AuthHeaders.java
@@ -0,0 +1,26 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.refrence;
+
+public final class AuthHeaders {
+
+ public static final String AUTH_TOKEN = "X-TOKEN";
+
+ private AuthHeaders() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/ServerFirewallPolicyAdapter.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/ServerFirewallPolicyAdapter.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/ServerFirewallPolicyAdapter.java
new file mode 100644
index 0000000..b4594dc
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/ServerFirewallPolicyAdapter.java
@@ -0,0 +1,79 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.util;
+
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import com.google.inject.TypeLiteral;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.jclouds.oneandone.rest.domain.ServerFirewallPolicy;
+
+public class ServerFirewallPolicyAdapter<T> extends TypeAdapter<List<T>> {
+
+ private com.google.gson.reflect.TypeToken<T> adapterclass;
+ private Gson gson;
+
+ public ServerFirewallPolicyAdapter(com.google.gson.reflect.TypeToken<T> adapterclass) {
+ this.adapterclass = adapterclass;
+ gson = new Gson();
+
+ }
+
+ static final TypeLiteral<List<ServerFirewallPolicy>> list = new TypeLiteral<List<ServerFirewallPolicy>>() {
+ };
+
+ @Override
+ public List<T> read(JsonReader reader) throws IOException {
+ List<ServerFirewallPolicy> list = new ArrayList<ServerFirewallPolicy>();
+ if (reader.peek() == JsonToken.BEGIN_OBJECT) {
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ Map<String, String> jsonMap = gson.fromJson(reader, mapType);
+ ServerFirewallPolicy inning = ServerFirewallPolicy.create(jsonMap.get("id"), jsonMap.get("name"));
+ list.add(inning);
+
+ } else if (reader.peek() == JsonToken.BEGIN_ARRAY) {
+
+ reader.beginArray();
+ while (reader.hasNext()) {
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ Map<String, String> jsonMap = gson.fromJson(reader, mapType);
+ ServerFirewallPolicy inning = ServerFirewallPolicy.create(jsonMap.get("id"), jsonMap.get("name"));
+ list.add(inning);
+ }
+ reader.endArray();
+
+ } else {
+ reader.skipValue();
+ }
+ return (List<T>) list;
+ }
+
+ @Override
+ public void write(JsonWriter writer, List<T> t) throws IOException {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/SnapshotAdapter.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/SnapshotAdapter.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/SnapshotAdapter.java
new file mode 100644
index 0000000..2923e39
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/util/SnapshotAdapter.java
@@ -0,0 +1,76 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.util;
+
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import com.google.inject.TypeLiteral;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.apache.jclouds.oneandone.rest.domain.Snapshot;
+
+public class SnapshotAdapter<T> extends TypeAdapter<List<T>> {
+
+ private com.google.gson.reflect.TypeToken<T> adapterclass;
+ private Gson gson;
+
+ public SnapshotAdapter(com.google.gson.reflect.TypeToken<T> adapterclass) {
+ this.adapterclass = adapterclass;
+ gson = new Gson();
+ }
+
+ static final TypeLiteral<List<Snapshot>> snapshot = new TypeLiteral<List<Snapshot>>() {
+ };
+
+ @Override
+ public List<T> read(JsonReader reader) throws IOException {
+ List<Snapshot> list = new ArrayList<Snapshot>();
+ if (reader.peek() == JsonToken.BEGIN_OBJECT) {
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ Map<String, String> jsonMap = gson.fromJson(reader, mapType);
+ Snapshot inning = Snapshot.create(jsonMap.get("id"), jsonMap.get("creation_date"), jsonMap.get("deletion_date"));
+ list.add(inning);
+ } else if (reader.peek() == JsonToken.BEGIN_ARRAY) {
+
+ reader.beginArray();
+ while (reader.hasNext()) {
+ Type mapType = new TypeToken<Map<String, Object>>() {
+ }.getType();
+ Map<String, String> jsonMap = gson.fromJson(reader, mapType);
+ Snapshot inning = Snapshot.create(jsonMap.get("id"), jsonMap.get("creation_date"), jsonMap.get("deletion_date"));
+ list.add(inning);
+ }
+ reader.endArray();
+ } else {
+ reader.skipValue();
+ }
+ return (List<T>) list;
+ }
+
+ @Override
+ public void write(JsonWriter writer, List<T> t) throws IOException {
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadataTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadataTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadataTest.java
new file mode 100644
index 0000000..e9954c5
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadataTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.apache.jclouds.oneandone.rest;
+
+import org.jclouds.providers.internal.BaseProviderMetadataTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "OneAndOneProviderMetadataTest")
+public class OneAndOneProviderMetadataTest extends BaseProviderMetadataTest {
+
+ public OneAndOneProviderMetadataTest() {
+ super(new OneAndOneProviderMetadata(), new OneAndOneApiMetadata());
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiLiveTest.java
new file mode 100644
index 0000000..de1ee6f
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiLiveTest.java
@@ -0,0 +1,272 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.FixedInstanceHardware;
+import org.apache.jclouds.oneandone.rest.domain.Hardware;
+import org.apache.jclouds.oneandone.rest.domain.HardwareFlavour;
+import org.apache.jclouds.oneandone.rest.domain.Hdd;
+import org.apache.jclouds.oneandone.rest.domain.Image;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.Status;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.domain.Types.ServerAction;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneLiveTest;
+import org.testng.Assert;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", testName = "ServerApiLiveTest")
+public class ServerApiLiveTest extends BaseOneAndOneLiveTest {
+
+ private List<Server> servers;
+ private Server currentServer;
+ private Server fixedInstanceServer;
+ private HardwareFlavour currentFlavour;
+ private Hdd currentHdd;
+ private Image currentImage;
+
+ private ServerApi serverApi() {
+
+ return api.serverApi();
+ }
+
+ @BeforeClass
+ public void setupTest() {
+ currentServer = createServer("jclouds test");
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void teardownTest() throws InterruptedException {
+ //turn on currentServer in order to be able to delete
+ assertNodeAvailable(currentServer);
+ turnOnServer(currentServer.id());
+
+ if (fixedInstanceServer != null) {
+
+ //delete fixed instance server once ready
+ assertNodeAvailable(fixedInstanceServer);
+ deleteServer(fixedInstanceServer.id());
+ }
+ if (currentServer != null) {
+ //delete currentserver once ready
+ assertNodeAvailable(currentServer);
+ deleteServer(currentServer.id());
+ }
+ }
+
+ @Test(dependsOnMethods = "testListHardwareFlavours")
+ public void testCreateFixedInstanceServer() {
+
+ Server.CreateFixedInstanceServer request = Server.CreateFixedInstanceServer.builder()
+ .name("java test fixed instance")
+ .description("testing with jclouds")
+ .hardware(FixedInstanceHardware.create(currentFlavour.id()))
+ .applianceId("7C5FA1D21B98DE39D7516333AAB7DA54")
+ .password("Test123!")
+ .powerOn(Boolean.TRUE).build();
+ fixedInstanceServer = serverApi().createFixedInstanceServer(request);
+
+ assertNotNull(fixedInstanceServer);
+ assertNotNull(fixedInstanceServer.id());
+ assertEquals(currentFlavour.hardware().vcore(), fixedInstanceServer.hardware().vcore());
+ assertEquals(currentFlavour.hardware().coresPerProcessor(), fixedInstanceServer.hardware().coresPerProcessor());
+ assertEquals(currentFlavour.hardware().ram(), fixedInstanceServer.hardware().ram());
+
+ }
+
+ @Test
+ public void testList() {
+ servers = serverApi().list();
+
+ assertNotNull(servers);
+ Assert.assertTrue(servers.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testListWithOption() {
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "test", null);
+ List<Server> serversWithQuery = serverApi().list(options);
+
+ assertNotNull(serversWithQuery);
+ Assert.assertTrue(serversWithQuery.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListWithOption")
+ public void testGetServer() {
+ Server result = serverApi().get(currentServer.id());
+
+ assertNotNull(result);
+ assertEquals(result.id(), currentServer.id());
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testListHardwareFlavours() {
+ List<HardwareFlavour> flavours = serverApi().listHardwareFlavours();
+ currentFlavour = flavours.get(1);
+ assertNotNull(flavours);
+ assertFalse(flavours.isEmpty());
+ Assert.assertTrue(flavours.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListHardwareFlavours")
+ public void testGetHardwareFlavour() {
+ HardwareFlavour flavours = serverApi().getHardwareFlavour(currentFlavour.id());
+
+ assertNotNull(flavours);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testGetServerStatus() {
+ Status status = serverApi().getStatus(currentServer.id());
+
+ assertNotNull(status);
+ }
+
+ @Test(dependsOnMethods = "testGetServerStatus")
+ public void testGetServerHardware() {
+ Hardware hardware = serverApi().getHardware(currentServer.id());
+
+ assertNotNull(hardware);
+ }
+
+ @Test(dependsOnMethods = "testGetServerStatus")
+ public void testUpdateServer() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ String updatedName = "Updatedjava";
+ String updatedDesc = "Updated desc";
+
+ Server updateResult = serverApi().update(currentServer.id(), Server.UpdateServer.create(updatedName, updatedDesc));
+
+ assertNotNull(updateResult);
+ assertEquals(updateResult.name(), updatedName);
+ assertEquals(updateResult.description(), updatedDesc);
+
+ }
+
+ @Test(dependsOnMethods = "testUpdateStaus")
+ public void testUpdateHardware() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ Server updateResult = serverApi().updateHardware(currentServer.id(), Hardware.UpdateHardware.create(4, 2, 6));
+
+ assertNotNull(updateResult);
+ }
+
+ @Test(dependsOnMethods = "testAddHdds")
+ public void testListHardwareHdds() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ //give time for harddisk to be added
+// Thread.sleep(60000);
+ List<Hdd> hdds = serverApi().listHdds(currentServer.id());
+ for (Hdd hdd : hdds) {
+ if (!hdd.isMain()) {
+ currentHdd = hdd;
+ break;
+ }
+ }
+ assertNotNull(hdds);
+ assertFalse(hdds.isEmpty());
+ Assert.assertTrue(hdds.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testUpdateHardware")
+ public void testAddHdds() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ List<Hdd.CreateHdd> requestList = new ArrayList<Hdd.CreateHdd>();
+ requestList.add(Hdd.CreateHdd.create(20, Boolean.TRUE));
+ Hdd.CreateHddList request = Hdd.CreateHddList.create(requestList);
+ //double check
+ assertNodeAvailable(currentServer);
+ Server response = serverApi().addHdd(currentServer.id(), request);
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListHardwareHdds")
+ public void testGetHdd() throws InterruptedException {
+ Hdd response = serverApi().getHdd(currentServer.id(), currentHdd.id());
+
+ assertNotNull(response);
+ assertEquals(response.size(), currentHdd.size());
+ }
+
+ @Test(dependsOnMethods = "testGetHdd")
+ public void testUpdateHdd() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ Server response = serverApi().updateHdd(currentServer.id(), currentHdd.id(), currentHdd.size() + 20);
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testUpdateHdd")
+ public void testDeleteHdd() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Hdd hddToDelete = null;
+ List<Hdd> hdds = serverApi().listHdds(currentServer.id());
+ for (Hdd hdd : hdds) {
+ if (!hdd.isMain()) {
+ hddToDelete = hdd;
+ break;
+ }
+ }
+ if (hddToDelete != null) {
+ Server response = serverApi().deleteHdd(currentServer.id(), hddToDelete.id());
+ assertNotNull(response);
+ }
+ }
+
+ @Test(dependsOnMethods = "testDeleteHdd")
+ public void testGetImage() throws InterruptedException {
+ if (fixedInstanceServer != null) {
+ currentImage = serverApi().getImage(fixedInstanceServer.id());
+
+ assertNotNull(currentImage);
+ }
+ }
+
+ @Test(dependsOnMethods = "testGetImage")
+ public void testUpdateImage() throws InterruptedException {
+ if (fixedInstanceServer != null) {
+ assertNodeAvailable(fixedInstanceServer);
+
+ Server.UpdateServerResponse response = serverApi().updateImage(fixedInstanceServer.id(), Server.UpdateImage.create(currentImage.id(), "Test123!"));
+
+ assertNotNull(response);
+ }
+ }
+
+ @Test(dependsOnMethods = "testUpdateServer")
+ public void testUpdateStaus() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ Server updateResult = serverApi().updateStatus(currentServer.id(), Server.UpdateStatus.create(ServerAction.POWER_OFF, Types.ServerActionMethod.HARDWARE));
+ assertNodeAvailable(currentServer);
+
+ assertNotNull(updateResult);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiMockTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiMockTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiMockTest.java
new file mode 100644
index 0000000..b577e1b
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerApiMockTest.java
@@ -0,0 +1,816 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import com.squareup.okhttp.mockwebserver.MockResponse;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Dvd;
+import org.apache.jclouds.oneandone.rest.domain.FixedInstanceHardware;
+import org.apache.jclouds.oneandone.rest.domain.Hardware;
+import org.apache.jclouds.oneandone.rest.domain.HardwareFlavour;
+import org.apache.jclouds.oneandone.rest.domain.Hdd;
+import org.apache.jclouds.oneandone.rest.domain.Image;
+import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.ServerFirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.ServerIp;
+import org.apache.jclouds.oneandone.rest.domain.ServerLoadBalancer;
+import org.apache.jclouds.oneandone.rest.domain.ServerPrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Snapshot;
+import org.apache.jclouds.oneandone.rest.domain.Status;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.domain.options.GenericQueryOptions;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneApiMockTest;
+import org.testng.Assert;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "ServerApiMockTest", singleThreaded = true)
+public class ServerApiMockTest extends BaseOneAndOneApiMockTest {
+
+ @Test
+ public void testList() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.json"))
+ );
+
+ List<Server> servers = serverApi().list();
+
+ assertNotNull(servers);
+ assertEquals(servers.size(), 10);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers");
+ }
+
+ @Test
+ public void testList404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404));
+
+ List<Server> servers = serverApi().list();
+
+ assertNotNull(servers);
+ assertEquals(servers.size(), 0);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers");
+ }
+
+ @Test
+ public void testListWithOption() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.options-query-test.json"))
+ );
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "test", null);
+ List<Server> servers = serverApi().list(options);
+
+ assertNotNull(servers);
+ assertEquals(servers.size(), 9);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers?q=test");
+ }
+
+ @Test
+ public void testListWithOption404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ GenericQueryOptions options = new GenericQueryOptions();
+ options.options(0, 0, null, "test", null);
+ List<Server> servers = serverApi().list(options);
+
+ assertNotNull(servers);
+ assertEquals(servers.size(), 0);
+
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers?q=test");
+ }
+
+ public void testGetServer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.json"))
+ );
+ Server result = serverApi().get("serverId");
+
+ assertNotNull(result);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId");
+ }
+
+ @Test
+ public void testGetServer404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server result = serverApi().get("serverId");
+
+ assertEquals(result, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId");
+ }
+
+ @Test
+ public void testListHardwareFlavours() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.flavours.json"))
+ );
+ List<HardwareFlavour> flavours = serverApi().listHardwareFlavours();
+
+ assertNotNull(flavours);
+ assertFalse(flavours.isEmpty());
+ Assert.assertTrue(flavours.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/fixed_instance_sizes");
+ }
+
+ @Test
+ public void testGetHardwareFlavour() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.flavour.json"))
+ );
+ HardwareFlavour flavours = serverApi().getHardwareFlavour("flavourId");
+
+ assertNotNull(flavours);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/fixed_instance_sizes/flavourId");
+ }
+
+ @Test
+ public void testGetServerStatus() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.status.json"))
+ );
+ Status status = serverApi().getStatus("serverId");
+
+ assertNotNull(status);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/status");
+ }
+
+ @Test
+ public void testGetServersHardware() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.hardware.json"))
+ );
+ Hardware hardware = serverApi().getHardware("serverId");
+
+ assertNotNull(hardware);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/hardware");
+ }
+
+ @Test
+ public void testUpdateServer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server response = serverApi().update("serverId", Server.UpdateServer.create("My Server remame", "My server rename description"));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId", "{\n"
+ + " \"name\": \"My Server remame\",\n"
+ + " \"description\": \"My server rename description\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testUpdateHardware() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server response = serverApi().updateHardware("serverId", Hardware.UpdateHardware.create(2.0, 2.0, 2.0));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/hardware", "{\n"
+ + " \"vcore\": 2.0,\n"
+ + " \"cores_per_processor\": 2.0,\n"
+ + " \"ram\": 2.0\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testListHardwareHdds() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.hardware.hdds.json"))
+ );
+ List<Hdd> hdds = serverApi().listHdds("serverId");
+
+ assertNotNull(hdds);
+ assertFalse(hdds.isEmpty());
+ Assert.assertTrue(hdds.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/hardware/hdds");
+ }
+
+ @Test
+ public void testAddHdds() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/add.hdds.json"))
+ );
+ List<Hdd.CreateHdd> requestList = new ArrayList<Hdd.CreateHdd>();
+ requestList.add(Hdd.CreateHdd.create(40, Boolean.FALSE));
+ Hdd.CreateHddList request = Hdd.CreateHddList.create(requestList);
+
+ Server response = serverApi().addHdd("serverId", request);
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/hardware/hdds",
+ "{\n"
+ + " \"hdds\":[\n"
+ + " {\n"
+ + " \"size\": 40,\n"
+ + " \"is_main\": false\n"
+ + " }\n"
+ + " ]\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testGetHdd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.hdd.json"))
+ );
+ Hdd hdd = serverApi().getHdd("serverId", "hddId");
+
+ assertNotNull(hdd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/hardware/hdds/hddId");
+ }
+
+ @Test
+ public void testUpdateHdd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server hdd = serverApi().updateHdd("serverId", "hddId", 60);
+
+ assertNotNull(hdd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/hardware/hdds/hddId",
+ "{\n"
+ + " \"size\": 60\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeleteHdd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server hdd = serverApi().deleteHdd("serverId", "hddId");
+
+ assertNotNull(hdd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/hardware/hdds/hddId");
+ }
+
+ @Test
+ public void testDeleteHdd404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404));
+ Server hdd = serverApi().deleteHdd("serverId", "hddId");
+
+ assertEquals(hdd, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/hardware/hdds/hddId");
+ }
+
+ @Test
+ public void testGetImage() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.image.json"))
+ );
+ Image image = serverApi().getImage("serverId");
+
+ assertNotNull(image);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/image");
+ }
+
+ @Test
+ public void testUpdateImage() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.image.json"))
+ );
+ Server.UpdateServerResponse hdd = serverApi().updateImage("serverId", Server.UpdateImage.create("id", "password"));
+
+ assertNotNull(hdd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/image",
+ "{\n"
+ + " \"id\": \"id\",\n"
+ + " \"password\": \"password\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testListIps() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.ip.json"))
+ );
+ List<ServerIp> ips = serverApi().listIps("serverId");
+
+ assertNotNull(ips);
+ assertFalse(ips.isEmpty());
+ Assert.assertTrue(ips.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/ips");
+ }
+
+ @Test
+ public void testAddIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/add.hdds.json"))
+ );
+
+ Server response = serverApi().addIp("serverId", Types.IPType.IPV4);
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/ips",
+ "{\n"
+ + " \"type\": \"IPV4\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testGetIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.ip.json"))
+ );
+ ServerIp ip = serverApi().getIp("serverId", "ipId");
+
+ assertNotNull(ip);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/ips/ipId");
+ }
+
+ @Test
+ public void testDeleteIp() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+
+ Server hdd = serverApi().deleteIp("serverId", "ipId");
+
+ assertNotNull(hdd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId");
+ }
+
+ @Test
+ public void testDeleteIp404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+
+ Server hdd = serverApi().deleteIp("serverId", "ipId");
+
+ assertEquals(hdd, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId");
+ }
+
+ @Test
+ public void testListIpFirewallPolicies() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.ip.firewallPolicies.json"))
+ );
+ List<ServerFirewallPolicy> policies = serverApi().listIpFirewallPolicies("serverId", "ipId");
+
+ assertNotNull(policies);
+ assertFalse(policies.isEmpty());
+ Assert.assertTrue(policies.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/ips/ipId/firewall_policy");
+ }
+
+ @Test
+ public void testAddIpFirewallPolicy() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.json"))
+ );
+
+ Server response = serverApi().addFirewallPolicy("serverId", "ipId", "firewallPolicyId");
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/ips/ipId/firewall_policy",
+ "{\n"
+ + " \"id\": \"firewallPolicyId\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeleteIpFirewallPolicy() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server response = serverApi().deleteIpFirewallPolicy("serverId", "ipId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId/firewall_policy");
+ }
+
+ @Test
+ public void testDeleteIpFirewallPolicy404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().deleteIpFirewallPolicy("serverId", "ipId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId/firewall_policy");
+ }
+
+ @Test
+ public void testListIpLoadBalancer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.ip.loadBalancers.json"))
+ );
+ List<ServerLoadBalancer> loadBalancers = serverApi().listIpLoadBalancer("serverId", "ipId");
+
+ assertNotNull(loadBalancers);
+ assertFalse(loadBalancers.isEmpty());
+ Assert.assertTrue(loadBalancers.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/ips/ipId/load_balancers");
+ }
+
+ @Test
+ public void testAddIpLoadBalancer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.json"))
+ );
+
+ Server response = serverApi().addIpLoadBalancer("serverId", "ipId", "loadBalancerId");
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/ips/ipId/load_balancers",
+ "{\n"
+ + " \"load_balancer_id\": \"loadBalancerId\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeleteIpLoadBalancer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server response = serverApi().deleteIpLoadBalancer("serverId", "ipId", "loadBalancerId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId/load_balancers/loadBalancerId");
+ }
+
+ @Test
+ public void testDeleteIpLoadBalancer404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().deleteIpLoadBalancer("serverId", "ipId", "loadBalancerId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/ips/ipId/load_balancers/loadBalancerId");
+ }
+
+ @Test
+ public void testGetDvd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.dvd.json"))
+ );
+ Dvd dvd = serverApi().getDvd("serverId");
+
+ assertNotNull(dvd);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/dvd");
+ }
+
+ @Test
+ public void testLoadDvd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.json"))
+ );
+
+ Server response = serverApi().loadDvd("serverId", "dvdId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/dvd",
+ "{\n"
+ + " \"id\": \"dvdId\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeletedvd() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server response = serverApi().unloadDvd("serverId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/dvd");
+ }
+
+ @Test
+ public void testDeletedvd404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().unloadDvd("serverId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/dvd");
+ }
+
+ @Test
+ public void testListPrivateNetwork() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.privatenetwork.json"))
+ );
+ List<ServerPrivateNetwork> privateNetwork = serverApi().listPrivateNetworks("serverId");
+
+ assertNotNull(privateNetwork);
+ assertFalse(privateNetwork.isEmpty());
+ Assert.assertTrue(privateNetwork.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/private_networks");
+ }
+
+ @Test
+ public void testGetPrivateNetwork() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.privatenetwork.json"))
+ );
+ PrivateNetwork response = serverApi().getPrivateNetwork("serverId", "privateNetworkId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/private_networks/privateNetworkId");
+ }
+
+ @Test
+ public void testAssignPrivateNetwork() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+
+ Server response = serverApi().assignPrivateNetwork("serverId", "privateNetworkId");
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/private_networks",
+ "{\n"
+ + " \"id\": \"privateNetworkId\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeletePrivateNetwork() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server response = serverApi().deletePrivateNetwork("serverId", "privateNetworkId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/private_networks/privateNetworkId");
+ }
+
+ @Test
+ public void testDeletePrivateNetwork404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().deletePrivateNetwork("serverId", "privateNetworkId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/private_networks/privateNetworkId");
+ }
+
+ @Test
+ public void testListSnapshot() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/list.snapshot.json"))
+ );
+ List<Snapshot> snapshots = serverApi().listSnapshots("serverId");
+
+ assertNotNull(snapshots);
+ assertFalse(snapshots.isEmpty());
+ Assert.assertTrue(snapshots.size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "GET", "/servers/serverId/snapshots");
+ }
+
+ @Test
+ public void testRestoreSnapshot() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server response = serverApi().restoreSnapshot("serverId", "snapshotId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/snapshots/snapshotId");
+ }
+
+ @Test
+ public void testCreateSnapshot() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+
+ Server response = serverApi().createSnapshot("serverId");
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/snapshots");
+ }
+
+ @Test
+ public void testDeleteSnapshot() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server response = serverApi().deleteSnapshot("serverId", "snapshotId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/snapshots/snapshotId");
+ }
+
+ @Test
+ public void testDeleteSnapshot404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().deleteSnapshot("serverId", "snapshotId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId/snapshots/snapshotId");
+ }
+
+ @Test
+ public void testCreateClone() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+
+ Server response = serverApi().clone("serverId", Server.Clone.create("datadcenterId", "Copy of My server"));
+
+ assertNotNull(response);
+ Assert.assertTrue(response.hardware().hdds().size() > 0);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers/serverId/clone",
+ "{\n"
+ + " \"name\": \"Copy of My server\",\n"
+ + " \"datacenter_id\": \"datadcenterId\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testCreateServer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ List<Hdd.CreateHdd> hdds = new ArrayList<Hdd.CreateHdd>();
+ Hdd.CreateHdd hdd = Hdd.CreateHdd.create(50, Boolean.TRUE);
+ hdds.add(hdd);
+
+ Hdd.CreateHddList hddsRequest = Hdd.CreateHddList.create(hdds);
+
+ Hardware.CreateHardware hardware = Hardware.CreateHardware.create(2.0, 2.0, 2.0, hdds);
+ Server response = serverApi().create(Server.CreateServer.create(
+ "My server",
+ "My server description",
+ hardware,
+ "applianceId",
+ "datacenterId",
+ "Test123!",
+ null,
+ Boolean.TRUE,
+ null,
+ null,
+ null,
+ null));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers",
+ "{\"name\":\"My server\",\"description\":\"My server description\",\"hardware\":{\"vcore\":2.0,\"cores_per_processor\":2.0,\"ram\":2.0,\"hdds\":[{\"size\":50.0,\"is_main\":true}]},\"appliance_id\":\"applianceId\",\"datacenter_id\":\"datacenterId\",\"password\":\"Test123!\",\"power_on\":true}"
+ );
+ }
+
+ @Test
+ public void testCreateFixedInstanceServer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/get.json"))
+ );
+ FixedInstanceHardware hardware = FixedInstanceHardware.create("fixedInstanceId");
+ Server response = serverApi().createFixedInstanceServer(Server.CreateFixedInstanceServer.create(
+ "name", "name", hardware, "applianceId", "datacenterId", "password",
+ null, Boolean.TRUE, null, null, null, null));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "POST", "/servers",
+ "{\"name\":\"name\",\"description\":\"name\",\"hardware\":{\"fixed_instance_size_id\":\"fixedInstanceId\"},\"appliance_id\":\"applianceId\",\"datacenter_id\":\"datacenterId\",\"password\":\"password\",\"power_on\":true}"
+ );
+ }
+
+ @Test
+ public void testUpdateStauts() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/update.json"))
+ );
+ Server response = serverApi().updateStatus("serverId", Server.UpdateStatus.create(Types.ServerAction.POWER_OFF, Types.ServerActionMethod.SOFTWARE));
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "PUT", "/servers/serverId/status/action",
+ "{\n"
+ + " \"action\": \"POWER_OFF\",\n"
+ + " \"method\": \"SOFTWARE\"\n"
+ + "}"
+ );
+ }
+
+ @Test
+ public void testDeleteServer() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setBody(stringFromResource("/server/delete.json"))
+ );
+ Server response = serverApi().delete("serverId");
+
+ assertNotNull(response);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId");
+ }
+
+ @Test
+ public void testDeleteServer404() throws InterruptedException {
+ server.enqueue(
+ new MockResponse().setResponseCode(404)
+ );
+ Server response = serverApi().delete("serverId");
+
+ assertEquals(response, null);
+ assertEquals(server.getRequestCount(), 1);
+ assertSent(server, "DELETE", "/servers/serverId");
+ }
+
+ private ServerApi serverApi() {
+ return api.serverApi();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerNetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerNetworkApiLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerNetworkApiLiveTest.java
new file mode 100644
index 0000000..bd936e0
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerNetworkApiLiveTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.ServerFirewallPolicy;
+import org.apache.jclouds.oneandone.rest.domain.ServerIp;
+import org.apache.jclouds.oneandone.rest.domain.ServerLoadBalancer;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneLiveTest;
+import org.testng.Assert;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ServerNetworkApiLiveTest extends BaseOneAndOneLiveTest {
+
+ private Server currentServer;
+ private ServerIp currentIP;
+ private ServerFirewallPolicy currentPolicy;
+ private ServerLoadBalancer currentBalancer;
+
+ @BeforeClass
+ public void setupTest() {
+ currentServer = createServer("jclouds network test");
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void teardownTest() throws InterruptedException {
+ deleteIp();
+ //give time for operations to finish
+ if (currentServer != null) {
+ assertNodeAvailable(currentServer);
+ deleteServer(currentServer.id());
+ }
+ }
+
+ private ServerApi serverApi() {
+
+ return api.serverApi();
+ }
+
+ private void deleteIp() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ Server response = serverApi().deleteIp(currentServer.id(), currentIP.id());
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testAddIp")
+ public void testListips() throws InterruptedException {
+ List<ServerIp> ips = serverApi().listIps(currentServer.id());
+ currentIP = ips.get(0);
+ assertNotNull(ips);
+ Assert.assertTrue(ips.size() > 0);
+ }
+
+ @Test
+ public void testAddIp() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ Server response = serverApi().addIp(currentServer.id(), Types.IPType.IPV4);
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testAddIpFirewallPolicy")
+ public void testListipFirewallPolicies() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ List<ServerFirewallPolicy> policies = serverApi().listIpFirewallPolicies(currentServer.id(), currentIP.id());
+ currentPolicy = policies.get(0);
+ assertNotNull(policies);
+ assertFalse(policies.isEmpty());
+ Assert.assertTrue(policies.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListips")
+ public void testAddIpFirewallPolicy() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ //TODO:: replace with live api data
+ String firewallPolicyId = "34A7E423DA3253E6D38563ED06F1041F";
+
+ Server response = serverApi().addFirewallPolicy(currentServer.id(), currentIP.id(), firewallPolicyId);
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testListipFirewallPolicies")
+ public void testDeleteIpFirewallPolicy() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Server response = serverApi().deleteIpFirewallPolicy(currentServer.id(), currentIP.id());
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testAddIpLoadBalancer")
+ public void testListipLoadBalancer() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ List<ServerLoadBalancer> balancers = serverApi().listIpLoadBalancer(currentServer.id(), currentIP.id());
+ assertNotNull(balancers);
+ assertFalse(balancers.isEmpty());
+ }
+
+ @Test(dependsOnMethods = "testAddIp")
+ public void testAddIpLoadBalancer() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ //TODO:: replace with live api data
+ String loadBalancerId = "13C3F75BA55AF28B8B2B4E508786F48B";
+
+ Server response = serverApi().addIpLoadBalancer(currentServer.id(), currentIP.id(), loadBalancerId);
+
+ List<ServerLoadBalancer> balancers = serverApi().listIpLoadBalancer(currentServer.id(), currentIP.id());
+ currentBalancer = balancers.get(0);
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testListipLoadBalancer")
+ public void testDeleteIpLoadBalancer() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Server response = serverApi().deleteIpLoadBalancer(currentServer.id(), currentIP.id(), currentBalancer.id());
+ assertNotNull(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerOperationsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerOperationsApiLiveTest.java b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerOperationsApiLiveTest.java
new file mode 100644
index 0000000..842b61b
--- /dev/null
+++ b/oneandone/src/test/java/org/apache/jclouds/oneandone/rest/features/ServerOperationsApiLiveTest.java
@@ -0,0 +1,173 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.features;
+
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Dvd;
+import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.ServerPrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Snapshot;
+import org.apache.jclouds.oneandone.rest.ids.ServerPrivateNetworkRef;
+import org.apache.jclouds.oneandone.rest.internal.BaseOneAndOneLiveTest;
+import org.testng.Assert;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ServerOperationsApiLiveTest extends BaseOneAndOneLiveTest {
+
+ private Server currentServer;
+ private Server cloneServer;
+
+ private ServerPrivateNetwork currentPrivateNetwork;
+
+ private ServerApi serverApi() {
+
+ return api.serverApi();
+ }
+
+ @BeforeClass
+ public void setupTest() {
+ currentServer = createServer("jclouds operations test");
+ }
+
+ @AfterClass(alwaysRun = true)
+ public void teardownTest() throws InterruptedException {
+ //give time for operations to finish
+// Thread.sleep(10000);
+ if (currentServer != null) {
+ assertNodeAvailable(currentServer);
+ deleteServer(currentServer.id());
+ }
+ if (cloneServer != null) {
+ assertNodeAvailable(cloneServer);
+ deleteServer(cloneServer.id());
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateClone")
+ public void testGetDvd() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Dvd dvd = serverApi().getDvd(currentServer.id());
+
+ assertNotNull(dvd);
+ }
+
+ @Test(dependsOnMethods = "testGetDvd")
+ public void testLoadDvd() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ //TODO: get data from live api
+ String dvdId = "81504C620D98BCEBAA5202D145203B4B";
+ Server response = serverApi().loadDvd(currentServer.id(), dvdId);
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testLoadDvd")
+ public void testUnloadDvd() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Server response = serverApi().unloadDvd(currentServer.id());
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testAssignPrivateNetwork")
+ public void testListPrivateNetwork() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ List<ServerPrivateNetwork> privateNetworks = serverApi().listPrivateNetworks(currentServer.id());
+ currentPrivateNetwork = privateNetworks.get(0);
+
+ assertNotNull(privateNetworks);
+ assertFalse(privateNetworks.isEmpty());
+ Assert.assertTrue(privateNetworks.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListPrivateNetwork")
+ public void testGetPrivateNetwork() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ PrivateNetwork privatenetworkd = serverApi().getPrivateNetwork(currentServer.id(), currentPrivateNetwork.id());
+ assertNotNull(privatenetworkd);
+ }
+
+ @Test
+ public void testAssignPrivateNetwork() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ //TODO: replace with live data from api
+ String privateNetworkId = "40D2C8D5029BF03F7C9D02D54C9F237D";
+ Server response = serverApi().assignPrivateNetwork(currentServer.id(), privateNetworkId);
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testGetPrivateNetwork")
+ public void testDeletePrivateNetwork() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ assertPrivateNetworkAvailable(ServerPrivateNetworkRef.create(currentServer.id(), currentPrivateNetwork.id()));
+ assertNodeAvailable(currentServer);
+
+ Server response = serverApi().deletePrivateNetwork(currentServer.id(), currentPrivateNetwork.id());
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testCreateSnapshot")
+ public void testListSnapshot() throws InterruptedException {
+ List<Snapshot> snapshots = serverApi().listSnapshots(currentServer.id());
+
+ assertNotNull(snapshots);
+ assertFalse(snapshots.isEmpty());
+ Assert.assertTrue(snapshots.size() > 0);
+ }
+
+ @Test(dependsOnMethods = "testListSnapshot")
+ public void testRestoreSnapshot() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ currentServer = serverApi().get(currentServer.id());
+ Server response = serverApi().restoreSnapshot(currentServer.id(), currentServer.Snapshot().id());
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testDeletePrivateNetwork")
+ public void testCreateSnapshot() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Server response = serverApi().createSnapshot(currentServer.id());
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testListSnapshot")
+ public void testDeleteSnapshot() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+ Thread.sleep(120000);
+ currentServer = serverApi().get(currentServer.id());
+ Server response = serverApi().deleteSnapshot(currentServer.id(), currentServer.Snapshot().id());
+
+ assertNotNull(response);
+ }
+
+ @Test(dependsOnMethods = "testDeleteSnapshot")
+ public void testCreateClone() throws InterruptedException {
+ assertNodeAvailable(currentServer);
+
+ cloneServer = serverApi().clone(currentServer.id(), Server.Clone.create(currentServer.datacenter().id(), "jclouds clone"));
+
+ assertNotNull(cloneServer);
+ }
+}
[3/3] jclouds-labs git commit: JCLOUDS-1124 oneandone-server-api
Posted by na...@apache.org.
JCLOUDS-1124 oneandone-server-api
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/7df28d25
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/7df28d25
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/7df28d25
Branch: refs/heads/master
Commit: 7df28d259999b2267484cfc82c7ae486697f0ec6
Parents: 2b36a75
Author: Ali Bazlamit <al...@hotmail.com>
Authored: Tue Jul 12 01:58:32 2016 +0200
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Jul 12 08:29:07 2016 +0200
----------------------------------------------------------------------
oneandone/pom.xml | 142 ++++
.../jclouds/oneandone/rest/OneAndOneApi.java | 27 +
.../oneandone/rest/OneAndOneApiMetadata.java | 72 ++
.../rest/OneAndOneProviderMetadata.java | 85 ++
.../rest/config/OneAndOneConstants.java | 52 ++
.../rest/config/OneAndOneHttpApiModule.java | 111 +++
.../rest/config/OneAndOneProperties.java | 27 +
.../oneandone/rest/domain/DataCenter.java | 35 +
.../jclouds/oneandone/rest/domain/Dvd.java | 33 +
.../rest/domain/FixedInstanceHardware.java | 31 +
.../jclouds/oneandone/rest/domain/Hardware.java | 71 ++
.../oneandone/rest/domain/HardwareFlavour.java | 72 ++
.../jclouds/oneandone/rest/domain/Hdd.java | 60 ++
.../jclouds/oneandone/rest/domain/Image.java | 86 ++
.../jclouds/oneandone/rest/domain/Licenses.java | 31 +
.../oneandone/rest/domain/PrivateNetwork.java | 61 ++
.../jclouds/oneandone/rest/domain/Server.java | 388 +++++++++
.../rest/domain/ServerFirewallPolicy.java | 33 +
.../jclouds/oneandone/rest/domain/ServerIp.java | 48 ++
.../rest/domain/ServerLoadBalancer.java | 33 +
.../rest/domain/ServerMonitoringPolicy.java | 33 +
.../rest/domain/ServerPrivateNetwork.java | 33 +
.../jclouds/oneandone/rest/domain/Snapshot.java | 35 +
.../jclouds/oneandone/rest/domain/Status.java | 34 +
.../jclouds/oneandone/rest/domain/Types.java | 141 ++++
.../oneandone/rest/domain/WarningAlert.java | 36 +
.../domain/options/GenericQueryOptions.java | 49 ++
.../oneandone/rest/features/ServerApi.java | 386 +++++++++
.../rest/filters/AuthenticateRequest.java | 46 ++
.../handlers/OneAndOneHttpErrorHandler.java | 72 ++
.../rest/ids/ServerPrivateNetworkRef.java | 31 +
.../oneandone/rest/refrence/AuthHeaders.java | 26 +
.../rest/util/ServerFirewallPolicyAdapter.java | 79 ++
.../oneandone/rest/util/SnapshotAdapter.java | 76 ++
.../rest/OneAndOneProviderMetadataTest.java | 28 +
.../rest/features/ServerApiLiveTest.java | 272 +++++++
.../rest/features/ServerApiMockTest.java | 816 +++++++++++++++++++
.../rest/features/ServerNetworkApiLiveTest.java | 141 ++++
.../features/ServerOperationsApiLiveTest.java | 173 ++++
.../rest/internal/BaseOneAndOneApiMockTest.java | 112 +++
.../rest/internal/BaseOneAndOneLiveTest.java | 120 +++
.../src/test/resources/server/add.hdds.json | 54 ++
oneandone/src/test/resources/server/delete.json | 51 ++
.../src/test/resources/server/get.dvd.json | 4 +
.../src/test/resources/server/get.flavour.json | 15 +
.../src/test/resources/server/get.hardware.json | 13 +
.../src/test/resources/server/get.hdd.json | 5 +
.../src/test/resources/server/get.image.json | 4 +
oneandone/src/test/resources/server/get.ip.json | 8 +
oneandone/src/test/resources/server/get.json | 48 ++
.../resources/server/get.privatenetwork.json | 20 +
.../src/test/resources/server/get.status.json | 4 +
.../test/resources/server/list.flavours.json | 113 +++
.../resources/server/list.hardware.hdds.json | 7 +
.../server/list.ip.firewallPolicies.json | 8 +
.../src/test/resources/server/list.ip.json | 10 +
.../resources/server/list.ip.loadBalancers.json | 6 +
oneandone/src/test/resources/server/list.json | 341 ++++++++
.../server/list.options-query-test.json | 309 +++++++
.../resources/server/list.privatenetwork.json | 6 +
.../test/resources/server/list.snapshot.json | 7 +
.../src/test/resources/server/update.image.json | 73 ++
oneandone/src/test/resources/server/update.json | 51 ++
pom.xml | 7 +-
64 files changed, 5397 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/pom.xml
----------------------------------------------------------------------
diff --git a/oneandone/pom.xml b/oneandone/pom.xml
new file mode 100644
index 0000000..faa579c
--- /dev/null
+++ b/oneandone/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.jclouds.labs</groupId>
+ <artifactId>jclouds-labs</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- TODO: when out of labs, switch to org.jclouds.api -->
+ <artifactId>oneandone</artifactId>
+ <name>jclouds OneAndOne REST api</name>
+ <description>jclouds components to access an implementation of OneAndOne</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <test.oneandone.endpoint>https://cloudpanel-api.1and1.com/v1/</test.oneandone.endpoint>
+ <test.oneandone.identity>FIXME</test.oneandone.identity>
+ <test.oneandone.api-version>1.0</test.oneandone.api-version>
+ <jclouds.osgi.export>org.jclouds.oneandone*;version="${project.version}"</jclouds.osgi.export>
+ <jclouds.osgi.import>
+ org.jclouds.labs*;version="${project.version}",
+ org.jclouds*;version="${jclouds.version}",
+ *
+ </jclouds.osgi.import>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.auto.service</groupId>
+ <artifactId>auto-service</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.auto.value</groupId>
+ <artifactId>auto-value</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-okhttp</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-sshj</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp</groupId>
+ <artifactId>mockwebserver</artifactId>
+ <exclusions>
+ <!-- Already provided by jclouds-sshj -->
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ </exclusion>
+ </exclusions>
+ <type>jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-slf4j</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>live</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <threadCount>1</threadCount>
+ <systemPropertyVariables>
+ <test.oneandone.endpoint>${test.oneandone.endpoint}</test.oneandone.endpoint>
+ <test.oneandone.identity>${test.oneandone.identity}</test.oneandone.identity>
+ <test.oneandone.api-version>${test.oneandone.api-version}</test.oneandone.api-version>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
new file mode 100644
index 0000000..577afcb
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApi.java
@@ -0,0 +1,27 @@
+/*
+ * 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.apache.jclouds.oneandone.rest;
+
+import java.io.Closeable;
+import org.apache.jclouds.oneandone.rest.features.ServerApi;
+import org.jclouds.rest.annotations.Delegate;
+
+public interface OneAndOneApi extends Closeable {
+
+ @Delegate
+ ServerApi serverApi();
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApiMetadata.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApiMetadata.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApiMetadata.java
new file mode 100644
index 0000000..4fa0416
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneApiMetadata.java
@@ -0,0 +1,72 @@
+/*
+ * 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.apache.jclouds.oneandone.rest;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+import java.net.URI;
+import java.util.Properties;
+import org.apache.jclouds.oneandone.rest.config.OneAndOneHttpApiModule;
+import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
+import org.jclouds.rest.internal.BaseHttpApiMetadata;
+
+public class OneAndOneApiMetadata extends BaseHttpApiMetadata<OneAndOneApi> {
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public OneAndOneApiMetadata() {
+ this(new Builder());
+ }
+
+ protected OneAndOneApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseHttpApiMetadata.defaultProperties();
+ return properties;
+ }
+
+ public static class Builder extends BaseHttpApiMetadata.Builder<OneAndOneApi, Builder> {
+
+ protected Builder() {
+ id("oneandone")
+ .name("OneAndOne REST API")
+ .identityName("API Username")
+ .documentation(URI.create("https://cloudpanel-api.1and1.com/documentation/1and1/v1/en/documentation.html"))
+ .defaultEndpoint("https://cloudpanel-api.1and1.com/v1")
+ .defaultProperties(OneAndOneApiMetadata.defaultProperties())
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(OkHttpCommandExecutorServiceModule.class)
+ .add(OneAndOneHttpApiModule.class)
+ .build());
+ }
+
+ @Override
+ public OneAndOneApiMetadata build() {
+ return new OneAndOneApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadata.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadata.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadata.java
new file mode 100644
index 0000000..d60a142
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/OneAndOneProviderMetadata.java
@@ -0,0 +1,85 @@
+/*
+ * 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.apache.jclouds.oneandone.rest;
+
+import com.google.auto.service.AutoService;
+import java.net.URI;
+import java.util.Properties;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_MAX_PERIOD;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PERIOD;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_TIMEOUT;
+import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
+import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
+import org.jclouds.providers.ProviderMetadata;
+import org.jclouds.providers.internal.BaseProviderMetadata;
+
+@AutoService(ProviderMetadata.class)
+public class OneAndOneProviderMetadata extends BaseProviderMetadata {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ @Override
+ public Builder toBuilder() {
+ return builder().fromProviderMetadata(this);
+ }
+
+ public OneAndOneProviderMetadata() {
+ super(builder());
+ }
+
+ public OneAndOneProviderMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = OneAndOneApiMetadata.defaultProperties();
+ long defaultTimeout = 60l * 60l; // 1 hour
+ properties.put(POLL_TIMEOUT, defaultTimeout);
+ properties.put(POLL_PERIOD, 1l);
+ properties.put(POLL_MAX_PERIOD, 1l * 9l);
+ properties.put(PROPERTY_SO_TIMEOUT, 60000 * 5);
+ properties.put(PROPERTY_CONNECTION_TIMEOUT, 60000 * 5);
+
+ return properties;
+ }
+
+ public static class Builder extends BaseProviderMetadata.Builder {
+
+ protected Builder() {
+ id("oneandone")
+ .name("OneAndOne REST Compute")
+ .apiMetadata(new OneAndOneApiMetadata())
+ .homepage(URI.create("https://cloudpanel-api.1and1.com"))
+ .console(URI.create("https://account.1and1.com"))
+ .endpoint("https://cloudpanel-api.1and1.com/v1")
+ .defaultProperties(OneAndOneProviderMetadata.defaultProperties());
+ }
+
+ @Override
+ public OneAndOneProviderMetadata build() {
+ return new OneAndOneProviderMetadata(this);
+ }
+
+ @Override
+ public Builder fromProviderMetadata(ProviderMetadata in) {
+ super.fromProviderMetadata(in);
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneConstants.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneConstants.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneConstants.java
new file mode 100644
index 0000000..9dde8b8
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneConstants.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.apache.jclouds.oneandone.rest.config;
+
+import com.google.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_MAX_PERIOD;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PERIOD;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_TIMEOUT;
+
+@Singleton
+public class OneAndOneConstants {
+
+ @Inject
+ @Named(POLL_TIMEOUT)
+ private String pollTimeout;
+
+ @Inject
+ @Named(POLL_PERIOD)
+ private String pollPeriod;
+
+ @Inject
+ @Named(POLL_MAX_PERIOD)
+ private String pollMaxPeriod;
+
+ public long pollTimeout() {
+ return Long.parseLong(pollTimeout);
+ }
+
+ public long pollPeriod() {
+ return Long.parseLong(pollPeriod);
+ }
+
+ public long pollMaxPeriod() {
+ return Long.parseLong(pollMaxPeriod);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneHttpApiModule.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneHttpApiModule.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneHttpApiModule.java
new file mode 100644
index 0000000..ce20590
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneHttpApiModule.java
@@ -0,0 +1,111 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.config;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.base.Predicate;
+import com.google.inject.Provides;
+import java.util.concurrent.TimeUnit;
+import javax.inject.Named;
+import org.apache.jclouds.oneandone.rest.OneAndOneApi;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PREDICATE_PRIVATE_NETWORK;
+import static org.apache.jclouds.oneandone.rest.config.OneAndOneProperties.POLL_PREDICATE_SERVER;
+import org.apache.jclouds.oneandone.rest.domain.PrivateNetwork;
+import org.apache.jclouds.oneandone.rest.domain.Server;
+import org.apache.jclouds.oneandone.rest.domain.Types;
+import org.apache.jclouds.oneandone.rest.handlers.OneAndOneHttpErrorHandler;
+import org.apache.jclouds.oneandone.rest.ids.ServerPrivateNetworkRef;
+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.json.config.GsonModule.DateAdapter;
+import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.config.HttpApiModule;
+import static org.jclouds.util.Predicates2.retry;
+
+@ConfiguresHttpApi
+public class OneAndOneHttpApiModule extends HttpApiModule<OneAndOneApi> {
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(OneAndOneHttpErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(OneAndOneHttpErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(OneAndOneHttpErrorHandler.class);
+ }
+
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(DateAdapter.class).to(Iso8601DateAdapter.class);
+ }
+
+ @Provides
+ @Named(POLL_PREDICATE_PRIVATE_NETWORK)
+ Predicate<ServerPrivateNetworkRef> providePrivateNetworkReadyPredicate(final OneAndOneApi api, OneAndOneConstants constants) {
+ return retry(new PrivateNetworkReadyPredicate(
+ api),
+ constants.pollTimeout(), constants.pollPeriod(), constants.pollMaxPeriod(), TimeUnit.SECONDS);
+ }
+
+ @Provides
+ @Named(POLL_PREDICATE_SERVER)
+ Predicate<Server> provideServerReadyPredicate(final OneAndOneApi api, OneAndOneConstants constants) {
+ return retry(new ServerReadyPredicate(
+ api),
+ constants.pollTimeout(), constants.pollPeriod(), constants.pollMaxPeriod(), TimeUnit.SECONDS);
+ }
+
+ static class ServerReadyPredicate implements Predicate<Server> {
+
+ private final OneAndOneApi api;
+
+ public ServerReadyPredicate(OneAndOneApi api) {
+ this.api = checkNotNull(api, "api must not be null");
+ }
+
+ @Override
+ public boolean apply(Server server) {
+ checkNotNull(server, "Server");
+ server = api.serverApi().get(server.id());
+ if ((server.status().state() != Types.ServerState.POWERED_OFF
+ && server.status().state() != Types.ServerState.POWERED_ON)
+ || server.status().percent() != 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+
+ static class PrivateNetworkReadyPredicate implements Predicate<ServerPrivateNetworkRef> {
+
+ private final OneAndOneApi api;
+
+ public PrivateNetworkReadyPredicate(OneAndOneApi api) {
+ this.api = checkNotNull(api, "api must not be null");
+ }
+
+ @Override
+ public boolean apply(ServerPrivateNetworkRef networkRef) {
+ checkNotNull(networkRef, "ServerPrivateNetworkRef");
+ PrivateNetwork server = api.serverApi().getPrivateNetwork(networkRef.serverId(), networkRef.privateNetworkId());
+ return server.state() != Types.GenericState.ACTIVE;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneProperties.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneProperties.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneProperties.java
new file mode 100644
index 0000000..469a230
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/config/OneAndOneProperties.java
@@ -0,0 +1,27 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.config;
+
+public final class OneAndOneProperties {
+
+ public static final String POLL_PREDICATE_SERVER = "jclouds.oneandone.rest.predicate.server";
+ public static final String POLL_PREDICATE_PRIVATE_NETWORK = "jclouds.oneandone.rest.predicate.privatenetwork";
+ public static final String AUTH_TOKEN = "oneandone.identity";
+ public static final String POLL_TIMEOUT = "jclouds.oneandone.rest.poll.timeout";
+ public static final String POLL_PERIOD = "jclouds.oneandone.rest.operation.poll.initial-period";
+ public static final String POLL_MAX_PERIOD = "jclouds.oneandone.rest.operation.poll.max-period";
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/DataCenter.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/DataCenter.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/DataCenter.java
new file mode 100644
index 0000000..c2d129f
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/DataCenter.java
@@ -0,0 +1,35 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class DataCenter {
+
+ public abstract String id();
+
+ public abstract String countryCode();
+
+ public abstract String location();
+
+ @SerializedNames({"id", "country_code", "location"})
+ public static DataCenter create(String id, String countryCode, String location) {
+ return new AutoValue_DataCenter(id, countryCode, location);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Dvd.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Dvd.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Dvd.java
new file mode 100644
index 0000000..865eb48
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Dvd.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Dvd {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @SerializedNames({"id", "name"})
+ public static Dvd create(String id, String name) {
+ return new AutoValue_Dvd(id, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FixedInstanceHardware.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FixedInstanceHardware.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FixedInstanceHardware.java
new file mode 100644
index 0000000..6d2e198
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/FixedInstanceHardware.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class FixedInstanceHardware {
+
+ public abstract String fixedInstanceSizeId();
+
+ @SerializedNames({"fixed_instance_size_id"})
+ public static FixedInstanceHardware create(String fixedInstanceSizeId) {
+ return new AutoValue_FixedInstanceHardware(fixedInstanceSizeId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hardware.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hardware.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hardware.java
new file mode 100644
index 0000000..4eda12f
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hardware.java
@@ -0,0 +1,71 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Hdd.CreateHdd;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Hardware {
+
+ public abstract double vcore();
+
+ public abstract double coresPerProcessor();
+
+ public abstract double ram();
+
+ public abstract List<Hdd> hdds();
+
+ @SerializedNames({"vcore", "cores_per_processor", "ram", "hdds"})
+ public static Hardware create(double vcore, double coresPerProcessor, double ram, List<Hdd> hdds) {
+ return new AutoValue_Hardware(vcore, coresPerProcessor, ram, hdds);
+ }
+
+ @AutoValue
+ public abstract static class CreateHardware {
+
+ public abstract double vcore();
+
+ public abstract double coresPerProcessor();
+
+ public abstract double ram();
+
+ public abstract List<CreateHdd> hdds();
+
+ @SerializedNames({"vcore", "cores_per_processor", "ram", "hdds"})
+ public static CreateHardware create(double vcore, double coresPerProcessor, double ram, List<CreateHdd> hdds) {
+ return new AutoValue_Hardware_CreateHardware(vcore, coresPerProcessor, ram, hdds);
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateHardware {
+
+ public abstract double ram();
+
+ public abstract double coresPerProcessor();
+
+ public abstract double vcore();
+
+ @SerializedNames({"ram", "cores_per_processor", "vcore"})
+ public static UpdateHardware create(double vcore, double coresPerProcessor, double ram) {
+ return new AutoValue_Hardware_UpdateHardware(vcore, coresPerProcessor, ram);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/HardwareFlavour.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/HardwareFlavour.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/HardwareFlavour.java
new file mode 100644
index 0000000..b5098c9
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/HardwareFlavour.java
@@ -0,0 +1,72 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import java.util.List;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class HardwareFlavour {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ public abstract Hardware hardware();
+
+ @SerializedNames({"id", "name", "hardware"})
+ public static HardwareFlavour create(String id, String name, Hardware hardware) {
+ return new AutoValue_HardwareFlavour(id, name, hardware);
+ }
+
+ @AutoValue
+ public abstract static class Hardware {
+
+ @Nullable
+ public abstract String fixedInstanceSizeId();
+
+ public abstract double vcore();
+
+ public abstract double coresPerProcessor();
+
+ public abstract double ram();
+
+ public abstract List<Hdd> hdds();
+
+ @SerializedNames({"fixed_instance_size_id", "vcore", "cores_per_processor", "ram", "hdds"})
+ public static Hardware create(String fixedInstanceSizeId, double vcore, double coresPerProcessor, double ram, List<Hdd> hdds) {
+ return new AutoValue_HardwareFlavour_Hardware(fixedInstanceSizeId, vcore, coresPerProcessor, ram, hdds);
+ }
+
+ @AutoValue
+ public abstract static class Hdd {
+
+ public abstract String unit();
+
+ public abstract int size();
+
+ public abstract boolean isMain();
+
+ @SerializedNames({"unit", "size", "is_main"})
+ public static Hdd create(String unit, int size, boolean isMain) {
+ return new AutoValue_HardwareFlavour_Hardware_Hdd(unit, size, isMain);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hdd.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hdd.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hdd.java
new file mode 100644
index 0000000..d0a480c
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Hdd.java
@@ -0,0 +1,60 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import java.util.List;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Hdd {
+
+ public abstract String id();
+
+ public abstract double size();
+
+ public abstract boolean isMain();
+
+ @SerializedNames({"id", "size", "is_main"})
+ public static Hdd create(String id, double size, boolean isMain) {
+ return new AutoValue_Hdd(id, size, isMain);
+ }
+
+ @AutoValue
+ public abstract static class CreateHddList {
+
+ public abstract List<CreateHdd> hdds();
+
+ @SerializedNames({"hdds"})
+ public static CreateHddList create(List<CreateHdd> hdds) {
+ return new AutoValue_Hdd_CreateHddList(hdds);
+ }
+ }
+
+ @AutoValue
+ public abstract static class CreateHdd {
+
+ public abstract double size();
+
+ public abstract boolean isMain();
+
+ @SerializedNames({"size", "is_main"})
+ public static CreateHdd create(double size, boolean isMain) {
+ return new AutoValue_Hdd_CreateHdd(size, isMain);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Image.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Image.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Image.java
new file mode 100644
index 0000000..80bbead
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Image.java
@@ -0,0 +1,86 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Types.ImageFrequency;
+import org.apache.jclouds.oneandone.rest.domain.Types.ImageType;
+import org.apache.jclouds.oneandone.rest.domain.Types.OSFamliyType;
+import org.apache.jclouds.oneandone.rest.domain.Types.OSType;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Image {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @Nullable
+ public abstract OSFamliyType osFamily();
+
+ @Nullable
+ public abstract OSType os();
+
+ @Nullable
+ public abstract String osVersion();
+
+ public abstract List<String> availableSites();
+
+ public abstract int architecture();
+
+ @Nullable
+ public abstract String osImageType();
+
+ @Nullable
+ public abstract ImageType type();
+
+ public abstract int minHddSize();
+
+ public abstract List<Licenses> licenses();
+
+ @Nullable
+ public abstract String state();
+
+ @Nullable
+ public abstract String description();
+
+ @Nullable
+ public abstract List<Hdd> hdds();
+
+ @Nullable
+ public abstract String serverId();
+
+ @Nullable
+ public abstract ImageFrequency frequency();
+
+ public abstract int numImages();
+
+ @Nullable
+
+ public abstract String creationDate();
+
+ @SerializedNames({"id", "name", "os_family", "os", "os_version", "availableSites", "architecture", "os_image_type", "type", "min_hdd_size", "licenses", "state", "description", "hdds", "server_id", "frequency", "numImages", "creation_date"})
+ public static Image create(String id, String name, OSFamliyType osFamily, OSType os, String osVersion, List<String> availableSites, int architecture, String osImageType, ImageType type, int minHddSize, List<Licenses> licenses, String state, String description, List<Hdd> hdds, String serverId, ImageFrequency frequency, int numImages, String creationDate) {
+ return new AutoValue_Image(id, name, osFamily, os, osVersion, availableSites == null ? ImmutableList.<String>of() : availableSites,
+ architecture, osImageType, type, minHddSize, licenses == null ? ImmutableList.<Licenses>of() : licenses, state,
+ description, hdds == null ? ImmutableList.<Hdd>of() : hdds, serverId, frequency, numImages, creationDate);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Licenses.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Licenses.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Licenses.java
new file mode 100644
index 0000000..1c1e9a3
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Licenses.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Licenses {
+
+ public abstract String name();
+
+ @SerializedNames({"name"})
+ public static Licenses create(String name) {
+ return new AutoValue_Licenses(name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/PrivateNetwork.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/PrivateNetwork.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/PrivateNetwork.java
new file mode 100644
index 0000000..5a01fc7
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/PrivateNetwork.java
@@ -0,0 +1,61 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Types.GenericState;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class PrivateNetwork {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @Nullable
+ public abstract String description();
+
+ @Nullable
+ public abstract String networkAddress();
+
+ @Nullable
+ public abstract String subnetMask();
+
+ @Nullable
+ public abstract GenericState state();
+
+ @Nullable
+ public abstract String creationDate();
+
+ @Nullable
+ public abstract List<Server> servers();
+
+ @Nullable
+ public abstract String cloudpanelId();
+
+ @Nullable
+ public abstract DataCenter datacenter();
+
+ @SerializedNames({"id", "name", "description", "network_address", "subnet_mask", "state", "creation_date", "servers", "cloudpanel_id", "datacenter"})
+ public static PrivateNetwork create(String id, String name, String description, String networkAddress, String subnetMask, GenericState state, String creationDate, List<Server> servers, String cloudpanelId, DataCenter datacenter) {
+ return new AutoValue_PrivateNetwork(id, name, description, networkAddress, subnetMask, state, creationDate, servers == null ? ImmutableList.<Server>of() : servers, cloudpanelId, datacenter);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Server.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Server.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Server.java
new file mode 100644
index 0000000..f83c4de
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Server.java
@@ -0,0 +1,388 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import java.util.Date;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Types.ServerAction;
+import org.apache.jclouds.oneandone.rest.domain.Types.ServerActionMethod;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Server {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @Nullable
+ public abstract Date creationDate();
+
+ @Nullable
+ public abstract String firstPassword();
+
+ @Nullable
+ public abstract String description();
+
+ @Nullable
+
+ public abstract Status status();
+
+ @Nullable
+
+ public abstract Hardware hardware();
+
+ @Nullable
+ public abstract Image image();
+
+ @Nullable
+ public abstract Dvd dvd();
+
+ @Nullable
+ public abstract Snapshot Snapshot();
+
+ @Nullable
+ public abstract DataCenter datacenter();
+
+ public abstract List<ServerIp> ips();
+
+ public abstract List<Alert> alerts();
+
+ @Nullable
+ public abstract ServerMonitoringPolicy monitoringPolicy();
+
+ public abstract List<ServerPrivateNetwork> privateNetworks();
+
+ @SerializedNames({"id", "name", "creation_date", "first_password", "description", "status", "hardware", "image", "dvd", "snapshot", "datacenter", "ips", "alerts", "monitoring_policy", "private_networks"})
+ public static Server create(String id, String name, Date creationDate, String firstPassword, String description, Status status, Hardware hardware, Image image, Dvd dvd, Snapshot snapshot, DataCenter datacenter, List<ServerIp> ips, List<Alert> alerts, ServerMonitoringPolicy policy, List<ServerPrivateNetwork> privateNetworks) {
+ return new AutoValue_Server(id, name, creationDate, firstPassword, description, status, hardware, image, dvd, snapshot, datacenter,
+ ips == null ? ImmutableList.<ServerIp>of() : ips, alerts == null ? ImmutableList.<Alert>of() : alerts, policy,
+ privateNetworks == null ? ImmutableList.<ServerPrivateNetwork>of() : privateNetworks);
+ }
+
+ @AutoValue
+ public abstract static class Alert {
+
+ public abstract List<WarningAlert> warning();
+
+ public abstract List<CriticalAlert> critical();
+
+ @SerializedNames({"warning", "critical"})
+ public static Alert create(List<WarningAlert> warning, List<CriticalAlert> critical) {
+ return new AutoValue_Server_Alert(warning == null ? ImmutableList.<WarningAlert>of() : warning,
+ critical == null ? ImmutableList.<CriticalAlert>of() : critical);
+ }
+ }
+
+ @AutoValue
+ public abstract static class CriticalAlert {
+
+ public abstract String type();
+
+ public abstract String description();
+
+ public abstract String date();
+
+ @SerializedNames({"type", "description", "date"})
+ public static CriticalAlert create(String type, String description, String date) {
+ return new AutoValue_Server_CriticalAlert(type, description, date);
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateServerResponse {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @Nullable
+ public abstract Date creationDate();
+
+ @Nullable
+ public abstract String firstPassword();
+
+ public abstract String description();
+
+ @Nullable
+ public abstract Status status();
+
+ @Nullable
+ public abstract Hardware hardware();
+
+ @Nullable
+ public abstract Image image();
+
+ @Nullable
+ public abstract Dvd dvd();
+
+ @Nullable
+ public abstract Snapshot Snapshot();
+
+ @Nullable
+ public abstract DataCenter datacenter();
+
+ public abstract List<String> ips();
+
+ public abstract List<Alert> alerts();
+
+ public abstract List<ServerMonitoringPolicy> monitoringPolicy();
+
+ public abstract List<ServerPrivateNetwork> privateNetworks();
+
+ @SerializedNames({"id", "name", "creation_date", "first_password", "description", "status", "hardware", "image", "dvd", "snapshot", "datacenter", "ips", "alerts", "monitoring_policy", "private_networks"})
+ public static UpdateServerResponse create(String id, String name, Date creationDate, String firstPassword, String description, Status status, Hardware hardware, Image image, Dvd dvd, Snapshot snapshot, DataCenter datacenter, List<String> ips, List<Alert> alerts, List<ServerMonitoringPolicy> policy, List<ServerPrivateNetwork> privateNetworks) {
+ return new AutoValue_Server_UpdateServerResponse(id, name, creationDate, firstPassword, description, status, hardware, image, dvd,
+ snapshot, datacenter, ips == null ? ImmutableList.<String>of() : ips, alerts == null ? ImmutableList.<Alert>of() : alerts,
+ policy == null ? ImmutableList.<ServerMonitoringPolicy>of() : policy, privateNetworks == null ? ImmutableList.<ServerPrivateNetwork>of() : privateNetworks);
+ }
+ }
+
+ @AutoValue
+ public abstract static class CreateServer {
+
+ public abstract String name();
+
+ public abstract String description();
+
+ public abstract Hardware.CreateHardware hardware();
+
+ public abstract String applianceId();
+
+ @Nullable
+ public abstract String dataCenterId();
+
+ @Nullable
+ public abstract String password();
+
+ @Nullable
+ public abstract String regionId();
+
+ @Nullable
+ public abstract Boolean powerOn();
+
+ @Nullable
+ public abstract String firewallPolicyId();
+
+ @Nullable
+ public abstract String ipId();
+
+ @Nullable
+ public abstract String loadrBalancerId();
+
+ @Nullable
+ public abstract String monitoringPolicyId();
+
+ @SerializedNames({"name", "description", "hardware", "appliance_id", "datacenter_id", "password", "region_id", "power_on", "firewall_policy_id", "ip_id", "loadr_balancer_id", "monitoring_policy_id"})
+ public static CreateServer create(final String name, final String description, final Hardware.CreateHardware hardware, final String applianceId,
+ final String dataCenterId, final String password, final String regionId, final Boolean powerOn, final String firewallPolicyId,
+ final String ipId, final String loadrBalancerId, final String monitoringPolicyId) {
+ return builder()
+ .name(name)
+ .description(description)
+ .hardware(hardware)
+ .applianceId(applianceId)
+ .dataCenterId(dataCenterId)
+ .password(password)
+ .regionId(regionId)
+ .powerOn(powerOn)
+ .firewallPolicyId(firewallPolicyId)
+ .ipId(ipId)
+ .loadrBalancerId(loadrBalancerId)
+ .monitoringPolicyId(monitoringPolicyId)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Server_CreateServer.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder name(String name);
+
+ public abstract Builder description(String description);
+
+ public abstract Builder hardware(Hardware.CreateHardware hardware);
+
+ public abstract Builder applianceId(String applianceId);
+
+ public abstract Builder dataCenterId(String dataCenterId);
+
+ public abstract Builder password(String password);
+
+ public abstract Builder regionId(String regionId);
+
+ public abstract Builder powerOn(Boolean powerOn);
+
+ public abstract Builder firewallPolicyId(String firewallPolicyId);
+
+ public abstract Builder ipId(String ipId);
+
+ public abstract Builder loadrBalancerId(String loadrBalancerId);
+
+ public abstract Builder monitoringPolicyId(String monitoringPolicyId);
+
+ public abstract CreateServer build();
+ }
+ }
+
+ @AutoValue
+ public abstract static class CreateFixedInstanceServer {
+
+ public abstract String name();
+
+ public abstract String description();
+
+ public abstract FixedInstanceHardware hardware();
+
+ public abstract String applianceId();
+
+ @Nullable
+ public abstract String dataCenterId();
+
+ @Nullable
+ public abstract String password();
+
+ @Nullable
+ public abstract String regionId();
+
+ @Nullable
+ public abstract Boolean powerOn();
+
+ @Nullable
+ public abstract String firewallPolicyId();
+
+ @Nullable
+ public abstract String ipId();
+
+ @Nullable
+ public abstract String loadrBalancerId();
+
+ @Nullable
+ public abstract String monitoringPolicyId();
+
+ @SerializedNames({"name", "description", "hardware", "appliance_id", "datacenter_id", "password", "region_id", "power_on", "firewall_policy_id", "ip_id", "loadr_balancer_id", "monitoring_policy_id"})
+ public static CreateFixedInstanceServer create(String name, String description, FixedInstanceHardware hardware, String applianceId, String dataCenterId, String password,
+ String regionId, Boolean powerOn, String firewallPolicyId, String ipId, String loadrBalancerId, String monitoringPolicyId) {
+ return builder()
+ .name(name)
+ .description(description)
+ .hardware(hardware)
+ .applianceId(applianceId)
+ .dataCenterId(dataCenterId)
+ .password(password)
+ .regionId(regionId)
+ .powerOn(powerOn)
+ .firewallPolicyId(firewallPolicyId)
+ .ipId(ipId)
+ .loadrBalancerId(loadrBalancerId)
+ .monitoringPolicyId(monitoringPolicyId)
+ .build();
+ }
+
+ public static Builder builder() {
+ return new AutoValue_Server_CreateFixedInstanceServer.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+
+ public abstract Builder name(String name);
+
+ public abstract Builder description(String description);
+
+ public abstract Builder hardware(FixedInstanceHardware hardware);
+
+ public abstract Builder applianceId(String applianceId);
+
+ public abstract Builder dataCenterId(String dataCenterId);
+
+ public abstract Builder password(String password);
+
+ public abstract Builder regionId(String regionId);
+
+ public abstract Builder powerOn(Boolean powerOn);
+
+ public abstract Builder firewallPolicyId(String firewallPolicyId);
+
+ public abstract Builder ipId(String ipId);
+
+ public abstract Builder loadrBalancerId(String loadrBalancerId);
+
+ public abstract Builder monitoringPolicyId(String monitoringPolicyId);
+
+ public abstract CreateFixedInstanceServer build();
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateImage {
+
+ public abstract String id();
+
+ public abstract String password();
+
+ @SerializedNames({"id", "password"})
+ public static UpdateImage create(String id, String password) {
+ return new AutoValue_Server_UpdateImage(id, password);
+ }
+ }
+
+ @AutoValue
+ public abstract static class Clone {
+
+ public abstract String datacenterId();
+
+ public abstract String name();
+
+ @SerializedNames({"datacenter_id", "name"})
+ public static Clone create(String datacenterId, String name) {
+ return new AutoValue_Server_Clone(datacenterId, name);
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateServer {
+
+ public abstract String name();
+
+ public abstract String description();
+
+ @SerializedNames({"name", "description"})
+ public static UpdateServer create(String name, String description) {
+ return new AutoValue_Server_UpdateServer(name, description);
+ }
+ }
+
+ @AutoValue
+ public abstract static class UpdateStatus {
+
+ public abstract ServerAction action();
+
+ public abstract ServerActionMethod method();
+
+ @SerializedNames({"action", "method"})
+ public static UpdateStatus create(ServerAction action, ServerActionMethod method) {
+ return new AutoValue_Server_UpdateStatus(action, method);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerFirewallPolicy.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerFirewallPolicy.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerFirewallPolicy.java
new file mode 100644
index 0000000..b57294a
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerFirewallPolicy.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class ServerFirewallPolicy {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @SerializedNames({"id", "name"})
+ public static ServerFirewallPolicy create(String id, String name) {
+ return new AutoValue_ServerFirewallPolicy(id, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerIp.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerIp.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerIp.java
new file mode 100644
index 0000000..0774334
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerIp.java
@@ -0,0 +1,48 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.apache.jclouds.oneandone.rest.domain.Types.IPType;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class ServerIp {
+
+ public abstract String id();
+
+ public abstract String ip();
+
+ public abstract List<ServerLoadBalancer> loadBalancers();
+
+ public abstract List<ServerFirewallPolicy> firewallPolicy();
+
+ @Nullable
+ public abstract String reverseDns();
+
+ @Nullable
+ public abstract IPType type();
+
+ @SerializedNames({"id", "ip", "loadBalancers", "firewallPolicy", "reverseDns", "type"})
+ public static ServerIp create(String id, String ip, List<ServerLoadBalancer> loadBalancers, List<ServerFirewallPolicy> firewallPolicy, String reverseDns, IPType type) {
+ return new AutoValue_ServerIp(id, ip, loadBalancers == null ? ImmutableList.<ServerLoadBalancer>of() : loadBalancers,
+ firewallPolicy == null ? ImmutableList.<ServerFirewallPolicy>of() : firewallPolicy, reverseDns, type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerLoadBalancer.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerLoadBalancer.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerLoadBalancer.java
new file mode 100644
index 0000000..0d7c6a7
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerLoadBalancer.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class ServerLoadBalancer {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @SerializedNames({"id", "name"})
+ public static ServerLoadBalancer create(String id, String name) {
+ return new AutoValue_ServerLoadBalancer(id, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerMonitoringPolicy.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerMonitoringPolicy.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerMonitoringPolicy.java
new file mode 100644
index 0000000..0df5466
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerMonitoringPolicy.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class ServerMonitoringPolicy {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @SerializedNames({"id", "name"})
+ public static ServerMonitoringPolicy create(String id, String name) {
+ return new AutoValue_ServerMonitoringPolicy(id, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerPrivateNetwork.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerPrivateNetwork.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerPrivateNetwork.java
new file mode 100644
index 0000000..111551a
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/ServerPrivateNetwork.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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class ServerPrivateNetwork {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ @SerializedNames({"id", "name"})
+ public static ServerPrivateNetwork create(String id, String name) {
+ return new AutoValue_ServerPrivateNetwork(id, name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Snapshot.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Snapshot.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Snapshot.java
new file mode 100644
index 0000000..a4f54ee
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Snapshot.java
@@ -0,0 +1,35 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Snapshot {
+
+ public abstract String id();
+
+ public abstract String creationDate();
+
+ public abstract String deletionDate();
+
+ @SerializedNames({"id", "creation_date", "deletion_date"})
+ public static Snapshot create(String id, String creationDate, String deletionDate) {
+ return new AutoValue_Snapshot(id, creationDate, deletionDate);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Status.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Status.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Status.java
new file mode 100644
index 0000000..308ce4d
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Status.java
@@ -0,0 +1,34 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import org.apache.jclouds.oneandone.rest.domain.Types.ServerState;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class Status {
+
+ public abstract ServerState state();
+
+ public abstract int percent();
+
+ @SerializedNames({"state", "percent"})
+ public static Status create(ServerState state, int percent) {
+ return new AutoValue_Status(state, percent);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
new file mode 100644
index 0000000..1587803
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/Types.java
@@ -0,0 +1,141 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.common.base.Enums;
+
+public class Types {
+
+ public enum OSFamliyType {
+
+ Windows, Linux, Others, Null, UNRECOGNIZED;
+
+ public static OSFamliyType fromValue(String v) {
+ return Enums.getIfPresent(OSFamliyType.class, v).or(UNRECOGNIZED);
+ }
+
+ }
+
+ public enum ImageType {
+ IMAGES("IMAGES"), MYIMAGE("MY_IMAGE"), PERSONAL("PERSONAL"), UNRECOGNIZED("");
+
+ public static ImageType fromValue(String v) {
+ return Enums.getIfPresent(ImageType.class, v).or(UNRECOGNIZED);
+ }
+ // the value which is used for matching
+ // the json node value with this enum
+ private final String value;
+
+ ImageType(final String type) {
+ value = type;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ public enum OSType {
+ CentOS("CentOS"),
+ Debian("Debian"),
+ Ubuntu("Ubuntu"),
+ RedHat("Red Hat"),
+ Windows2008("Windows 2008"),
+ Windows2012("Windows 2012"),
+ WindowsDatacenter("WindowsDatacenter"),
+ UNRECOGNIZED("");
+
+ public static OSType fromValue(String v) {
+ return Enums.getIfPresent(OSType.class, v).or(UNRECOGNIZED);
+ }
+
+ // the value which is used for matching
+ // the json node value with this enum
+ private final String value;
+
+ OSType(final String type) {
+ value = type;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+ }
+
+ public enum ImageFrequency {
+ ONCE,
+ DAILY,
+ WEEKLY,
+ UNRECOGNIZED;
+
+ public static ImageFrequency fromValue(String v) {
+ return Enums.getIfPresent(ImageFrequency.class, v).or(UNRECOGNIZED);
+ }
+ }
+
+ public enum ServerState {
+ POWERING_ON,
+ POWERING_OFF,
+ POWERED_ON,
+ POWERED_OFF,
+ DEPLOYING,
+ REBOOTING,
+ REMOVING,
+ CONFIGURING, UNRECOGNIZED;
+
+ public static ServerState fromValue(String v) {
+ return Enums.getIfPresent(ServerState.class, v).or(UNRECOGNIZED);
+ }
+ }
+
+ public enum GenericState {
+ ACTIVE, REMOVING,
+ CONFIGURING, UNRECOGNIZED;
+
+ public static GenericState fromValue(String v) {
+ return Enums.getIfPresent(GenericState.class, v).or(UNRECOGNIZED);
+ }
+ }
+
+ public enum ServerAction {
+ POWER_ON, POWER_OFF, REBOOT, UNRECOGNIZED;
+
+ public static ServerAction fromValue(String v) {
+ return Enums.getIfPresent(ServerAction.class, v).or(UNRECOGNIZED);
+ }
+
+ }
+
+ public enum ServerActionMethod {
+ SOFTWARE, HARDWARE, UNRECOGNIZED;
+
+ public static ServerActionMethod fromValue(String v) {
+ return Enums.getIfPresent(ServerActionMethod.class, v).or(UNRECOGNIZED);
+ }
+ }
+
+ public enum IPType {
+ IPV4, IPV6, UNRECOGNIZED;
+
+ public static IPType fromValue(String v) {
+ return Enums.getIfPresent(IPType.class, v).or(UNRECOGNIZED);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/WarningAlert.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/WarningAlert.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/WarningAlert.java
new file mode 100644
index 0000000..05303dd
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/WarningAlert.java
@@ -0,0 +1,36 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain;
+
+import com.google.auto.value.AutoValue;
+import java.util.Date;
+import org.jclouds.json.SerializedNames;
+
+@AutoValue
+public abstract class WarningAlert {
+
+ public abstract String type();
+
+ public abstract String description();
+
+ public abstract Date date();
+
+ @SerializedNames({"type", "description", "date"})
+ public static WarningAlert create(String type, String description, Date date) {
+ return new AutoValue_WarningAlert(type, description, date);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/7df28d25/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/options/GenericQueryOptions.java
----------------------------------------------------------------------
diff --git a/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/options/GenericQueryOptions.java b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/options/GenericQueryOptions.java
new file mode 100644
index 0000000..9527308
--- /dev/null
+++ b/oneandone/src/main/java/org/apache/jclouds/oneandone/rest/domain/options/GenericQueryOptions.java
@@ -0,0 +1,49 @@
+/*
+ * 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.apache.jclouds.oneandone.rest.domain.options;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+public class GenericQueryOptions extends BaseHttpRequestOptions {
+
+ public static final String PAGE = "page";
+ public static final String PERPAGE = "per_page";
+ public static final String SORT = "sort";
+ public static final String QUERY = "q";
+ public static final String FIELDS = "fields";
+
+ public GenericQueryOptions options(int page, int perPage, String sort, String query, String fields) {
+
+ if (page != 0) {
+ queryParameters.put(PAGE, String.valueOf(page));
+ }
+ if (perPage != 0) {
+ queryParameters.put(PERPAGE, String.valueOf(perPage));
+ }
+ if (sort != null && !sort.isEmpty()) {
+ queryParameters.put(SORT, sort);
+ }
+ if (query != null && !query.isEmpty()) {
+ queryParameters.put(QUERY, query);
+ }
+ if (fields != null && !fields.isEmpty()) {
+ queryParameters.put(FIELDS, fields);
+ }
+ return this;
+ }
+
+}