You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/05 20:27:40 UTC
[1/4] standardize listPage across all GCE resources.
Repository: jclouds-labs-google
Updated Branches:
refs/heads/master 8b5d3d3ce -> d74032369
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
index 4fcdfa9..eb6d0fe 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java
@@ -31,13 +31,13 @@ import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.Instance;
import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskMode;
import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
@@ -70,8 +70,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Override
protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
GoogleComputeEngineApi api = super.create(props, modules);
- List<Image> list = api.getImageApi("centos-cloud")
- .list(new ListOptions.Builder().filter("name eq centos.*")).next();
+ List<Image> list = api.getImageApi("centos-cloud").list(filter("name eq centos.*")).next();
URI imageUri = FluentIterable.from(list)
.filter(new Predicate<Image>() {
@Override
@@ -102,7 +101,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
}
private DiskApi diskApi() {
- return api.getDiskApi(userProject.get());
+ return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
@@ -113,16 +112,11 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
(INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instance.image());
- assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get())
- .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
+ assertZoneOperationDoneSuccessfully(diskApi().create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions),
TIME_WAIT);
-
- assertZoneOperationDoneSuccessfully(
- diskApi().createInZone("instance-live-test-disk", DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME), TIME_WAIT);
-
+ assertZoneOperationDoneSuccessfully(diskApi().create("instance-live-test-disk", DEFAULT_DISK_SIZE_GB), TIME_WAIT);
assertZoneOperationDoneSuccessfully(api().create(INSTANCE_NAME, instance), TIME_WAIT);
-
}
@Test(groups = "live", dependsOnMethods = "testInsertInstance")
@@ -162,7 +156,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testSetMetadataForInstance")
public void testAttachDiskToInstance() {
- assertZoneOperationDoneSuccessfully(diskApi().createInZone(ATTACH_DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().create(ATTACH_DISK_NAME, 1), TIME_WAIT);
Instance originalInstance = api().get(INSTANCE_NAME);
assertZoneOperationDoneSuccessfully(api().attachDisk(INSTANCE_NAME,
@@ -192,7 +186,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
assertTrue(modifiedInstance.disks().size() < originalInstance.disks().size());
- assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, ATTACH_DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().delete(ATTACH_DISK_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertInstance")
@@ -216,12 +210,10 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testResetInstance")
public void testDeleteInstance() {
assertZoneOperationDoneSuccessfully(api().delete(INSTANCE_NAME), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
- TIME_WAIT);
- assertZoneOperationDoneSuccessfully(
- api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete
- (INSTANCE_NETWORK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().delete(BOOT_DISK_NAME), TIME_WAIT);
+ Operation deleteNetwork = api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME);
+ assertGlobalOperationDoneSucessfully(deleteNetwork, TIME_WAIT);
}
private void assertInstanceEquals(Instance result, InstanceTemplate expected) {
@@ -233,12 +225,9 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
protected void tearDownContext() {
try {
waitZoneOperationDone(api().delete(INSTANCE_NAME), TIME_WAIT);
- waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
- TIME_WAIT);
- waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
- TIME_WAIT);
- waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete
- (INSTANCE_NETWORK_NAME), TIME_WAIT);
+ waitZoneOperationDone(diskApi().delete(DISK_NAME), TIME_WAIT);
+ waitZoneOperationDone(diskApi().delete(BOOT_DISK_NAME), TIME_WAIT);
+ waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME), TIME_WAIT);
} catch (Exception e) {
// we don't really care about any exception here, so just delete away.
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
index 1400232..2a39179 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java
@@ -67,10 +67,9 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
.payload(payloadFromResource("/machinetype.json")).build();
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject", "us-central1-a");
- assertEquals(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"),
- new ParseMachineTypeTest().expected());
+ assertEquals(machineTypeApi.get("n1-standard-1"), new ParseMachineTypeTest().expected());
}
public void testGetMachineTypeResponseIs4xx() throws Exception {
@@ -84,28 +83,27 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject", "us-central1-a");
- assertNull(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"));
+ assertNull(machineTypeApi.get("n1-standard-1"));
}
public void testListMachineTypeNoOptionsResponseIs2xx() throws Exception {
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApi
- ("myproject");
+ ("myproject", "us-central1-a");
- assertEquals(machineTypeApi.listInZone("us-central1-a").next().toString(),
- new ParseMachineTypeListTest().expected().toString());
+ assertEquals(machineTypeApi.list().next().toString(), new ParseMachineTypeListTest().expected().toString());
}
public void testLisOperationWithPaginationOptionsResponseIs4xx() {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
- MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApi("myproject");
+ MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
+ LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApi("myproject", "us-central1-a");
- assertFalse(machineTypeApi.listInZone("us-central1-a").hasNext());
+ assertFalse(machineTypeApi.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
index 89c7257..132b42b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -26,7 +27,6 @@ import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.MachineType;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -34,13 +34,12 @@ public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private MachineType machineType;
private MachineTypeApi api() {
- return api.getMachineTypeApi(userProject.get());
+ return api.getMachineTypeApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
public void testListMachineType() {
- Iterator<ListPage<MachineType>> pageIterator = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .maxResults(1));
+ Iterator<ListPage<MachineType>> pageIterator = api().list(maxResults(1));
assertTrue(pageIterator.hasNext());
List<MachineType> machineTypeAsList = pageIterator.next();
@@ -53,7 +52,7 @@ public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListMachineType")
public void testGetMachineType() {
- MachineType machineType = api().getInZone(DEFAULT_ZONE_NAME, this.machineType.name());
+ MachineType machineType = api().get(this.machineType.name());
assertNotNull(machineType);
assertMachineTypeEquals(machineType, this.machineType);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
index 9363370..080b63c 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -25,7 +26,6 @@ import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
@Test(groups = "live", testName = "NetworkApiLiveTest")
@@ -53,21 +53,17 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetNetwork")
public void testListNetwork() {
-
- Iterator<ListPage<Network>> networks = api().list(new ListOptions.Builder()
- .filter("name eq " + NETWORK_NAME));
+ Iterator<ListPage<Network>> networks = api().list(filter("name eq " + NETWORK_NAME));
List<Network> networksAsList = networks.next();
assertEquals(networksAsList.size(), 1);
assertNetworkEquals(networksAsList.get(0));
-
}
@Test(groups = "live", dependsOnMethods = "testListNetwork")
public void testDeleteNetwork() {
-
assertGlobalOperationDoneSucessfully(api().delete(NETWORK_NAME), TIME_WAIT);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
index e360863..35decbc 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -26,7 +27,6 @@ import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Region;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -39,7 +39,7 @@ public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListRegion() {
- Iterator<ListPage<Region>> pageIterator = api().list(new ListOptions.Builder().maxResults(1));
+ Iterator<ListPage<Region>> pageIterator = api().list(maxResults(1));
assertTrue(pageIterator.hasNext());
List<Region> regionAsList = pageIterator.next();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
index 1a4f127..ce7fdc8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiExpectTest.java
@@ -18,6 +18,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
@@ -25,7 +26,6 @@ import static org.testng.Assert.assertNull;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
@@ -60,9 +60,10 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
public void testGetOperationResponseIs2xx() throws Exception {
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE)
+ .getRegionOperationApi("myproject", "us-central1");
- assertEquals(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ assertEquals(regionOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
new ParseRegionOperationTest().expected());
}
@@ -71,9 +72,9 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApi("myproject", "us-central1");
- assertNull(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ assertNull(regionOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
}
public void testDeleteOperationResponseIs2xx() throws Exception {
@@ -81,14 +82,15 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.builder()
.method("DELETE")
.endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject", "us-central1");
- regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ regionOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
}
public void testDeleteOperationResponseIs4xx() throws Exception {
@@ -96,14 +98,15 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.builder()
.method("DELETE")
.endpoint(DELETE_OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject", "us-central1");
- regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ regionOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
}
public void testLisOperationWithNoOptionsResponseIs2xx() {
@@ -118,9 +121,9 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.payload(payloadFromResource("/region_operation_list.json")).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
- assertEquals(regionOperationApi.listInRegion("us-central1").next().toString(), expectedList().toString());
+ assertEquals(regionOperationApi.list().next().toString(), expectedList().toString());
}
public void testListOperationWithPaginationOptionsResponseIs2xx() {
@@ -140,11 +143,10 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.payload(payloadFromResource("/region_operation_list.json")).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
- assertEquals(regionOperationApi.listAtMarkerInRegion("us-central1", "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
- "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
- new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ assertEquals(regionOperationApi.listPage("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz", filter("status eq done").maxResults(3)).toString(),
expectedList().toString());
}
@@ -159,8 +161,8 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject", "us-central1");
- assertFalse(regionOperationApi.listInRegion("us-central1").hasNext());
+ assertFalse(regionOperationApi.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
index 66c1041..f15fbf5 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionOperationApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import java.util.Iterator;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.SkipException;
import org.testng.annotations.Test;
@@ -34,13 +34,11 @@ public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
private Operation operation;
private RegionOperationApi api() {
- return api.getRegionOperationApi(userProject.get());
+ return api.getRegionOperationApi(userProject.get(), DEFAULT_REGION_NAME);
}
public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
- // .filter("operationType eq insert")
- .maxResults(1));
+ Iterator<ListPage<Operation>> operations = api().list(maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
int count = 0;
@@ -59,7 +57,7 @@ public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
public void testGetOperation() {
- Operation result = api().getInRegion(DEFAULT_REGION_NAME, operation.name());
+ Operation result = api().get(operation.name());
assertNotNull(result);
assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
index f38a7ea..8d478b6 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/SnapshotApiLiveTest.java
@@ -17,6 +17,7 @@
package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.features.DiskApiLiveTest.TIME_WAIT;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import java.util.Iterator;
@@ -26,7 +27,6 @@ import org.jclouds.googlecomputeengine.domain.Disk;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Snapshot;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -40,16 +40,15 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
}
private DiskApi diskApi() {
- return api.getDiskApi(userProject.get());
+ return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
public void testCreateSnapshot() {
- assertZoneOperationDoneSuccessfully(diskApi().createInZone(DISK_NAME, 1, DEFAULT_ZONE_NAME), TIME_WAIT);
- disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
+ assertZoneOperationDoneSuccessfully(diskApi().create(DISK_NAME, 1), TIME_WAIT);
+ disk = diskApi().get(DISK_NAME);
- assertZoneOperationDoneSuccessfully(diskApi().createSnapshotInZone(DEFAULT_ZONE_NAME, DISK_NAME, SNAPSHOT_NAME),
- TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().createSnapshot(DISK_NAME, SNAPSHOT_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testCreateSnapshot")
@@ -62,9 +61,7 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetSnapshot")
public void testListSnapshot() {
-
- Iterator<ListPage<Snapshot>> snapshots = api().list(new ListOptions.Builder()
- .filter("name eq " + SNAPSHOT_NAME));
+ Iterator<ListPage<Snapshot>> snapshots = api().list(filter("name eq " + SNAPSHOT_NAME));
List<Snapshot> snapshotsAsList = snapshots.next();
@@ -75,8 +72,7 @@ public class SnapshotApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testListSnapshot")
public void testDeleteDisk() {
-
- assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
assertGlobalOperationDoneSucessfully(api().delete(SNAPSHOT_NAME), TIME_WAIT);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
index 631ca4a..26c016a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiExpectTest.java
@@ -154,8 +154,7 @@ public class TargetPoolApiExpectTest extends BaseGoogleComputeEngineApiExpectTes
TOKEN_RESPONSE, list, operationResponse).getTargetPoolApi("myproject", "us-central1");
ListOptions options = new ListOptions();
- assertEquals(api.list(options).toString(),
- new ParseTargetPoolListTest().expected().toString());
+ assertEquals(api.list(options).next().toString(), new ParseTargetPoolListTest().expected().toString());
}
public void testListTargetPoolsResponseIs4xx() {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
index 41d5fa3..753b81a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
@@ -33,7 +34,6 @@ import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
import org.testng.annotations.AfterClass;
@@ -73,8 +73,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
InstanceApi instanceApi = api.getInstanceApi(userProject.get(), DEFAULT_ZONE_NAME);
HttpHealthCheckApi httpHealthCheckApi = api.getHttpHealthCheckApi(userProject.get());
- ListPage<Image> list = api.getImageApi("centos-cloud").list(new ListOptions.Builder().filter("name eq centos.*"))
- .next();
+ ListPage<Image> list = api.getImageApi("centos-cloud").list(filter("name eq centos.*")).next();
// Get an imageUri
URI imageUri = FluentIterable.from(list)
.filter(new Predicate<Image>() {
@@ -104,9 +103,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
// Create a disk.
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instanceTemplate.image());
- assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get())
- .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
- TIME_WAIT_LONG);
+ assertZoneOperationDoneSuccessfully(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME)
+ .create(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, diskCreationOptions), TIME_WAIT_LONG);
// Create an instance.
assertZoneOperationDoneSuccessfully(instanceApi.create(INSTANCE_NAME, instanceTemplate),
@@ -205,8 +203,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
public void testListTargetPool() {
- ListPage<TargetPool> targetPool = api().list(new ListOptions.Builder()
- .filter("name eq " + BACKUP_TARGETPOOL_NAME));
+ ListPage<TargetPool> targetPool = api().list(filter("name eq " + BACKUP_TARGETPOOL_NAME)).next();
assertEquals(Iterables.size(targetPool), 1);
}
@@ -249,11 +246,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
try {
waitZoneOperationDone(instanceApi.delete(INSTANCE_NAME), TIME_WAIT_LONG);
-
- waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
- TIME_WAIT);
+ waitZoneOperationDone(api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME).delete(BOOT_DISK_NAME), TIME_WAIT);
waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete(INSTANCE_NETWORK_NAME), TIME_WAIT_LONG);
-
waitGlobalOperationDone(httpHealthCheckApi.delete(HEALTHCHECK_NAME), TIME_WAIT);
} catch (Exception e) {
// we don't really care about any exception here, so just delete away.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
index f4c885e..c1224d0 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -26,7 +27,6 @@ import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Zone;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -39,8 +39,7 @@ public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testListZone() {
-
- Iterator<ListPage<Zone>> pageIterator = api().list(new ListOptions.Builder().maxResults(1));
+ Iterator<ListPage<Zone>> pageIterator = api().list(maxResults(1));
assertTrue(pageIterator.hasNext());
List<Zone> zoneAsList = pageIterator.next();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
index 4d542ce..4a3136a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java
@@ -18,6 +18,7 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
@@ -25,7 +26,6 @@ import static org.testng.Assert.assertNull;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
@@ -51,9 +51,10 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
public void testGetOperationResponseIs2xx() throws Exception {
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, GET_ZONE_OPERATION_RESPONSE).getZoneOperationApi("myproject");
+ TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, GET_ZONE_OPERATION_RESPONSE)
+ .getZoneOperationApi("myproject", "us-central1-a");
- assertEquals(zoneOperationApi.getInZone("us-central1-a", "operation-1354084865060-4cf88735faeb8-bbbb12cb"),
+ assertEquals(zoneOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
new ParseZoneOperationTest().expected());
}
@@ -62,9 +63,10 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, operationResponse).getZoneOperationApi("myproject");
+ TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, operationResponse)
+ .getZoneOperationApi("myproject", "us-central1-a");
- assertNull(zoneOperationApi.getInZone("us-central1-a", "operation-1354084865060-4cf88735faeb8-bbbb12cb"));
+ assertNull(zoneOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
}
public void testDeleteOperationResponseIs2xx() throws Exception {
@@ -72,14 +74,15 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
.builder()
.method("DELETE")
.endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApi("myproject");
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, delete,
+ operationResponse).getZoneOperationApi("myproject", "us-central1-a");
- zoneOperationApi.deleteInZone("us-central1-a", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ zoneOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
}
public void testDeleteOperationResponseIs4xx() throws Exception {
@@ -87,14 +90,15 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
.builder()
.method("DELETE")
.endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApi("myproject");
+ TOKEN_RESPONSE, delete, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
- zoneOperationApi.deleteInZone("us-central1-a", "operation-1352178598164-4cdcc9d031510-4aa46279");
+ zoneOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
}
private static ListPage<Operation> expectedList() {
@@ -116,9 +120,9 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
.payload(payloadFromResource("/zone_operation_list.json")).build();
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
- assertEquals(zoneOperationApi.listInZone("us-central1-a").next().toString(),
+ assertEquals(zoneOperationApi.list().next().toString(),
expectedList().toString());
}
@@ -139,12 +143,12 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
.payload(payloadFromResource("/zone_operation_list.json")).build();
ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
- assertEquals(zoneOperationApi.listAtMarkerInZone("us-central1-a",
+ assertEquals(zoneOperationApi.listPage(
"CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
"I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
- new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ filter("status eq done").maxResults(3)).toString(),
expectedList().toString());
}
@@ -158,8 +162,9 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
- ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject");
+ ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, get, operationResponse).getZoneOperationApi("myproject", "us-central1-a");
- assertFalse(zoneOperationApi.listInZone("us-central1-a").hasNext());
+ assertFalse(zoneOperationApi.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
index aafea3d..0d9422f 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import java.util.Iterator;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.SkipException;
import org.testng.annotations.Test;
@@ -34,13 +34,11 @@ public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest
private Operation operation;
private ZoneOperationApi api() {
- return api.getZoneOperationApi(userProject.get());
+ return api.getZoneOperationApi(userProject.get(), DEFAULT_ZONE_NAME);
}
public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
-// .filter("operationType eq insert")
- .maxResults(1));
+ Iterator<ListPage<Operation>> operations = api().list(maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
int count = 0;
@@ -59,7 +57,7 @@ public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest
@Test(groups = "live", dependsOnMethods = "testListOperationsWithFiltersAndPagination")
public void testGetOperation() {
- Operation result = api().getInZone(DEFAULT_ZONE_NAME, operation.name());
+ Operation result = api().get(operation.name());
assertNotNull(result);
assertEquals(result.name(), operation.name()); // Checking state besides name can lead to flaky test.
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/internal/ToIteratorOfListPageExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/internal/ToIteratorOfListPageExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/internal/ToIteratorOfListPageExpectTest.java
new file mode 100644
index 0000000..2c961bf
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/internal/ToIteratorOfListPageExpectTest.java
@@ -0,0 +1,185 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.functions.internal;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.Image;
+import org.jclouds.googlecomputeengine.domain.Instance;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.features.AddressApi;
+import org.jclouds.googlecomputeengine.features.ImageApi;
+import org.jclouds.googlecomputeengine.features.InstanceApi;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
+import org.jclouds.googlecomputeengine.parse.ParseAddressTest;
+import org.jclouds.googlecomputeengine.parse.ParseImageTest;
+import org.jclouds.googlecomputeengine.parse.ParseInstanceTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.Json;
+import org.jclouds.json.config.GsonModule;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Guice;
+
+@Test(groups = "unit", testName = "ToIteratorOfListPageTest")
+public class ToIteratorOfListPageExpectTest extends BaseGoogleComputeEngineApiExpectTest {
+
+ private final Json json = Guice.createInjector(new GsonModule(), new GoogleComputeEngineParserModule())
+ .getInstance(Json.class);
+
+ public void globalScope() {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(BASE_URL + "/myproject/global/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list_single_page.json")).build();
+
+ ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list, operationResponse).getImageApi("myproject");
+
+ Iterator<ListPage<Image>> images = imageApi.list();
+
+ assertEquals(images.next().size(), 3);
+ }
+
+ public void multiplePagesProjectScoped() {
+ HttpRequest list1 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(BASE_URL + "/myproject/global/images?maxResults=1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest list2 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/global/images?pageToken=token1&maxResults=1").build();
+
+ HttpRequest list3 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/global/images?pageToken=token2&maxResults=1").build();
+
+ List<Image> items = ImmutableList.of(new ParseImageTest().expected());
+
+ HttpResponse list1Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token1"))).build();
+
+ HttpResponse list2Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token2"))).build();
+
+ HttpResponse list3Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, null))).build();
+
+ ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list1, list1Response, list2, list2Response, list3, list3Response)
+ .getImageApi("myproject");
+
+ Iterator<ListPage<Image>> images = imageApi.list(maxResults(1));
+
+ int imageCounter = 0;
+ while (images.hasNext()) {
+ imageCounter += images.next().size();
+ }
+ assertEquals(imageCounter, 3);
+ }
+
+ public void multiplePagesRegionScoped() {
+ HttpRequest list1 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(BASE_URL + "/myproject/regions/us-central1/addresses?maxResults=1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest list2 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/regions/us-central1/addresses?pageToken=token1&maxResults=1").build();
+
+ HttpRequest list3 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/regions/us-central1/addresses?pageToken=token2&maxResults=1").build();
+
+ List<Address> items = ImmutableList.of(new ParseAddressTest().expected());
+
+ HttpResponse list1Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token1"))).build();
+
+ HttpResponse list2Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token2"))).build();
+
+ HttpResponse list3Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, null))).build();
+
+ AddressApi addressApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list1, list1Response, list2, list2Response, list3, list3Response)
+ .getAddressApi("myproject", "us-central1");
+
+ Iterator<ListPage<Address>> addresses = addressApi.list(maxResults(1));
+
+ int addressCounter = 0;
+ while (addresses.hasNext()) {
+ addressCounter += addresses.next().size();
+ }
+ assertEquals(addressCounter, 3);
+ }
+
+ public void multiplePagesZoneScoped() {
+ HttpRequest list1 = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint(BASE_URL + "/myproject/zones/us-central1-a/instances?maxResults=1")
+ .addHeader("Accept", "application/json")
+ .addHeader("Authorization", "Bearer " + TOKEN).build();
+
+ HttpRequest list2 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/zones/us-central1-a/instances?pageToken=token1&maxResults=1").build();
+
+ HttpRequest list3 = list1.toBuilder()
+ .endpoint(BASE_URL + "/myproject/zones/us-central1-a/instances?pageToken=token2&maxResults=1").build();
+
+ List<Instance> items = ImmutableList.of(new ParseInstanceTest().expected());
+
+ HttpResponse list1Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token1"))).build();
+
+ HttpResponse list2Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, "token2"))).build();
+
+ HttpResponse list3Response = HttpResponse.builder().statusCode(200)
+ .payload(json.toJson(ListPage.create(items, null))).build();
+
+ InstanceApi instanceApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
+ TOKEN_RESPONSE, list1, list1Response, list2, list2Response, list3, list3Response)
+ .getInstanceApi("myproject", "us-central1-a");
+
+ Iterator<ListPage<Instance>> instances = instanceApi.list(maxResults(1));
+
+ int instanceCounter = 0;
+ while (instances.hasNext()) {
+ instanceCounter += instances.next().size();
+ }
+ assertEquals(instanceCounter, 3);
+ }
+}
[4/4] git commit: standardize listPage across all GCE resources.
Posted by ad...@apache.org.
standardize listPage across all GCE resources.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/d7403236
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/d7403236
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/d7403236
Branch: refs/heads/master
Commit: d74032369fbef26972b5f8b996f8e98c3be4b84a
Parents: 8b5d3d3
Author: Adrian Cole <ac...@twitter.com>
Authored: Tue Nov 4 22:26:51 2014 -0800
Committer: Adrian Cole <ac...@twitter.com>
Committed: Wed Nov 5 11:26:31 2014 -0800
----------------------------------------------------------------------
.../GoogleComputeEngineApi.java | 49 ++---
.../binders/DiskCreationBinder.java | 65 +++----
.../TargetPoolChangeHealthChecksBinder.java | 9 +-
.../TargetPoolChangeInstancesBinder.java | 9 +-
.../TargetPoolMapofListofMapGenericBinder.java | 63 +++----
.../compute/GoogleComputeEngineService.java | 12 +-
.../GoogleComputeEngineServiceAdapter.java | 19 +-
...ogleComputeEngineSecurityGroupExtension.java | 10 +-
.../functions/NetworkToSecurityGroup.java | 22 +--
.../features/AddressApi.java | 82 +++-----
.../googlecomputeengine/features/DiskApi.java | 131 +++++--------
.../features/DiskTypeApi.java | 111 +++++------
.../features/FirewallApi.java | 76 +++-----
.../features/ForwardingRuleApi.java | 95 +++++-----
.../features/GlobalOperationApi.java | 60 +++---
.../features/HttpHealthCheckApi.java | 92 ++++-----
.../googlecomputeengine/features/ImageApi.java | 87 +++------
.../features/InstanceApi.java | 13 +-
.../features/MachineTypeApi.java | 45 ++---
.../features/NetworkApi.java | 58 ++----
.../features/ProjectApi.java | 22 +--
.../googlecomputeengine/features/RegionApi.java | 44 ++---
.../features/RegionOperationApi.java | 70 +++----
.../googlecomputeengine/features/RouteApi.java | 111 +++++------
.../features/SnapshotApi.java | 56 ++----
.../features/TargetPoolApi.java | 107 ++++++-----
.../googlecomputeengine/features/ZoneApi.java | 44 ++---
.../features/ZoneOperationApi.java | 67 +++----
.../internal/BaseToIteratorOfListPage.java | 14 +-
.../BaseWithRegionToIteratorOfListPage.java | 16 +-
.../BaseWithZoneToIteratorOfListPage.java | 16 +-
.../functions/internal/ParseAddresses.java | 2 +-
.../functions/internal/ParseDiskTypes.java | 2 +-
.../functions/internal/ParseDisks.java | 2 +-
.../functions/internal/ParseFirewalls.java | 2 +-
.../internal/ParseForwardingRules.java | 2 +-
.../internal/ParseGlobalOperations.java | 2 +-
.../internal/ParseHttpHealthChecks.java | 2 +-
.../functions/internal/ParseImages.java | 2 +-
.../functions/internal/ParseMachineTypes.java | 5 +-
.../functions/internal/ParseNetworks.java | 2 +-
.../internal/ParseRegionOperations.java | 2 +-
.../functions/internal/ParseRegions.java | 2 +-
.../functions/internal/ParseRoutes.java | 2 +-
.../functions/internal/ParseSnapshots.java | 2 +-
.../functions/internal/ParseTargetPools.java | 2 +-
.../functions/internal/ParseZoneOperations.java | 2 +-
.../functions/internal/ParseZones.java | 2 +-
.../options/AttachDiskOptions.java | 50 ++---
.../options/DiskCreationOptions.java | 22 +--
.../options/ListOptions.java | 7 +-
.../RegionOperationDonePredicate.java | 13 +-
.../predicates/ZoneOperationDonePredicate.java | 2 +-
.../PageSystemExpectTest.java | 111 -----------
.../binders/DiskCreationBinderTest.java | 19 +-
.../ForwardingRuleCreationBinderTest.java | 12 --
.../HttpHealthCheckCreationBinderTest.java | 12 --
.../TargetPoolAddInstanceBinderTest.java | 15 +-
.../binders/TargetPoolCreationBinderTest.java | 12 --
.../GoogleComputeEngineServiceLiveTest.java | 9 +-
.../functions/NetworkToSecurityGroupTest.java | 4 +-
.../features/AddressApiExpectTest.java | 30 ++-
.../features/AddressApiLiveTest.java | 14 +-
.../features/DiskApiExpectTest.java | 46 +++--
.../features/DiskApiLiveTest.java | 26 +--
.../features/DiskTypeApiExpectTest.java | 37 ++--
.../features/DiskTypeApiLiveTest.java | 9 +-
.../features/FirewallApiLiveTest.java | 5 +-
.../features/ForwardingRuleApiLiveTest.java | 14 +-
.../features/GlobalOperationApiExpectTest.java | 8 +-
.../features/GlobalOperationApiLiveTest.java | 6 +-
.../features/HttpHealthCheckApiLiveTest.java | 5 +-
.../features/ImageApiExpectTest.java | 4 +-
.../features/ImageApiLiveTest.java | 15 +-
.../features/InstanceApiLiveTest.java | 39 ++--
.../features/MachineTypeApiExpectTest.java | 20 +-
.../features/MachineTypeApiLiveTest.java | 9 +-
.../features/NetworkApiLiveTest.java | 8 +-
.../features/RegionApiLiveTest.java | 4 +-
.../features/RegionOperationApiExpectTest.java | 36 ++--
.../features/RegionOperationApiLiveTest.java | 10 +-
.../features/SnapshotApiLiveTest.java | 18 +-
.../features/TargetPoolApiExpectTest.java | 3 +-
.../features/TargetPoolApiLiveTest.java | 18 +-
.../features/ZoneApiLiveTest.java | 5 +-
.../features/ZoneOperationApiExpectTest.java | 39 ++--
.../features/ZoneOperationApiLiveTest.java | 10 +-
.../ToIteratorOfListPageExpectTest.java | 185 +++++++++++++++++++
88 files changed, 1085 insertions(+), 1538 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
index 19e178b..095f8c8 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
@@ -58,28 +58,31 @@ public interface GoogleComputeEngineApi extends Closeable {
* Provides access to Address features
*
* @param projectName the name of the project
+ * @param region the name of the region scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- AddressApi getAddressApi(@PathParam("project") String projectName);
+ @Path("/projects/{project}/regions/{region}")
+ AddressApi getAddressApi(@PathParam("project") String projectName, @PathParam("region") String region);
/**
* Provides access to Disk features
*
* @param projectName the name of the project
+ * @param zone the name of the zone scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- DiskApi getDiskApi(@PathParam("project") String projectName);
+ @Path("/projects/{project}/zones/{zone}")
+ DiskApi getDiskApi(@PathParam("project") String projectName, @PathParam("zone") String zone);
/**
* Provides access to DiskType features
*
- * @param projectName the name of the project
+ * @param projectName the name of the project
+ * @param zone the name of the zone scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- DiskTypeApi getDiskTypeApi(@PathParam("project") String projectName);
+ @Path("/projects/{project}/zones/{zone}")
+ DiskTypeApi getDiskTypeApi(@PathParam("project") String projectName, @PathParam("zone") String zone);
/**
* Provides access to Firewall features
@@ -87,7 +90,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
FirewallApi getFirewallApi(@PathParam("project") String projectName);
/**
@@ -106,7 +109,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
GlobalOperationApi getGlobalOperationApi(@PathParam("project") String projectName);
/**
@@ -115,7 +118,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}/global/httpHealthChecks")
+ @Path("/projects/{project}/global")
HttpHealthCheckApi getHttpHealthCheckApi(@PathParam("project") String projectName);
/**
@@ -124,7 +127,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
ImageApi getImageApi(@PathParam("project") String projectName);
/**
@@ -141,10 +144,11 @@ public interface GoogleComputeEngineApi extends Closeable {
* Provides access to MachineType features
*
* @param projectName the name of the project
+ * @param zone the name of the zone scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- MachineTypeApi getMachineTypeApi(@PathParam("project") String projectName);
+ @Path("/projects/{project}/zones/{zone}")
+ MachineTypeApi getMachineTypeApi(@PathParam("project") String projectName, @PathParam("zone") String zone);
/**
* Provides access to Network features
@@ -152,7 +156,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
NetworkApi getNetworkApi(@PathParam("project") String projectName);
/**
@@ -173,11 +177,12 @@ public interface GoogleComputeEngineApi extends Closeable {
/**
* Provides access to Region Operation features
*
- * @param projectName the name of the project
+ * @param project the name of the project
+ * @param region the name of the region scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- RegionOperationApi getRegionOperationApi(@PathParam("project") String projectName);
+ @Path("/projects/{project}/regions/{region}")
+ RegionOperationApi getRegionOperationApi(@PathParam("project") String project, @PathParam("region") String region);
/**
* Provides access to Route features
@@ -185,7 +190,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
RouteApi getRouteApi(@PathParam("project") String projectName);
/**
@@ -194,7 +199,7 @@ public interface GoogleComputeEngineApi extends Closeable {
* @param projectName the name of the project
*/
@Delegate
- @Path("/projects/{project}")
+ @Path("/projects/{project}/global")
SnapshotApi getSnapshotApi(@PathParam("project") String projectName);
/**
@@ -220,9 +225,9 @@ public interface GoogleComputeEngineApi extends Closeable {
* Provides access to Zone Operation features
*
* @param projectName the name of the project
+ * @param zone the name of the zone scoping this request.
*/
@Delegate
- @Path("/projects/{project}")
- ZoneOperationApi getZoneOperationApi(@PathParam("project") String projectName);
-
+ @Path("/projects/{project}/zones/{zone}")
+ ZoneOperationApi getZoneOperationApi(@PathParam("project") String projectName, @PathParam("zone") String zone);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinder.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinder.java
index 37aa9b6..16825e5 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinder.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinder.java
@@ -16,54 +16,43 @@
*/
package org.jclouds.googlecomputeengine.binders;
-import java.net.URI;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.Map;
-import javax.inject.Inject;
-
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
+import org.jclouds.rest.MapBinder;
-public class DiskCreationBinder extends BindToJsonPayload {
-
- @Inject DiskCreationBinder(Json jsonBinder) {
- super(jsonBinder);
- }
+import com.google.gson.stream.JsonWriter;
+public final class DiskCreationBinder implements MapBinder {
@Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
DiskCreationOptions options = (DiskCreationOptions) postParams.get("options");
- String name = postParams.get("name").toString();
- int sizeGb = (Integer) postParams.get("sizeGb");
- DiskCreationBinderHelper diskCreationOptionsExtended = new DiskCreationBinderHelper(name, sizeGb, options);
- return super.bindToRequest(request, diskCreationOptionsExtended);
+ Writer out = new StringWriter();
+ JsonWriter json = new JsonWriter(out);
+ json.setSerializeNulls(false);
+ try {
+ json.beginObject();
+ json.name("name").value(postParams.get("name").toString());
+ json.name("sizeGb").value((Integer) postParams.get("sizeGb"));
+ json.name("type").value(options.type() != null ? options.type().toString() : null);
+ json.name("sourceImage").value(options.sourceImage() != null ? options.sourceImage().toString() : null);
+ json.name("sourceSnapshot")
+ .value(options.sourceSnapshot() != null ? options.sourceSnapshot().toString() : null);
+ json.endObject();
+ json.close();
+ } catch (IOException e) {
+ throw new AssertionError(e); // should be impossible as we are writing a string!
+ }
+ request.setPayload(out.toString());
+ request.getPayload().getContentMetadata().setContentType("application/json");
+ return request;
}
- private class DiskCreationBinderHelper{
-
- /**
- * Values used to bind DiskCreationOptions to json request.
- */
- @SuppressWarnings("unused")
- private String name;
- @SuppressWarnings("unused")
- private int sizeGb;
- @SuppressWarnings("unused")
- private URI type;
- @SuppressWarnings("unused")
- private URI sourceImage;
- @SuppressWarnings("unused")
- private URI sourceSnapshot;
-
- private DiskCreationBinderHelper(String name, int sizeGb, DiskCreationOptions diskCreationOptions){
- this.name = name;
- this.sizeGb = sizeGb;
- this.type = diskCreationOptions.getType();
- this.sourceImage = diskCreationOptions.getSourceImage();
- this.sourceSnapshot = diskCreationOptions.getSourceSnapshot();
- }
+ @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new UnsupportedOperationException();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeHealthChecksBinder.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeHealthChecksBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeHealthChecksBinder.java
index 7834803..6c0e0e2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeHealthChecksBinder.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeHealthChecksBinder.java
@@ -18,16 +18,11 @@ package org.jclouds.googlecomputeengine.binders;
import javax.inject.Inject;
-import org.jclouds.json.Json;
-
/**
* Binder used for adding and deleting healthChecks from a target pool.
*/
public final class TargetPoolChangeHealthChecksBinder extends TargetPoolMapofListofMapGenericBinder {
-
- @Inject TargetPoolChangeHealthChecksBinder(Json jsonBinder) {
- super(jsonBinder);
- super.outerString("healthChecks");
- super.innerString("healthCheck");
+ @Inject TargetPoolChangeHealthChecksBinder() {
+ super("healthChecks", "healthCheck");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeInstancesBinder.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeInstancesBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeInstancesBinder.java
index 603654a..4572505 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeInstancesBinder.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolChangeInstancesBinder.java
@@ -18,16 +18,11 @@ package org.jclouds.googlecomputeengine.binders;
import javax.inject.Inject;
-import org.jclouds.json.Json;
-
/**
* Binder used for adding and deleting instances from a target pool.
*/
public final class TargetPoolChangeInstancesBinder extends TargetPoolMapofListofMapGenericBinder {
-
- @Inject TargetPoolChangeInstancesBinder(Json jsonBinder) {
- super(jsonBinder);
- super.outerString("instances");
- super.innerString("instance");
+ @Inject TargetPoolChangeInstancesBinder() {
+ super("instances", "instance");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolMapofListofMapGenericBinder.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolMapofListofMapGenericBinder.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolMapofListofMapGenericBinder.java
index 007b06f..fa611f1 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolMapofListofMapGenericBinder.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/binders/TargetPoolMapofListofMapGenericBinder.java
@@ -16,50 +16,51 @@
*/
package org.jclouds.googlecomputeengine.binders;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
import java.net.URI;
import java.util.List;
import java.util.Map;
-import javax.inject.Inject;
-
import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
+import org.jclouds.rest.MapBinder;
-class TargetPoolMapofListofMapGenericBinder extends BindToJsonPayload {
-
- @Inject TargetPoolMapofListofMapGenericBinder(Json jsonBinder) {
- super(jsonBinder);
- }
+import com.google.gson.stream.JsonWriter;
- private String outterString;
- private String innerString;
+class TargetPoolMapofListofMapGenericBinder implements MapBinder {
+ private final String outterString;
+ private final String innerString;
- public void outerString(String outterString) {
+ TargetPoolMapofListofMapGenericBinder(String outterString, String innerString) {
this.outterString = outterString;
- }
-
- public void innerString(String innerString) {
this.innerString = innerString;
}
- /**
- * For the addInstance request the request body is in an atypical form.
- *
- * @see <a href="https://cloud.google.com/compute/docs/reference/latest/targetPools/addInstance"/>
- */
@Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
- List<URI> instances = (List<URI>) postParams.get(outterString);
- Map<String, List<Map<String, URI>>> finalInstances = Maps.newLinkedHashMap();
- List<Map<String, URI>> innerInstances = Lists.newArrayList();
- for (URI instance : instances) {
- innerInstances.add(ImmutableMap.of(innerString, instance));
+ Writer out = new StringWriter();
+ JsonWriter json = new JsonWriter(out);
+ try {
+ json.beginObject();
+ json.name(outterString);
+ json.beginArray();
+ for (URI uri : (List<URI>) postParams.get(outterString)) {
+ json.beginObject();
+ json.name(innerString).value(uri.toString());
+ json.endObject();
+ }
+ json.endArray();
+ json.endObject();
+ json.close();
+ } catch (IOException e) {
+ throw new AssertionError(e); // should be impossible as we are writing a string!
}
- finalInstances.put(outterString, innerInstances);
- return super.bindToRequest(request, finalInstances);
+ request.setPayload(out.toString());
+ request.getPayload().getContentMetadata().setContentType("application/json");
+ return request;
+ }
+
+ @Override public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ throw new UnsupportedOperationException();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
index a523e64..34b8a87 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineService.java
@@ -76,7 +76,7 @@ import com.google.common.base.Supplier;
import com.google.common.util.concurrent.Atomics;
import com.google.common.util.concurrent.ListeningExecutorService;
-public class GoogleComputeEngineService extends BaseComputeService {
+public final class GoogleComputeEngineService extends BaseComputeService {
private final Function<Set<? extends NodeMetadata>, Set<String>> findOrphanedGroups;
private final GroupNamingConvention.Factory namingConvention;
@@ -86,8 +86,7 @@ public class GoogleComputeEngineService extends BaseComputeService {
private final long operationCompleteCheckInterval;
private final long operationCompleteCheckTimeout;
- @Inject
- protected GoogleComputeEngineService(ComputeServiceContext context,
+ @Inject GoogleComputeEngineService(ComputeServiceContext context,
Map<String, Credentials> credentialStore,
@Memoized Supplier<Set<? extends Image>> images,
@Memoized Supplier<Set<? extends Hardware>> hardwareProfiles,
@@ -148,8 +147,7 @@ public class GoogleComputeEngineService extends BaseComputeService {
}
}
-
- protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
+ private void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
String resourceName = namingConvention.create().sharedNameForGroup(groupName);
Network network = api.getNetworkApi(project.get()).get(resourceName);
FirewallApi firewallApi = api.getFirewallApi(project.get());
@@ -181,10 +179,6 @@ public class GoogleComputeEngineService extends BaseComputeService {
}
}
-
- /**
- * returns template options, except of type {@link org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions}.
- */
@Override
public GoogleComputeEngineTemplateOptions templateOptions() {
return GoogleComputeEngineTemplateOptions.class.cast(super.templateOptions());
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
index c330eda..0a2bc7d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceAdapter.java
@@ -72,6 +72,7 @@ import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.domain.Zone;
import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate;
import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate.PersistentDisk;
+import org.jclouds.googlecomputeengine.features.DiskApi;
import org.jclouds.googlecomputeengine.features.InstanceApi;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
@@ -228,15 +229,12 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
String diskName = instanceName + "-" + GCE_BOOT_DISK_SUFFIX;
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(imageUri);
- Operation diskOperation = api.getDiskApi(userProject.get())
- .createInZone(diskName,
- diskSize,
- template.getLocation().getId(),
- diskCreationOptions);
+ DiskApi diskApi = api.getDiskApi(userProject.get(), template.getLocation().getId());
+ Operation diskOperation = diskApi.create(diskName, diskSize, diskCreationOptions);
waitOperationDone(diskOperation);
- return api.getDiskApi(userProject.get()).getInZone(template.getLocation().getId(), diskName);
+ return diskApi.get(diskName);
}
@Override
@@ -244,7 +242,7 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
ImmutableList.Builder<MachineTypeInZone> builder = ImmutableList.builder();
for (final Location zone : zones.get().values()) {
- for (Iterator<ListPage<MachineType>> i = api.getMachineTypeApi(userProject.get()).listInZone(zone.getId());
+ for (Iterator<ListPage<MachineType>> i = api.getMachineTypeApi(userProject.get(), zone.getId()).list();
i.hasNext(); ) {
builder.addAll(FluentIterable.from(i.next()).filter(new Predicate<MachineType>() {
@Override public boolean apply(MachineType input) {
@@ -328,8 +326,9 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
@Override
public void destroyNode(final String name) {
SlashEncodedIds zoneAndId = SlashEncodedIds.fromSlashEncoded(name);
+ InstanceApi instanceApi = api.getInstanceApi(userProject.get(), zoneAndId.left());
String diskName = null;
- Instance instance = api.getInstanceApi(userProject.get(), zoneAndId.left()).get(zoneAndId.right());
+ Instance instance = instanceApi.get(zoneAndId.right());
if (instance != null &&
"true".equals(instance.metadata().items().get(GCE_DELETE_BOOT_DISK_METADATA_KEY))) {
for (AttachedDisk input : instance.disks()) {
@@ -339,10 +338,10 @@ public final class GoogleComputeEngineServiceAdapter implements ComputeServiceAd
}
}
}
- waitOperationDone(api.getInstanceApi(userProject.get(), zoneAndId.left()).delete(zoneAndId.right()));
+ waitOperationDone(instanceApi.delete(zoneAndId.right()));
if (diskName != null) {
- waitOperationDone(api.getDiskApi(userProject.get()).deleteInZone(zoneAndId.left(), diskName));
+ waitOperationDone(api.getDiskApi(userProject.get(), zoneAndId.left()).delete(diskName));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
index d40db68..28ee3eb 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtension.java
@@ -23,6 +23,7 @@ import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERA
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
import static org.jclouds.googlecomputeengine.compute.strategy.CreateNodesWithGroupEncodedIntoNameThenAddToSet.DEFAULT_INTERNAL_NETWORK_RANGE;
import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.equalsIpPermission;
import static org.jclouds.googlecomputeengine.predicates.NetworkFirewallPredicates.providesIpPermission;
import static org.jclouds.util.Predicates2.retry;
@@ -50,7 +51,6 @@ import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.options.FirewallOptions;
import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions.Builder;
import org.jclouds.net.domain.IpPermission;
import org.jclouds.net.domain.IpProtocol;
@@ -169,7 +169,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
return false;
}
- ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id);
+ ListOptions options = filter("network eq .*/" + id);
FluentIterable<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(options)));
@@ -202,7 +202,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
checkNotNull(api.getNetworkApi(userProject.get()).get(group.getId()) == null, "network for group is null");
- ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
+ ListOptions options = filter("network eq .*/" + group.getName());
if (Iterables
.any(concat(api.getFirewallApi(userProject.get()).list(options)), providesIpPermission(ipPermission))) {
@@ -265,7 +265,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
checkNotNull(api.getNetworkApi(userProject.get()).get(group.getId()) == null, "network for group is null");
- ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
+ ListOptions options = filter("network eq .*/" + group.getName());
FluentIterable<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(options)));
@@ -327,7 +327,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
}
private SecurityGroup groupForTagsInNetwork(Network nw, final Collection<String> tags) {
- ListOptions opts = new Builder().filter("network eq .*/" + nw.name());
+ ListOptions opts = filter("network eq .*/" + nw.name());
List<Firewall> fws = FluentIterable.from(concat(api.getFirewallApi(userProject.get()).list(opts)))
.filter(new Predicate<Firewall>() {
@Override public boolean apply(final Firewall input) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
index 5c4d8ce..1bd4811 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroup.java
@@ -17,41 +17,34 @@
package org.jclouds.googlecomputeengine.compute.functions;
import static org.jclouds.googlecomputeengine.internal.ListPages.concat;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
-import javax.annotation.Resource;
import javax.inject.Inject;
-import javax.inject.Named;
import org.jclouds.compute.domain.SecurityGroup;
import org.jclouds.compute.domain.SecurityGroupBuilder;
-import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.config.UserProject;
import org.jclouds.googlecomputeengine.domain.Firewall;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.logging.Logger;
import org.jclouds.net.domain.IpPermission;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableList;
/**
* A function for transforming a GCE-specific Network into a generic
* SecurityGroup object.
*/
-public class NetworkToSecurityGroup implements Function<Network, SecurityGroup> {
- @Resource
- @Named(ComputeServiceConstants.COMPUTE_LOGGER)
- protected Logger logger = Logger.NULL;
+public final class NetworkToSecurityGroup implements Function<Network, SecurityGroup> {
private final Function<Firewall, Iterable<IpPermission>> firewallToPerms;
private final GoogleComputeEngineApi api;
private final Supplier<String> project;
- @Inject
- public NetworkToSecurityGroup(Function<Firewall, Iterable<IpPermission>> firewallToPerms,
+ @Inject NetworkToSecurityGroup(Function<Firewall, Iterable<IpPermission>> firewallToPerms,
GoogleComputeEngineApi api,
@UserProject Supplier<String> project) {
this.firewallToPerms = firewallToPerms;
@@ -59,8 +52,7 @@ public class NetworkToSecurityGroup implements Function<Network, SecurityGroup>
this.project = project;
}
- @Override
- public SecurityGroup apply(Network network) {
+ @Override public SecurityGroup apply(Network network) {
SecurityGroupBuilder builder = new SecurityGroupBuilder();
builder.id(network.name());
@@ -68,9 +60,9 @@ public class NetworkToSecurityGroup implements Function<Network, SecurityGroup>
builder.name(network.name());
builder.uri(network.selfLink());
- ImmutableSet.Builder permBuilder = ImmutableSet.builder();
+ ImmutableList.Builder permBuilder = ImmutableList.builder();
- ListOptions options = new ListOptions.Builder().filter("network eq .*/" + network.name());
+ ListOptions options = filter("network eq .*/" + network.name());
for (Firewall fw : concat(api.getFirewallApi(project.get()).list(options))) {
permBuilder.addAll(firewallToPerms.apply(fw));
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
index 8babee2..71bd2bb 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -52,109 +52,79 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Addresses via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/addresses")
+@Consumes(APPLICATION_JSON)
public interface AddressApi {
- /**
- * Returns the specified address resource.
- *
- * @param region Name of the region the address is in.
- * @param addressName name of the address resource to return.
- * @return a Address resource.
- */
+ /** Returns an address by name or null if not found. */
@Named("Addresses:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses/{address}")
+ @Path("/{address}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Address getInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+ Address get(@PathParam("address") String address);
/**
- * Creates a address resource in the specified project specifying the size of the address.
- *
- *
- * @param region the name of the region where the address is to be created.
- * @param addressName the name of address.
+ * Creates an address resource in the specified project specifying the size of the address.
+ *
+ * @param address the name of address.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("Addresses:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
+ @Produces(APPLICATION_JSON)
@OAuthScopes({COMPUTE_SCOPE})
@MapBinder(BindToJsonPayload.class)
- Operation createInRegion(@PathParam("region") String region, @PayloadParam("name") String addressName);
+ Operation create(@PayloadParam("name") String address);
- /**
- * Deletes the specified address resource.
- *
- * @param region the region the address is in.
- * @param addressName name of the address resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes an address by name and returns the operation in progress, or null if not found. */
@Named("Addresses:delete")
@DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses/{address}")
+ @Path("/{address}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Operation deleteInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+ Operation delete(@PathParam("address") String address);
/**
- * Retrieves the listPage of address resources contained within the specified project and region.
- * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
- * not been set.
+ * Retrieves the list of address resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param region the region to search in
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listPage
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
+ * @return a page of the list
*/
@Named("Addresses:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseAddresses.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+ ListPage<Address> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * A paged version of AddressApi#listPageInRegion(String)
- *
- * @param region the region to list in
- * @return an Iterator that is able to fetch additional pages when required
- * @see #listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Addresses:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseAddresses.class)
@Transform(ParseAddresses.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Address>> listInRegion(@PathParam("region") String region);
+ Iterator<ListPage<Address>> list();
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
@Named("Addresses:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/regions/{region}/addresses")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseAddresses.class)
@Transform(ParseAddresses.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Address>> listInRegion(@PathParam("region") String region, ListOptions options);
+ Iterator<ListPage<Address>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
index d38c48a..8b485de 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -54,155 +54,114 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Disks via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/disks")
+@Consumes(APPLICATION_JSON)
public interface DiskApi {
- /**
- * Returns the specified persistent disk resource.
- *
- * @param zone Name of the zone the disk is in.
- * @param diskName name of the persistent disk resource to return.
- * @return a Disk resource.
- */
+ /** Returns a persistent disk by name or null if not found. */
@Named("Disks:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks/{disk}")
+ @Path("/{disk}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Disk getInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName);
+ Disk get(@PathParam("disk") String disk);
/**
* Creates a persistent disk resource in the specified project specifying the size of the disk.
*
* @param diskName the name of disk.
* @param sizeGb the size of the disk
- * @param zone the name of the zone where the disk is to be created.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("Disks:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
- @OAuthScopes({COMPUTE_SCOPE})
+ @Produces(APPLICATION_JSON)
+ @OAuthScopes(COMPUTE_SCOPE)
@MapBinder(BindToJsonPayload.class)
- Operation createInZone(@PayloadParam("name") String diskName,
- @PayloadParam("sizeGb") int sizeGb,
- @PathParam("zone") String zone);
+ Operation create(@PayloadParam("name") String diskName, @PayloadParam("sizeGb") int sizeGb);
/**
- * Creates a persistent disk resource, in the specified project,
- * specifying the size of the disk and other options.
+ * Creates a persistent disk resource, in the specified project, specifying the size of the disk and other options.
*
* @param diskName the name of disk.
* @param sizeGb the size of the disk
- * @param zone the name of the zone where the disk is to be created.
* @param options the options of the disk to create.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("Disks:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
- @OAuthScopes({COMPUTE_SCOPE})
+ @Produces(APPLICATION_JSON)
+ @OAuthScopes(COMPUTE_SCOPE)
@MapBinder(DiskCreationBinder.class)
- Operation createInZone(@PayloadParam("name") String diskName,
- @PayloadParam("sizeGb") int sizeGb,
- @PathParam("zone") String zone,
- @PayloadParam("options") DiskCreationOptions options);
+ Operation create(@PayloadParam("name") String diskName,
+ @PayloadParam("sizeGb") int sizeGb,
+ @PayloadParam("options") DiskCreationOptions options);
+
+ /** Deletes a persistent disk by name and returns the operation in progress, or null if not found. */
+ @Named("Disks:delete")
+ @DELETE
+ @Path("/{disk}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation delete(@PathParam("disk") String disk);
/**
- * Deletes the specified persistent disk resource.
+ * Create a snapshot of a given disk in a zone.
+ *
+ * @param diskName the name of the disk.
+ * @param snapshotName the name for the snapshot to be created.
*
- * @param zone the zone the disk is in.
- * @param diskName name of the persistent disk resource to delete.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
- @Named("Disks:delete")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks/{disk}")
+ @Named("Disks:createSnapshot")
+ @POST
+ @Path("/{disk}/createSnapshot")
@OAuthScopes(COMPUTE_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- Operation deleteInZone(@PathParam("zone") String zone, @PathParam("disk") String diskName);
+ @MapBinder(BindToJsonPayload.class)
+ Operation createSnapshot(@PathParam("disk") String diskName, @PayloadParam("name") String snapshotName);
/**
- * Retrieves the listPage of persistent disk resources contained within the specified project and zone.
- * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
- * not been set.
+ * Retrieves the list of persistent disk resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param zone the zone to search in
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listPage
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
+ * @return a page of the list
*/
@Named("Disks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDisks.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Disk> listAtMarkerInZone(@PathParam("zone") String zone, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+ ListPage<Disk> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * A paged version of DiskApi#listPageInZone(String)
- *
- * @param zone the zone to list in
- * @return an Iterator that is able to fetch additional pages when required
- * @see DiskApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Disks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDisks.class)
@Transform(ParseDisks.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Disk>> listInZone(@PathParam("zone") String zone);
+ Iterator<ListPage<Disk>> list();
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
@Named("Disks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseDisks.class)
@Transform(ParseDisks.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Disk>> listInZone(@PathParam("zone") String zone, ListOptions options);
-
- /**
- * Create a snapshot of a given disk in a zone.
- *
- * @param zone the zone the disk is in.
- * @param diskName the name of the disk.
- * @param snapshotName the name for the snapshot to be created.
- *
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
- @Named("Disks:createSnapshot")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/zones/{zone}/disks/{disk}/createSnapshot")
- @OAuthScopes(COMPUTE_SCOPE)
- @MapBinder(BindToJsonPayload.class)
- Operation createSnapshotInZone(@PathParam("zone") String zone,
- @PathParam("disk") String diskName,
- @PayloadParam("name") String snapshotName);
-
+ Iterator<ListPage<Disk>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
index 32cf465..b16939f 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/DiskTypeApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import java.util.Iterator;
@@ -26,7 +27,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -44,76 +44,55 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to DiskTypes via their REST API.
- *
- * @see <a href="https://cloud.google.com/compute/docs/reference/v1/diskTypes"/>
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/diskTypes")
+@Consumes(APPLICATION_JSON)
public interface DiskTypeApi {
- /**
- * Returns the specified disk type resource.
- *
- * @param zone the name of the zone the disk type is in
- * @param diskType name of the disk type resource to return.
- * @return If successful, this method returns a DiskType resource
- */
- @Named("DiskTypes:get")
- @GET
- @Path("/zones/{zone}/diskTypes/{diskType}")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- DiskType getInZone(@PathParam("zone") String zone, @PathParam("diskType") String diskType);
+ /** Returns a disk type by name or null if not found. */
+ @Named("DiskTypes:get")
+ @GET
+ @Path("/{diskType}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ DiskType get(@PathParam("diskType") String diskType);
- /**
- * Retrieves the list of disk type resources available to the specified project.
- * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
- * been set.
- *
- * @param zone The name of the zone to list in.
- * @param marker marks the beginning of the next list page
- * @param listOptions listing options
- * @return a page of the list
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
- */
- @Named("DiskTypes:list")
- @GET
- @Path("/zones/{zone}/diskTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDiskTypes.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<DiskType> listAtMarkerInZone(@PathParam("zone") String zone,
- @QueryParam("pageToken") @Nullable String marker,
- ListOptions listOptions);
+ /**
+ * Retrieves the list of disk type resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ */
+ @Named("DiskTypes:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDiskTypes.class)
+ @Fallback(EmptyListPageOnNotFoundOr404.class)
+ ListPage<DiskType> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
- /**
- * @see DiskTypeApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
- */
- @Named("DiskTypes:list")
- @GET
- @Path("/zones/{zone}/diskTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDiskTypes.class)
- @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
- @Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<DiskType>> listInZone(@PathParam("zone") String zone);
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("DiskTypes:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDiskTypes.class)
+ @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<DiskType>> list();
- /**
- * @see DiskTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
- *
- * @param zone the zone to list in
- * @return an Iterator that is able to fetch additional pages when required
- */
- @Named("DiskTypes:list")
- @GET
- @Path("/zones/{zone}/diskTypes")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseDiskTypes.class)
- @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
- @Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<DiskType>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("DiskTypes:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseDiskTypes.class)
+ @Transform(ParseDiskTypes.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<DiskType>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
index 5a6567d..883d647 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/FirewallApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -32,7 +33,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -58,26 +58,20 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Firewalls via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/firewalls")
+@Consumes(APPLICATION_JSON)
public interface FirewallApi {
- /**
- * Returns the specified image resource.
- *
- * @param firewallName name of the firewall resource to return.
- * @return an Firewall resource
- */
+
+ /** Returns a firewall by name or null if not found. */
@Named("Firewalls:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls/{firewall}")
+ @Path("/{firewall}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Firewall get(@PathParam("firewall") String firewallName);
+ Firewall get(@PathParam("firewall") String firewall);
/**
* Creates a firewall resource in the specified project using the data included in the request.
@@ -90,9 +84,7 @@ public interface FirewallApi {
*/
@Named("Firewalls:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
+ @Produces(APPLICATION_JSON)
@OAuthScopes({COMPUTE_SCOPE})
@MapBinder(FirewallBinder.class)
Operation createInNetwork(@PayloadParam("name") String name,
@@ -102,79 +94,64 @@ public interface FirewallApi {
/**
* Updates the specified firewall resource with the data included in the request.
*
- * @param firewallName the name firewall to be updated.
+ * @param firewall the name firewall to be updated.
* @param firewallOptions the new firewall.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("Firewalls:update")
@PUT
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls/{firewall}")
+ @Produces(APPLICATION_JSON)
+ @Path("/{firewall}")
@OAuthScopes({COMPUTE_SCOPE})
- Operation update(@PathParam("firewall") String firewallName,
+ Operation update(@PathParam("firewall") String firewall,
@BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions);
/**
* Updates the specified firewall resource, with patch semantics, with the data included in the request.
*
- * @param firewallName the name firewall to be updated.
+ * @param firewall the name firewall to be updated.
* @param firewallOptions the new firewall.
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("Firewalls:patch")
@PATCH
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls/{firewall}")
+ @Produces(APPLICATION_JSON)
+ @Path("/{firewall}")
@OAuthScopes({COMPUTE_SCOPE})
- Operation patch(@PathParam("firewall") String firewallName,
+ Operation patch(@PathParam("firewall") String firewall,
@BinderParam(BindToJsonPayload.class) FirewallOptions firewallOptions);
- /**
- * Deletes the specified image resource.
- *
- * @param firewallName name of the firewall resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field. If the image did not exist the result is null.
- */
+ /** Deletes a firewall by name and returns the operation in progress, or null if not found. */
@Named("Firewalls:delete")
@DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls/{firewall}")
+ @Path("/{firewall}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
- Operation delete(@PathParam("firewall") String firewallName);
+ Operation delete(@PathParam("firewall") String firewall);
/**
* Retrieves the list of firewall resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
- * @param marker marks the beginning of the next list page
- * @param options listing options
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
* @return a page of the list
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Firewalls:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseFirewalls.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Firewall> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options);
+ ListPage<Firewall> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see FirewallApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Firewalls:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseFirewalls.class)
@Transform(ParseFirewalls.ToIteratorOfListPage.class)
@@ -182,15 +159,10 @@ public interface FirewallApi {
Iterator<ListPage<Firewall>> list();
/**
- * A paged version of FirewallApi#list()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see FirewallApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Firewalls:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/firewalls")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseFirewalls.class)
@Transform(ParseFirewalls.ToIteratorOfListPage.class)
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
index 95009c0..5e8b4ab 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -54,23 +55,16 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to ForwardingRules via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/forwardingRules")
+@Consumes(APPLICATION_JSON)
public interface ForwardingRuleApi {
- /**
- * Returns the specified ForwardingRule resource.
- *
- * @param forwardingRule the name of the ForwardingRule resource to return.
- * @return a ForwardingRule resource.
- */
+ /** Returns a forwarding rule by name or null if not found. */
@Named("ForwardingRules:get")
@GET
- @Path("/forwardingRules/{forwardingRule}")
+ @Path("/{forwardingRule}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@@ -85,51 +79,23 @@ public interface ForwardingRuleApi {
*/
@Named("ForwardingRules:insert")
@POST
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/forwardingRules")
+ @Produces(APPLICATION_JSON)
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(ForwardingRuleCreationBinder.class)
Operation create(@PayloadParam("name") String forwardingRuleName,
@PayloadParam("options") ForwardingRuleCreationOptions options);
- /**
- * Deletes the specified TargetPool resource.
- *
- * @param forwardingRule name of the persistent forwarding rule resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes a forwarding rule by name and returns the operation in progress, or null if not found. */
@Named("ForwardingRules:delete")
@DELETE
- @Path("/forwardingRules/{forwardingRule}")
+ @Path("/{forwardingRule}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Operation delete(@PathParam("forwardingRule") String forwardingRule);
/**
- * @return an Iterator that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- */
- @Named("ForwardingRules:list")
- @GET
- @Path("/forwardingRules")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseForwardingRules.class)
- @Transform(ParseForwardingRules.ToIteratorOfListPage.class)
- @Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<ForwardingRule>> list();
-
- @Named("ForwardingRules:list")
- @GET
- @Path("/forwardingRules")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseForwardingRules.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<ForwardingRule> list(ListOptions options);
-
- /**
* Changes the target url for a forwarding rule.
*
* @param forwardingRule the name of the ForwardingRule resource in which target is to be set.
@@ -141,11 +107,48 @@ public interface ForwardingRuleApi {
*/
@Named("ForwardingRules:setTarget")
@POST
- @Path("/forwardingRules/{forwardingRule}/setTarget")
+ @Path("/{forwardingRule}/setTarget")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@MapBinder(BindToJsonPayload.class)
@Nullable
- Operation setTarget(@PathParam("forwardingRule") String forwardingRule,
- @PayloadParam("target") URI target);
+ Operation setTarget(@PathParam("forwardingRule") String forwardingRule, @PayloadParam("target") URI target);
+
+ /**
+ * Retrieves the list of forwarding rule resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ */
+ @Named("ForwardingRules:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseForwardingRules.class)
+ @Fallback(EmptyListPageOnNotFoundOr404.class)
+ ListPage<ForwardingRule> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ForwardingRules:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseForwardingRules.class)
+ @Transform(ParseForwardingRules.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<ForwardingRule>> list();
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("ForwardingRules:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseForwardingRules.class)
+ @Transform(ParseForwardingRules.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<ForwardingRule>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
index 0d23b03..892a8d8 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/GlobalOperationApi.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -28,7 +30,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -46,83 +47,64 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Global Operations via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/operations")
+@Consumes(APPLICATION_JSON)
public interface GlobalOperationApi {
- /**
- * Retrieves the specified operation resource.
- *
- * @param operationName name of the operation resource to return.
- * @return If successful, this method returns an Operation resource
- */
+ /** Returns an operation by name or null if not found. */
@Named("GlobalOperations:get")
@GET
- @Path("/global/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
- Operation get(@PathParam("operation") String operationName);
+ @Nullable
+ Operation get(@PathParam("operation") String operation);
- /**
- * Deletes the specified operation resource.
- *
- * @param operationName name of the operation resource to delete.
- */
+ /** Deletes an operation by name. */
@Named("GlobalOperations:delete")
@DELETE
- @Path("/global/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- void delete(@PathParam("operation") String operationName);
+ @Fallback(VoidOnNotFoundOr404.class)
+ void delete(@PathParam("operation") String operation);
/**
- * Retrieves the listFirstPage of operation resources contained within the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Retrieves the list of operation resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the list, starting at marker
+ * @return a page of the list
*/
@Named("GlobalOperations:list")
@GET
- @Path("/global/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+ ListPage<Operation> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see GlobalOperationApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("GlobalOperations:list")
@GET
- @Path("/global/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
@Transform(ParseGlobalOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
Iterator<ListPage<Operation>> list();
/**
- * A paged version of GlobalOperationApi#listFirstPage()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see GlobalOperationApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("GlobalOperations:list")
@GET
- @Path("/global/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseGlobalOperations.class)
@Transform(ParseGlobalOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Operation>> list(ListOptions listOptions);
+ Iterator<ListPage<Operation>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
index 892bba3..1e61ce3 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApi.java
@@ -16,9 +16,9 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import java.util.Iterator;
@@ -31,10 +31,11 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyListPageOnNotFoundOr404;
import org.jclouds.googlecomputeengine.binders.HttpHealthCheckCreationBinder;
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
import org.jclouds.googlecomputeengine.domain.ListPage;
@@ -55,20 +56,13 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to HttpHealthChecks via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/httpHealthChecks")
+@Consumes(APPLICATION_JSON)
public interface HttpHealthCheckApi {
- /**
- * Returns the specified HttpHealthCheck resource.
- *
- * @param httpHealthCheck the name of the HttpHealthCheck resource to return.
- * @return a HttpHealthCheck resource.
- */
+ /** Returns a health check by name or null if not found. */
@Named("HttpHealthChecks:get")
@GET
@Path("/{httpHealthCheck}")
@@ -86,7 +80,7 @@ public interface HttpHealthCheckApi {
*/
@Named("HttpHealthChecks:insert")
@POST
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces(APPLICATION_JSON)
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(BindToJsonPayload.class)
Operation insert(@PayloadParam("name") String httpHealthCheckName);
@@ -100,18 +94,12 @@ public interface HttpHealthCheckApi {
*/
@Named("HttpHealthChecks:insert")
@POST
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces(APPLICATION_JSON)
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(HttpHealthCheckCreationBinder.class)
Operation insert(@PayloadParam("name") String name, @PayloadParam("options") HttpHealthCheckCreationOptions options);
- /**
- * Deletes the specified TargetPool resource.
- *
- * @param httpHealthCheck name of the persistent forwarding rule resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes a health check by name and returns the operation in progress, or null if not found. */
@Named("HttpHealthChecks:delete")
@DELETE
@Path("/{httpHealthCheck}")
@@ -121,29 +109,6 @@ public interface HttpHealthCheckApi {
Operation delete(@PathParam("httpHealthCheck") String httpHealthCheck);
/**
- * @return an Iterator that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- */
- @Named("HttpHealthChecks:list")
- @GET
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseHttpHealthChecks.class)
- @Transform(ParseHttpHealthChecks.ToIteratorOfListPage.class)
- @Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<HttpHealthCheck>> list();
-
- /**
- * @param options @see org.jclouds.googlecomputeengine.options.ListOptions
- * @return ListPage
- */
- @Named("HttpHealthChecks:list")
- @GET
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseHttpHealthChecks.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<HttpHealthCheck> list(ListOptions options);
-
- /**
* Updates a HttpHealthCheck resource in the specified project
* using the data included in the request. This method supports patch semantics.
*
@@ -173,10 +138,47 @@ public interface HttpHealthCheckApi {
@Named("HttpHealthChecks:update")
@PUT
@Path("/{httpHealthCheck}")
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces(APPLICATION_JSON)
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(HttpHealthCheckCreationBinder.class)
Operation update(@PathParam("httpHealthCheck") @PayloadParam("name") String name,
@PayloadParam("options") HttpHealthCheckCreationOptions options);
+ /**
+ * Retrieves the list of persistent http health check resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ */
+ @Named("HttpHealthChecks:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseHttpHealthChecks.class)
+ @Fallback(EmptyListPageOnNotFoundOr404.class)
+ ListPage<HttpHealthCheck> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("HttpHealthChecks:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseHttpHealthChecks.class)
+ @Transform(ParseHttpHealthChecks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<HttpHealthCheck>> list();
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("HttpHealthChecks:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseHttpHealthChecks.class)
+ @Transform(ParseHttpHealthChecks.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<HttpHealthCheck>> list(ListOptions options);
}
[2/4] standardize listPage across all GCE resources.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
index 707f8c6..e2fe73f 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java
@@ -47,7 +47,7 @@ public final class ParseRegions extends ParseJson<ListPage<Region>> {
final ListOptions options) {
return new Function<String, ListPage<Region>>() {
@Override public ListPage<Region> apply(String input) {
- return api.getRegionApi(projectName).listAtMarker(input, options);
+ return api.getRegionApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
index 59053e5..c56c9e4 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java
@@ -48,7 +48,7 @@ public final class ParseRoutes extends ParseJson<ListPage<Route>> {
final ListOptions options) {
return new Function<String, ListPage<Route>>() {
@Override public ListPage<Route> apply(String input) {
- return api.getRouteApi(projectName).listAtMarker(input, options);
+ return api.getRouteApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
index a5df763..2265012 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java
@@ -47,7 +47,7 @@ public final class ParseSnapshots extends ParseJson<ListPage<Snapshot>> {
final ListOptions options) {
return new Function<String, ListPage<Snapshot>>() {
@Override public ListPage<Snapshot> apply(String input) {
- return api.getSnapshotApi(projectName).listAtMarker(input, options);
+ return api.getSnapshotApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
index 466a859..d23ab07 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java
@@ -52,7 +52,7 @@ public final class ParseTargetPools extends ParseJson<ListPage<TargetPool>> {
@Override
public ListPage<TargetPool> apply(String input) {
- return api.getTargetPoolApi(projectName, regionName).list(options);
+ return api.getTargetPoolApi(projectName, regionName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
index 5bad3df..de2e6ec 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
@@ -48,7 +48,7 @@ public final class ParseZoneOperations extends ParseJson<ListPage<Operation>> {
return new Function<String, ListPage<Operation>>() {
@Override public ListPage<Operation> apply(String input) {
- return api.getZoneOperationApi(projectName).listAtMarkerInZone(zoneName, input, options);
+ return api.getZoneOperationApi(projectName, zoneName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
index 0253f9e..fee1fdc 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
@@ -48,7 +48,7 @@ public final class ParseZones extends ParseJson<ListPage<Zone>> {
final ListOptions options) {
return new Function<String, ListPage<Zone>>() {
@Override public ListPage<Zone> apply(String input) {
- return api.getZoneApi(projectName).listAtMarker(input, options);
+ return api.getZoneApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
index 5ad2846..4f85702 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java
@@ -23,7 +23,7 @@ import java.net.URI;
*
* @see <a href="https://developers.google.com/compute/docs/reference/latest/instances/attachDisk"/>
*/
-public class AttachDiskOptions {
+public final class AttachDiskOptions {
public enum DiskType {
SCRATCH,
@@ -41,53 +41,31 @@ public class AttachDiskOptions {
private String deviceName;
private boolean boot;
- /**
- * The disk type
- *
- * @return the disk type.
- */
- public DiskType getType() {
+ public DiskType type() {
return type;
}
- /**
- * The disk mode
- *
- * @return the disk mode
- */
- public DiskMode getMode() {
+ public DiskMode mode() {
return mode;
}
- /**
- * The URI of the source disk - optional, if DiskType.SCRATCH is used.
- *
- * @return the URI
- */
- public URI getSource() {
+ /** The URI of the source disk - optional, if DiskType.SCRATCH is used. */
+ public URI source() {
return source;
}
- /**
- * The device name on the instance - optional.
- *
- * @return the device name
- */
- public String getDeviceName() {
+ /** The device name on the instance - optional. */
+ public String deviceName() {
return deviceName;
}
- /**
- * Indicates that this is a boot disk. VM will use the first partition of the disk for its root filesystem.
- *
- * @return true if this is a boot disk, false otherwise
- */
- public boolean getBoot() {
+ /** True if this is a boot disk. VM will use the first partition of the disk for its root filesystem. */
+ public boolean boot() {
return boot;
}
/**
- * @see AttachDiskOptions#getType()
+ * @see AttachDiskOptions#type()
*/
public AttachDiskOptions type(DiskType type) {
this.type = type;
@@ -95,7 +73,7 @@ public class AttachDiskOptions {
}
/**
- * @see AttachDiskOptions#getMode()
+ * @see AttachDiskOptions#mode()
*/
public AttachDiskOptions mode(DiskMode mode) {
this.mode = mode;
@@ -103,7 +81,7 @@ public class AttachDiskOptions {
}
/**
- * @see AttachDiskOptions#getSource()
+ * @see AttachDiskOptions#source()
*/
public AttachDiskOptions source(URI source) {
this.source = source;
@@ -111,7 +89,7 @@ public class AttachDiskOptions {
}
/**
- * @see AttachDiskOptions#getDeviceName()
+ * @see AttachDiskOptions#deviceName()
*/
public AttachDiskOptions deviceName(String deviceName) {
this.deviceName = deviceName;
@@ -119,7 +97,7 @@ public class AttachDiskOptions {
}
/**
- * @see org.jclouds.googlecomputeengine.options.AttachDiskOptions#getBoot()
+ * @see AttachDiskOptions#boot()
*/
public AttachDiskOptions boot(boolean boot) {
this.boot = boot;
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java
index 7c70586..2dd215c 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java
@@ -18,16 +18,8 @@ package org.jclouds.googlecomputeengine.options;
import java.net.URI;
-/**
- * Options for attaching disks to instances.
- *
- * @see <a href="https://cloud.google.com/compute/docs/reference/latest/disks/insert"/>
- */
-public class DiskCreationOptions {
+public final class DiskCreationOptions {
- /**
- * DiskCreationBinder extends this class to add name and sizeGb
- */
private URI type;
private URI sourceImage;
private URI sourceSnapshot;
@@ -37,7 +29,7 @@ public class DiskCreationOptions {
*
* @return the disk type
*/
- public URI getType(){
+ public URI type(){
return type;
}
@@ -46,7 +38,7 @@ public class DiskCreationOptions {
*
* @return sourceImage, fully qualified URL for the image to be copied.
*/
- public URI getSourceImage(){
+ public URI sourceImage(){
return sourceImage;
}
@@ -55,12 +47,12 @@ public class DiskCreationOptions {
*
* @return sourceSnapshot, fully qualified URL for the snapshot to be copied.
*/
- public URI getSourceSnapshot(){
+ public URI sourceSnapshot(){
return sourceSnapshot;
}
/**
- * @see DiskCreationOptions#getType()
+ * @see DiskCreationOptions#type()
*/
public DiskCreationOptions type(URI type){
this.type = type;
@@ -68,7 +60,7 @@ public class DiskCreationOptions {
}
/**
- * @see DiskCreationOptions#getSourceImage()
+ * @see DiskCreationOptions#sourceImage()
*/
public DiskCreationOptions sourceImage(URI sourceImage){
this.sourceImage = sourceImage;
@@ -76,7 +68,7 @@ public class DiskCreationOptions {
}
/**
- * @see DiskCreationOptions#getSourceSnapshot()
+ * @see DiskCreationOptions#sourceSnapshot()
*/
public DiskCreationOptions sourceSnapshot(URI sourceSnapshot){
this.sourceSnapshot = sourceSnapshot;
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
index 3944486..0c46000 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java
@@ -23,7 +23,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
/**
* Allows to optionally specify a filter, max results and a page token for <code>listFirstPage()</code> REST methods.
*/
-public class ListOptions extends BaseHttpRequestOptions {
+public final class ListOptions extends BaseHttpRequestOptions {
/**
* Optional. Filter expression for filtering listed resources, in the form filter={expression}. Your {expression}
@@ -70,7 +70,7 @@ public class ListOptions extends BaseHttpRequestOptions {
return this;
}
- public static class Builder {
+ public static final class Builder {
/**
* @see ListOptions#filter(String)
@@ -85,5 +85,8 @@ public class ListOptions extends BaseHttpRequestOptions {
public static ListOptions maxResults(Integer maxResults) {
return new ListOptions().maxResults(maxResults);
}
+
+ private Builder(){
+ }
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
index 2ebfaa3..1eb3f4d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java
@@ -22,6 +22,8 @@ import java.net.URI;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
+import javax.inject.Inject;
+
import org.jclouds.collect.Memoized;
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
import org.jclouds.googlecomputeengine.config.UserProject;
@@ -30,10 +32,8 @@ import org.jclouds.googlecomputeengine.domain.Region;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
-import com.google.inject.Inject;
public final class RegionOperationDonePredicate implements Predicate<AtomicReference<Operation>> {
-
private final GoogleComputeEngineApi api;
private final Supplier<String> project;
private final Supplier<Map<URI, Region>> regions;
@@ -46,11 +46,10 @@ public final class RegionOperationDonePredicate implements Predicate<AtomicRefer
}
@Override public boolean apply(AtomicReference<Operation> input) {
- checkNotNull(input, "input");
-
- Operation current = api.getRegionOperationApi(project.get())
- .getInRegion(regions.get().get(input.get().region()).name(),
- input.get().name());
+ checkNotNull(input.get(), "input");
+ URI region = checkNotNull(input.get().region(), "region of %s", input.get());
+ String locationId = checkNotNull(regions.get().get(region), "location of %s", region).id();
+ Operation current = api.getRegionOperationApi(project.get(), locationId).get(input.get().name());
switch (current.status()) {
case DONE:
input.set(current);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
index 1f60dd9..9c727ed 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java
@@ -52,7 +52,7 @@ public final class ZoneOperationDonePredicate implements Predicate<AtomicReferen
checkNotNull(input.get(), "input");
URI zone = checkNotNull(input.get().zone(), "zone of %s", input.get());
String locationId = checkNotNull(zones.get().get(zone), "location of %s", zone).getId();
- Operation current = api.getZoneOperationApi(project.get()).getInZone(locationId, input.get().name());
+ Operation current = api.getZoneOperationApi(project.get(), locationId).get(input.get().name());
switch (current.status()) {
case DONE:
input.set(current);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
deleted file mode 100644
index 7f2ed9d..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecomputeengine;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertSame;
-
-import java.util.Iterator;
-
-import org.jclouds.googlecomputeengine.domain.Image;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.features.ImageApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-/**
- * A test specifically for the paging system. The code used is common to all list() methods so we're using Images
- * but it could be anything else.
- */
-@Test(groups = "unit")
-public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public void testGetSinglePage() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/image_list_single_page.json")).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getImageApi("myproject");
-
- Iterator<ListPage<Image>> images = imageApi.list();
-
- assertEquals(images.next().size(), 3);
- }
-
- public void testGetMultiplePages() {
- HttpRequest list1 = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images?maxResults=3")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpRequest list2 = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images?pageToken" +
- "=CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx&maxResults=3")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpRequest list3 = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images?pageToken" +
- "=CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2&maxResults=3")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse list1response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/image_list_multiple_page_1.json")).build();
-
- HttpResponse list2Response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/image_list_multiple_page_2.json")).build();
-
- HttpResponse list3Response = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/image_list_single_page.json")).build();
-
-
- ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
- .getImageApi("myproject");
-
- Iterator<ListPage<Image>> images = imageApi.list(new ListOptions.Builder().maxResults(3));
-
- int imageCounter = 0;
- while (images.hasNext()) {
- imageCounter += images.next().size();
- }
- assertSame(imageCounter, 9);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java
index 5075cdb..86ea1a0 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java
@@ -24,44 +24,29 @@ import java.util.Map;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.json.internal.GsonWrapper;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
-import com.google.gson.Gson;
-/**
- * Tests behavior of {@code BindToJsonPayload}
- */
@Test(groups = "unit", testName = "DiskCreationBinderTest")
public class DiskCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
private static final String FAKE_SOURCE_IMAGE = "https://www.googleapis.com/compute/v1/projects/" +
"debian-cloud/global/images/backports-debian-7-wheezy-v20141017";
- Json json = new GsonWrapper(new Gson());
+ DiskCreationBinder binder = new DiskCreationBinder();
@Test
public void testMap() throws SecurityException, NoSuchMethodException {
- DiskCreationBinder binder = new DiskCreationBinder(json);
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(FAKE_SOURCE_IMAGE));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
Map<String, Object> postParams = ImmutableMap.of("name", "testName", "sizeGb", 15, "options", diskCreationOptions);
- binder.bindToRequest(request, postParams);
+ request = binder.bindToRequest(request, postParams);
assertEquals(request.getPayload().getRawContent(),
"{\"name\":\"testName\",\"sizeGb\":15,\"sourceImage\":\"" + FAKE_SOURCE_IMAGE + "\"}");
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
-
}
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullIsBad() {
- DiskCreationBinder binder = new DiskCreationBinder(json);
- binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null);
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java
index 66f8b3d..3a480d8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java
@@ -32,10 +32,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
-
-/**
- * Tests behavior of {@code BindToJsonPayload}
- */
@Test(groups = "unit", testName = "ForwardingRuleCreationBinderTest")
public class ForwardingRuleCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
@@ -72,13 +68,5 @@ public class ForwardingRuleCreationBinderTest extends BaseGoogleComputeEngineExp
+ "\"target\":\"" + TARGET + "\""
+ "}");
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
-
}
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullIsBad() {
- ForwardingRuleCreationBinder binder = new ForwardingRuleCreationBinder(json);
- binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null);
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
index 1dec9dc..e9a8fe4 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java
@@ -30,10 +30,6 @@ import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
-
-/**
- * Tests behavior of {@code BindToJsonPayload}
- */
@Test(groups = "unit", testName = "HttpHealthCheckCreationBinderTest")
public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
@@ -68,13 +64,5 @@ public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineEx
+ "\"description\":\"" + DESCRIPTION + "\""
+ "}");
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
-
}
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullIsBad() {
- DiskCreationBinder binder = new DiskCreationBinder(json);
- binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null);
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java
index 129d006..d20fb22 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java
@@ -24,13 +24,10 @@ import java.util.Map;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.json.internal.GsonWrapper;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.gson.Gson;
@Test(groups = "unit", testName = "TargetPoolAddInstanceBinderTest")
public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
@@ -40,12 +37,11 @@ public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpe
"projects/project/zones/us-central1-a/instances/instance-1"),
URI.create("https://www.googleapis.com/compute/v1/" +
"projects/project/zones/us-central1-a/instances/instance-2"));
-
- Json json = new GsonWrapper(new Gson());
+
+ TargetPoolChangeInstancesBinder binder = new TargetPoolChangeInstancesBinder();
@Test
public void testMap() throws SecurityException, NoSuchMethodException {
- TargetPoolChangeInstancesBinder binder = new TargetPoolChangeInstancesBinder(json);
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
Map<String, Object> postParams = ImmutableMap.of("instances", (Object) FAKE_INSTANCES);
@@ -59,12 +55,5 @@ public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpe
+ "]"
+ "}");
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
-
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullIsBad() {
- DiskCreationBinder binder = new DiskCreationBinder(json);
- binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
index 2c756c0..f55e938 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java
@@ -34,10 +34,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
-
-/**
- * Tests behavior of {@code BindToJsonPayload}
- */
@Test(groups = "unit", testName = "TargetPoolCreationBinderTest")
public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
@@ -72,13 +68,5 @@ public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectT
+ "\"description\":\"This is a test!\""
+ "}");
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
-
}
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNullIsBad() {
- DiskCreationBinder binder = new DiskCreationBinder(json);
- binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null);
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
index e7470e7..5a9f52e 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java
@@ -22,7 +22,6 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.Properties;
-import java.util.Set;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.NodeMetadata;
@@ -66,17 +65,13 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
Supplier<String> userProject = context.utils().injector().getInstance(Key.get(new TypeLiteral<Supplier<String>>() {
}, UserProject.class));
ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder();
- for (MachineType machine : api.getMachineTypeApi(userProject.get())
- .listInZone(DEFAULT_ZONE_NAME).next()) {
+ for (MachineType machine : api.getMachineTypeApi(userProject.get(), DEFAULT_ZONE_NAME).list().next()) {
if (machine.deprecated() != null) {
deprecatedMachineTypes.add(machine.id());
}
}
ImmutableSet<String> deprecatedMachineTypeIds = deprecatedMachineTypes.build();
- Set<? extends Hardware> hardwareProfiles = client.listHardwareProfiles();
- System.out.println(hardwareProfiles.size());
- for (Hardware hardwareProfile : hardwareProfiles) {
- System.out.println(hardwareProfile);
+ for (Hardware hardwareProfile : client.listHardwareProfiles()) {
assertFalse(contains(deprecatedMachineTypeIds, hardwareProfile.getId()));
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
index 76454d4..891a5a9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java
@@ -22,6 +22,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasProtocol;
import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasStartAndEndPort;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -33,7 +34,6 @@ import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Network;
import org.jclouds.googlecomputeengine.features.FirewallApi;
import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions.Builder;
import org.jclouds.net.domain.IpProtocol;
import org.testng.annotations.Test;
@@ -58,7 +58,7 @@ public class NetworkToSecurityGroupTest {
GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
FirewallApi fwApi = createMock(FirewallApi.class);
- ListOptions options = new Builder().filter("network eq .*/jclouds-test");
+ ListOptions options = filter("network eq .*/jclouds-test");
expect(api.getFirewallApi(projectSupplier.get()))
.andReturn(fwApi);
expect(fwApi.list(options)).andReturn(
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
index 09e9057..ef18d2b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
@@ -47,10 +47,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/address_get.json")).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject", "us-central1");
- assertEquals(api.getInRegion("us-central1", "test-ip1"),
- new ParseAddressTest().expected());
+ assertEquals(api.get("test-ip1"), new ParseAddressTest().expected());
}
public void testGetAddressResponseIs4xx() throws Exception {
@@ -64,9 +63,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject", "us-central1");
- assertNull(api.getInRegion("us-central1", "test-ip1"));
+ assertNull(api.get("test-ip1"));
}
public void testInsertAddressResponseIs2xx() {
@@ -84,9 +83,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, insert,
- insertAddressResponse).getAddressApi("myproject");
+ insertAddressResponse).getAddressApi("myproject", "us-central1");
- assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseRegionOperationTest().expected());
+ assertEquals(api.create("test-ip1"), new ParseRegionOperationTest().expected());
}
public void testDeleteAddressResponseIs2xx() {
@@ -101,10 +100,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/region_operation.json")).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject", "us-central1");
- assertEquals(api.deleteInRegion("us-central1", "test-ip1"),
- new ParseRegionOperationTest().expected());
+ assertEquals(api.delete("test-ip1"), new ParseRegionOperationTest().expected());
}
public void testDeleteAddressResponseIs4xx() {
@@ -118,9 +116,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject", "us-central1");
- assertNull(api.deleteInRegion("us-central1", "test-ip1"));
+ assertNull(api.delete("test-ip1"));
}
public void testListAddresssResponseIs2xx() {
@@ -135,9 +133,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/address_list.json")).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject", "us-central1");
- assertEquals(api.listInRegion("us-central1").next().toString(), new ParseAddressListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseAddressListTest().expected().toString());
}
public void testListAddresssResponseIs4xx() {
@@ -151,8 +149,8 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
+ TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject", "us-central1");
- assertFalse(api.listInRegion("us-central1").hasNext());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
index cbd707c..f076687 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import java.util.Iterator;
import org.jclouds.googlecomputeengine.domain.Address;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -33,18 +33,18 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private static final int TIME_WAIT = 30;
private AddressApi api() {
- return api.getAddressApi(userProject.get());
+ return api.getAddressApi(userProject.get(), DEFAULT_REGION_NAME);
}
@Test(groups = "live")
public void testInsertAddress() {
- assertRegionOperationDoneSucessfully(api().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
+ assertRegionOperationDoneSucessfully(api().create(ADDRESS_NAME), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertAddress")
public void testGetAddress() {
- Address address = api().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME);
+ Address address = api().get(ADDRESS_NAME);
assertNotNull(address);
assertEquals(address.name(), ADDRESS_NAME);
}
@@ -52,15 +52,13 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetAddress")
public void testListAddress() {
- Iterator<ListPage<Address>> addresses = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
- .filter("name eq " + ADDRESS_NAME));
-
+ Iterator<ListPage<Address>> addresses = api().list(filter("name eq " + ADDRESS_NAME));
assertEquals(addresses.next().size(), 1);
}
@Test(groups = "live", dependsOnMethods = "testListAddress")
public void testDeleteAddress() {
- assertRegionOperationDoneSucessfully(api().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
+ assertRegionOperationDoneSucessfully(api().delete(ADDRESS_NAME), TIME_WAIT);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
index d11f26d..6122b2b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
@@ -53,9 +53,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/disk_get.json")).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject", "us-central1-a");
- assertEquals(api.getInZone("us-central1-a", "testimage1"),
+ assertEquals(api.get("testimage1"),
new ParseDiskTest().expected());
}
@@ -70,9 +70,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject", "us-central1-a");
- assertNull(api.getInZone("us-central1-a", "testimage1"));
+ assertNull(api.get("testimage1"));
}
public void testInsertDiskResponseIs2xx() {
@@ -90,9 +90,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApi("myproject");
+ insertDiskResponse).getDiskApi("myproject", "us-central1-a");
- assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseZoneOperationTest().expected());
+ assertEquals(api.create("testimage1", 1), new ParseZoneOperationTest().expected());
}
public void testInsertDiskFromImageResponseIs2xx() {
@@ -110,11 +110,10 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApi("myproject");
+ insertDiskResponse).getDiskApi("myproject", "us-central1-a");
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL));
- assertEquals(api.createInZone("testimage1", 1, "us-central1-a", diskCreationOptions),
- new ParseZoneOperationTest().expected());
+ assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
}
public void testInsertDiskSSDResponseIs2xx(){
@@ -132,11 +131,10 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApi("myproject");
+ insertDiskResponse).getDiskApi("myproject", "us-central1-a");
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL));
- assertEquals(api.createInZone("testimage1", 1,
- "us-central1-a", diskCreationOptions), new ParseZoneOperationTest().expected());
+ assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
}
public void testCreateSnapshotResponseIs2xx() {
@@ -154,9 +152,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApi("myproject");
+ createSnapshotResponse).getDiskApi("myproject", "us-central1-a");
- assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"),
+ assertEquals(api.createSnapshot("testimage1", "test-snap"),
new ParseZoneOperationTest().expected());
}
@@ -175,9 +173,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApi("myproject");
+ createSnapshotResponse).getDiskApi("myproject", "us-central1-a");
- api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap");
+ api.createSnapshot("testimage1", "test-snap");
}
public void testDeleteDiskResponseIs2xx() {
@@ -192,9 +190,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/zone_operation.json")).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject", "us-central1-a");
- assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
+ assertEquals(api.delete("testimage1"),
new ParseZoneOperationTest().expected());
}
@@ -209,9 +207,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject", "us-central1-a");
- assertNull(api.deleteInZone("us-central1-a", "testimage1"));
+ assertNull(api.delete("testimage1"));
}
public void testListDisksResponseIs2xx() {
@@ -226,9 +224,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
.payload(payloadFromResource("/disk_list.json")).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject", "us-central1-a");
- assertEquals(api.listInZone("us-central1-a").next().toString(), new ParseDiskListTest().expected().toString());
+ assertEquals(api.list().next().toString(), new ParseDiskListTest().expected().toString());
}
public void testListDisksResponseIs4xx() {
@@ -242,8 +240,8 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
+ TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject", "us-central1-a");
- assertFalse(api.listInZone("us-central1-a").hasNext());
+ assertFalse(api.list().hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
index d05454a..ad771d9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Disk;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -38,40 +38,35 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public static final int sizeGb = 1;
private DiskApi api() {
- return api.getDiskApi(userProject.get());
+ return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
public void testInsertDisk() {
- assertZoneOperationDoneSuccessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().create(DISK_NAME, sizeGb), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertDisk")
public void testGetDisk() {
-
- Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
+ Disk disk = api().get(DISK_NAME);
assertNotNull(disk);
assertDiskEquals(disk);
}
@Test(groups = "live", dependsOnMethods = "testGetDisk")
public void testListDisk() {
-
- Iterator<ListPage<Disk>> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .filter("name eq " + DISK_NAME));
+ Iterator<ListPage<Disk>> disks = api().list(filter("name eq " + DISK_NAME));
List<Disk> disksAsList = disks.next();
assertEquals(disksAsList.size(), 1);
assertDiskEquals(disksAsList.get(0));
-
}
@Test(groups = "live", dependsOnMethods = "testListDisk")
public void testDeleteDisk() {
-
- assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().delete(DISK_NAME), TIME_WAIT);
}
private void assertDiskEquals(Disk result) {
@@ -84,22 +79,19 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
public void testInsertSSDDisk() {
URI diskType = getDiskTypeUrl(userProject.get(), DEFAULT_ZONE_NAME, "pd-ssd");
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(diskType);
- assertZoneOperationDoneSuccessfully(
- api().createInZone(SSD_DISK_NAME, sizeGb, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().create(SSD_DISK_NAME, sizeGb, diskCreationOptions), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testInsertSSDDisk")
public void testGetSSDDisk() {
-
- Disk disk = api().getInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME);
+ Disk disk = api().get(SSD_DISK_NAME);
assertNotNull(disk);
assertSSDDiskEquals(disk);
}
@Test(groups = "live", dependsOnMethods = "testGetSSDDisk")
public void testDeleteSSDDisk() {
-
- assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(api().delete(SSD_DISK_NAME), TIME_WAIT);
}
private void assertSSDDiskEquals(Disk result) {
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
index b62a251..a6ae5ac 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
@@ -17,6 +17,7 @@
package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
@@ -43,18 +44,6 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.payload(staticPayloadFromResource("/disktype_list.json"))
.build();
- public static final HttpRequest LIST_CENTRAL1B_DISK_TYPES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint(BASE_URL + "/myproject/zones/us-central1-b/diskTypes")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_CENTRAL1B_DISK_TYPES_RESPONSE = HttpResponse.builder()
- .statusCode(200)
- .payload(staticPayloadFromResource("/disktype_list_central1b.json"))
- .build();
-
public void testGetDiskTypeResponseIs2xx() throws Exception {
HttpRequest get = HttpRequest
.builder()
@@ -67,9 +56,9 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
.payload(payloadFromResource("/disktype.json")).build();
DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject", "us-central1-a");
- assertEquals(diskTypeApi.getInZone("us-central1-a", "pd-standard"),
+ assertEquals(diskTypeApi.get("pd-standard"),
new ParseDiskTypeTest().expected());
}
@@ -84,28 +73,30 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject");
+ TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject", "us-central1-a");
- assertNull(diskTypeApi.getInZone("us-central1-a", "pd-standard"));
+ assertNull(diskTypeApi.get("pd-standard"));
}
public void testListDiskTypeNoOptionsResponseIs2xx() throws Exception {
DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi
- ("myproject");
+ TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi
+ ("myproject", "us-central1-a");
- assertEquals(diskTypeApi.listInZone("us-central1-a").next().toString(),
- new ParseDiskTypeListTest().expected().toString());
+ assertEquals(diskTypeApi.list().next().toString(), new ParseDiskTypeListTest().expected().toString());
}
- public void testLisOperationWithPaginationOptionsResponseIs4xx() {
+ public void testListDiskTypesWithPaginationOptionsResponseIs4xx() {
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+ HttpRequest listRequestWithOptions = LIST_DISK_TYPES_REQUEST.toBuilder()
+ .endpoint(LIST_DISK_TYPES_REQUEST.getEndpoint() + "?maxResults=1").build();
+
DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, operationResponse).getDiskTypeApi("myproject");
+ TOKEN_RESPONSE, listRequestWithOptions, operationResponse).getDiskTypeApi("myproject", "us-central1-a");
- assertFalse(diskTypeApi.listInZone("us-central1-a").hasNext());
+ assertFalse(diskTypeApi.list(maxResults(1)).hasNext());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
index 03c7b36..5e252f8 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
@@ -25,7 +26,6 @@ import java.util.Iterator;
import org.jclouds.googlecomputeengine.domain.DiskType;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -33,14 +33,13 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
private DiskType diskType;
private DiskTypeApi api() {
- return api.getDiskTypeApi(userProject.get());
+ return api.getDiskTypeApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
public void testDiskType() {
- Iterator<ListPage<DiskType>> pageIterator = api().listInZone(DEFAULT_ZONE_NAME,
- new ListOptions.Builder().maxResults(1));
+ Iterator<ListPage<DiskType>> pageIterator = api().list(maxResults(1));
assertTrue(pageIterator.hasNext());
ListPage<DiskType> page = pageIterator.next();
@@ -52,7 +51,7 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testDiskType")
public void testGetDiskType() {
- DiskType diskType = api().getInZone(DEFAULT_ZONE_NAME, this.diskType.name());
+ DiskType diskType = api().get(this.diskType.name());
assertNotNull(diskType);
assertDiskTypeEquals(diskType, this.diskType);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
index f17c69e..6cc6ec7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
@@ -17,6 +17,7 @@
package org.jclouds.googlecomputeengine.features;
import static com.google.common.collect.Iterables.getOnlyElement;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Firewall;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@@ -110,8 +110,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetFirewall")
public void testListFirewall() {
- Iterator<ListPage<Firewall>> firewalls = api().list(new ListOptions.Builder()
- .filter("name eq " + FIREWALL_NAME));
+ Iterator<ListPage<Firewall>> firewalls = api().list(filter("name eq " + FIREWALL_NAME));
List<Firewall> firewallsAsList = firewalls.next();
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
index 380bfbb..9b361ee 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -25,7 +26,6 @@ import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.TargetPool;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -56,7 +56,7 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
}
private AddressApi addressApi(){
- return api.getAddressApi(userProject.get());
+ return api.getAddressApi(userProject.get(), DEFAULT_REGION_NAME);
}
@BeforeClass
@@ -68,15 +68,15 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
assertRegionOperationDoneSucessfully(targetPoolApi().create(TARGETPOOL_NAME_NEW, targetPoolCreationOptions), TIME_WAIT);
newTargetPool = targetPoolApi().get(TARGETPOOL_NAME_NEW);
- assertRegionOperationDoneSucessfully(addressApi().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
- address = addressApi().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME);
+ assertRegionOperationDoneSucessfully(addressApi().create(ADDRESS_NAME), TIME_WAIT);
+ address = addressApi().get(ADDRESS_NAME);
}
@AfterClass
public void tearDown() {
assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME), TIME_WAIT);
assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME_NEW), TIME_WAIT);
- assertRegionOperationDoneSucessfully(addressApi().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
+ assertRegionOperationDoneSucessfully(addressApi().delete(ADDRESS_NAME), TIME_WAIT);
}
@Test(groups = "live")
@@ -111,9 +111,7 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
@Test(groups = "live", dependsOnMethods = "testInsertForwardingRule")
public void testListForwardingRule() {
-
- ListPage<ForwardingRule> forwardingRule = api().list(new ListOptions.Builder()
- .filter("name eq " + FORWARDING_RULE_NAME));
+ ListPage<ForwardingRule> forwardingRule = api().list(filter("name eq " + FORWARDING_RULE_NAME)).next();
assertEquals(forwardingRule.size(), 1);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
index d66532a..8209741 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
@@ -18,12 +18,12 @@ package org.jclouds.googlecomputeengine.features;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationListTest;
import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest;
import org.jclouds.http.HttpRequest;
@@ -69,6 +69,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.builder()
.method("DELETE")
.endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
@@ -84,6 +85,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
.builder()
.method("DELETE")
.endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
+ .addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer " + TOKEN).build();
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
@@ -131,9 +133,9 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
- assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
+ assertEquals(globalOperationApi.listPage("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
"I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
- new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
+ filter("status eq done").maxResults(3)).toString(),
new ParseGlobalOperationListTest().expected().toString());
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
index 0d40738..5205589 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import java.util.Iterator;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Operation;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.SkipException;
import org.testng.annotations.Test;
@@ -38,9 +38,7 @@ public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
}
public void testListOperationsWithFiltersAndPagination() {
- Iterator<ListPage<Operation>> operations = api().list(new ListOptions.Builder()
- // .filter("operationType eq insert")
- .maxResults(1));
+ Iterator<ListPage<Operation>> operations = api().list(maxResults(1));
// make sure that in spite of having only one result per page we get at least two results
int count = 0;
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
index bebe700..9b70697 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull;
@@ -24,7 +25,6 @@ import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
@@ -69,8 +69,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
@Test(groups = "live", dependsOnMethods = "testInsertHttpHealthCheck")
public void testListHttpHealthCheck() {
- ListPage<HttpHealthCheck> httpHealthCheck = api().list(new ListOptions.Builder()
- .filter("name eq " + HTTP_HEALTH_CHECK_NAME));
+ ListPage<HttpHealthCheck> httpHealthCheck = api().list(filter("name eq " + HTTP_HEALTH_CHECK_NAME)).next();
assertEquals(Iterables.size(httpHealthCheck), 1);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
index 039adec..3383125 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
@@ -168,7 +168,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject");
- assertEquals(imageApi.createImageFromPD("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"),
+ assertEquals(imageApi.createFromDisk("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"),
new ParseOperationTest().expected());
}
@@ -188,6 +188,6 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject");
- imageApi.createImageFromPD("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk");
+ imageApi.createFromDisk("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
index c9e34c9..2fc56a1 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Disk;
import org.jclouds.googlecomputeengine.domain.Image;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
import org.testng.annotations.Test;
public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@@ -49,13 +49,12 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
}
private DiskApi diskApi() {
- return api.getDiskApi(userProject.get());
+ return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME);
}
@Test(groups = "live")
public void testListImage() {
-
- Iterator<ListPage<Image>> images = api().list(new ListOptions.Builder().maxResults(1));
+ Iterator<ListPage<Image>> images = api().list(maxResults(1));
List<Image> imageAsList = images.next();
@@ -78,14 +77,14 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live")
public void testInsertDisk() {
- assertZoneOperationDoneSuccessfully(diskApi().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
- Disk disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
+ assertZoneOperationDoneSuccessfully(diskApi().create(DISK_NAME, sizeGb), TIME_WAIT);
+ Disk disk = diskApi().get(DISK_NAME);
diskURI = disk.selfLink();
}
@Test(groups = "live", dependsOnMethods = "testInsertDisk")
public void testCreateImageFromPD(){
- assertGlobalOperationDoneSucessfully(imageApi().createImageFromPD(IMAGE_NAME, diskURI.toString()), TIME_WAIT);
+ assertGlobalOperationDoneSucessfully(imageApi().createFromDisk(IMAGE_NAME, diskURI.toString()), TIME_WAIT);
}
@Test(groups = "live", dependsOnMethods = "testCreateImageFromPD")
@@ -97,7 +96,7 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
@Test(groups = "live", dependsOnMethods = "testGetCreatedImage")
public void testCleanup(){
assertGlobalOperationDoneSucessfully(imageApi().delete(IMAGE_NAME), TIME_WAIT);
- assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
+ assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT);
}
private void assertImageEquals(Image result) {
[3/4] standardize listPage across all GCE resources.
Posted by ad...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
index 2b4562a..2b1340c 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ImageApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -52,73 +52,66 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Images via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/images")
+@Consumes(APPLICATION_JSON)
public interface ImageApi {
- /**
- * Returns the specified image resource.
- *
- * @param imageName name of the image resource to return.
- * @return an Image resource
- */
+
+ /** Returns an image by name or null if not found. */
@Named("Images:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images/{image}")
+ @Path("/{image}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Image get(@PathParam("image") String imageName);
+ Image get(@PathParam("image") String image);
- /**
- * Deletes the specified image resource.
- *
- * @param imageName name of the image resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field. If the image did not exist the result is null.
- */
+ /** Deletes an image by name and returns the operation in progress, or null if not found. */
@Named("Images:delete")
@DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images/{image}")
+ @Path("/{image}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Operation delete(@PathParam("image") String imageName);
+ Operation delete(@PathParam("image") String image);
+
+ /**
+ * Creates an image resource in the specified project from the provided persistent disk.
+ *
+ * @param image the name of the created image
+ * @param sourceDisk fully qualified URL for the persistent disk to create the image from
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Images:insert")
+ @POST
+ @Produces(APPLICATION_JSON)
+ @OAuthScopes(COMPUTE_SCOPE)
+ @MapBinder(BindToJsonPayload.class)
+ Operation createFromDisk(@PayloadParam("name") String image, @PayloadParam("sourceDisk") String sourceDisk);
/**
* Retrieves the list of image resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
* @return a page of the list
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Images:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseImages.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Image> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+ ListPage<Image> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * A paged version of ImageApi#list()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Images:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseImages.class)
@Transform(ParseImages.ToIteratorOfListPage.class)
@@ -126,35 +119,13 @@ public interface ImageApi {
Iterator<ListPage<Image>> list();
/**
- * A paged version of ImageApi#list()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see ImageApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Images:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/images")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseImages.class)
@Transform(ParseImages.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
Iterator<ListPage<Image>> list(ListOptions options);
-
- /**
- * Creates an image resource in the specified project from the provided persistent disk.
- *
- * @param imageName the name of the created image
- * @param sourceDisk fully qualified URL for the persistent disk to create the image from
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
- @Named("Images:insert")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/images")
- @OAuthScopes(COMPUTE_SCOPE)
- @MapBinder(BindToJsonPayload.class)
- Operation createImageFromPD(@PayloadParam("name") String imageName, @PayloadParam("sourceDisk") String sourceDisk);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
index 09dc36d..33ed393 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/InstanceApi.java
@@ -60,10 +60,6 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Instances via their REST API.
- * @see InstanceApi
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
@Path("/instances")
@@ -82,7 +78,6 @@ public interface InstanceApi {
/**
* Creates a instance resource in the specified project using the data included in the request.
*
- *
* @param instance this name of the instance to be created
* @param template the instance template
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
@@ -112,18 +107,16 @@ public interface InstanceApi {
* @param token marks the beginning of the next list page
* @param listOptions listing options
* @return a page of the list
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("Instances:list")
@GET
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseInstances.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Instance> listPage(@Nullable String token, ListOptions listOptions);
+ ListPage<Instance> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see InstanceApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Instances:list")
@GET
@@ -134,7 +127,7 @@ public interface InstanceApi {
Iterator<ListPage<Instance>> list();
/**
- * @see InstanceApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Instances:list")
@GET
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
index f78d12d..b197ab2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/MachineTypeApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import java.util.Iterator;
@@ -26,7 +27,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -44,76 +44,55 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to MachineTypes via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/machineTypes")
+@Consumes(APPLICATION_JSON)
public interface MachineTypeApi {
- /**
- * Returns the specified machine type resource
- *
- * @param zone the name of the zone the machine type is in
- * @param machineTypeName name of the machine type resource to return.
- * @return If successful, this method returns a MachineType resource
- */
+ /** Returns an machine type by name or null if not found. */
@Named("MachineTypes:get")
@GET
- @Path("/zones/{zone}/machineTypes/{machineType}")
+ @Path("/{machineType}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
- MachineType getInZone(@PathParam("zone") String zone, @PathParam("machineType") String machineTypeName);
+ MachineType get(@PathParam("machineType") String machineType);
/**
* Retrieves the list of machine type resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
- * @param zone The name of the zone to list in.
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
* @return a page of the list
- * @see ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
*/
@Named("MachineTypes:list")
@GET
- @Path("/zones/{zone}/machineTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseMachineTypes.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<MachineType> listAtMarkerInZone(@PathParam("zone") String zone,
- @QueryParam("pageToken") @Nullable String marker,
- ListOptions listOptions);
+ ListPage<MachineType> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see MachineTypeApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("MachineTypes:list")
@GET
- @Path("/zones/{zone}/machineTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseMachineTypes.class)
@Transform(ParseMachineTypes.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<MachineType>> listInZone(@PathParam("zone") String zone);
+ Iterator<ListPage<MachineType>> list();
/**
- * A paged version of MachineTypeApi#listInZone(String)
- *
- * @param zone the zone to list in
- * @return an Iterator that is able to fetch additional pages when required
- * @see MachineTypeApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("MachineTypes:list")
@GET
- @Path("/zones/{zone}/machineTypes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseMachineTypes.class)
@Transform(ParseMachineTypes.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<MachineType>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
-
+ Iterator<ListPage<MachineType>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
index c998be5..7b80233 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/NetworkApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -52,23 +52,16 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to Networks via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/networks")
+@Consumes(APPLICATION_JSON)
public interface NetworkApi {
- /**
- * Returns the specified persistent network resource.
- *
- * @param networkName name of the persistent network resource to return.
- * @return a Network resource.
- */
+ /** Returns a network by name or null if not found. */
@Named("Networks:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks/{network}")
+ @Path("/{network}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Network get(@PathParam("network") String networkName);
@@ -83,9 +76,7 @@ public interface NetworkApi {
*/
@Named("Networks:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
+ @Produces(APPLICATION_JSON)
@OAuthScopes({COMPUTE_SCOPE})
@MapBinder(BindToJsonPayload.class)
Operation createInIPv4Range(@PayloadParam("name") String networkName,
@@ -102,56 +93,42 @@ public interface NetworkApi {
*/
@Named("Networks:insert")
@POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
+ @Produces(APPLICATION_JSON)
@OAuthScopes({COMPUTE_SCOPE})
@MapBinder(BindToJsonPayload.class)
Operation createInIPv4RangeWithGateway(@PayloadParam("name") String networkName,
@PayloadParam("IPv4Range") String IPv4Range,
@PayloadParam("gatewayIPv4") String gatewayIPv4);
- /**
- * Deletes the specified persistent network resource.
- *
- * @param networkName name of the persistent network resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes a network by name and returns the operation in progress, or null if not found. */
@Named("Networks:delete")
@DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks/{network}")
+ @Path("/{network}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Operation delete(@PathParam("network") String networkName);
/**
- * Retrieves the list of persistent network resources contained within the specified project.
+ * Retrieves the list of network resources available to the specified project.
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
* been set.
*
- * @param marker marks the beginning of the next list page
- * @param options listing options
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
* @return a page of the list
- * @see ListOptions
*/
@Named("Networks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Network> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions options);
+ ListPage<Network> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see NetworkApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Networks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
@Transform(ParseNetworks.ToIteratorOfListPage.class)
@@ -159,15 +136,10 @@ public interface NetworkApi {
Iterator<ListPage<Network>> list();
/**
- * A paged version of NetworkApi#list()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see NetworkApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Networks:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/networks")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseNetworks.class)
@Transform(ParseNetworks.ToIteratorOfListPage.class)
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
index 573aaa5..2a9c1a1 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ProjectApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -28,7 +29,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.NullOn400or404;
import org.jclouds.googlecomputeengine.binders.MetadataBinder;
@@ -42,25 +42,18 @@ import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.SkipEncoding;
-/**
- * Provides access to Projects via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/projects")
+@Consumes(APPLICATION_JSON)
public interface ProjectApi {
- /**
- * Returns the specified project resource.
- *
- * @param projectName name of the project to return
- * @return if successful, this method returns a Project resource
- */
+ /** Returns a project by name or null if not found. */
@Named("Projects:get")
@GET
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOn400or404.class)
- @Path("/projects/{project}")
+ @Path("/{project}")
Project get(@PathParam("project") String projectName);
/**
@@ -83,10 +76,9 @@ public interface ProjectApi {
*/
@Named("Projects:setCommonInstanceMetadata")
@POST
- @Path("/projects/{project}/setCommonInstanceMetadata")
+ @Path("/{project}/setCommonInstanceMetadata")
@OAuthScopes(COMPUTE_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
+ @Produces(APPLICATION_JSON)
@MapBinder(MetadataBinder.class)
Operation setCommonInstanceMetadata(@PathParam("project") String projectName,
@PayloadParam("items") Map<String, String> metadata,
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
index 6480a14..6e5da47 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import java.util.Iterator;
@@ -25,7 +26,7 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -34,6 +35,7 @@ import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Region;
import org.jclouds.googlecomputeengine.functions.internal.ParseRegions;
import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.rest.annotations.Fallback;
@@ -42,49 +44,41 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Regions via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/regions")
+@Consumes(APPLICATION_JSON)
public interface RegionApi {
- /**
- * Returns the specified region resource
- *
- * @param regionName name of the region resource to return.
- * @return If successful, this method returns a Region resource
- */
+ /** Returns a region by name or null if not found. */
@Named("Regions:get")
@GET
- @Path("/regions/{region}")
+ @Path("/{region}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
- Region get(@PathParam("region") String regionName);
+ Region get(@PathParam("region") String region);
/**
- * Retrieves the listFirstPage of region resources available to the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Retrieves the list of region resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
+ * @return a page of the list
*/
@Named("Regions:list")
@GET
- @Path("/regions")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRegions.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Region> listAtMarker(String marker, ListOptions listOptions);
+ ListPage<Region> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see RegionApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Regions:list")
@GET
- @Path("/regions")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRegions.class)
@Transform(ParseRegions.ToIteratorOfListPage.class)
@@ -92,17 +86,13 @@ public interface RegionApi {
Iterator<ListPage<Region>> list();
/**
- * A paged version of RegionApi#listFirstPage()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see RegionApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Regions:list")
@GET
- @Path("/regions")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRegions.class)
@Transform(ParseRegions.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Region>> list(ListOptions listOptions);
+ Iterator<ListPage<Region>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
index 5a2f662..4bc0eac 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RegionOperationApi.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -28,7 +30,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -46,91 +47,64 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Operations via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/operations")
+@Consumes(APPLICATION_JSON)
public interface RegionOperationApi {
- /**
- * Retrieves the specified operation resource.
- *
- * @param region the region the operation is in
- * @param operationName name of the operation resource to return.
- * @return If successful, this method returns an Operation resource
- */
+ /** Returns an operation by name or null if not found. */
@Named("RegionOperations:get")
@GET
- @Path("/regions/{region}/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
- Operation getInRegion(@PathParam("region") String region, @PathParam("operation") String operationName);
+ @Nullable
+ Operation get(@PathParam("operation") String operation);
- /**
- * Deletes the specified operation resource.
- *
- * @param region the region the operation is in
- * @param operationName name of the operation resource to delete.
- */
+ /** Deletes an operation by name. */
@Named("RegionOperations:delete")
@DELETE
- @Path("/regions/{region}/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- void deleteInRegion(@PathParam("region") String region, @PathParam("operation") String operationName);
+ @Fallback(VoidOnNotFoundOr404.class)
+ void delete(@PathParam("operation") String operation);
/**
- * Retrieves the listFirstPage of operation resources contained within the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Retrieves the list of operation resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param region the region to list in
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the list, starting at marker
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
+ * @return a page of the list
*/
@Named("RegionOperations:list")
@GET
- @Path("/regions/{region}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseRegionOperations.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarkerInRegion(@PathParam("region") String region,
- @QueryParam("pageToken") @Nullable String marker,
- ListOptions listOptions);
+ ListPage<Operation> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see RegionOperationApi#listInRegion(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("RegionOperations:list")
@GET
- @Path("/regions/{region}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseRegionOperations.class)
@Transform(ParseRegionOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Operation>> listInRegion(@PathParam("region") String region);
+ Iterator<ListPage<Operation>> list();
/**
- * A paged version of RegionOperationApi#listFirstPage(String)
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- * @see RegionOperationApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("RegionOperations:list")
@GET
- @Path("/regions/{region}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseRegionOperations.class)
@Transform(ParseRegionOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Operation>> listInRegion(@PathParam("region") String region, ListOptions listOptions);
+ Iterator<ListPage<Operation>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
index a2916cc..0919e6d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/RouteApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -30,7 +31,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -53,52 +54,70 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Routes via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/routes")
+@Consumes(APPLICATION_JSON)
public interface RouteApi {
- /**
- * Returns the specified route resource
- *
- * @param routeName name of the region resource to return.
- * @return If successful, this method returns a Route resource
- */
+ /** Returns a route type by name or null if not found. */
@Named("Routes:get")
@GET
- @Path("/global/routes/{route}")
+ @Path("/{route}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
Route get(@PathParam("route") String routeName);
+ /** Deletes a route by name and returns the operation in progress, or null if not found. */
+ @Named("Routes:delete")
+ @DELETE
+ @Consumes(APPLICATION_JSON)
+ @Path("/{route}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation delete(@PathParam("route") String routeName);
+
/**
- * Retrieves the listFirstPage of route resources available to the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Creates a route resource in the specified project using the data included in the request.
*
- * @param marker marks the beginning of the next list page
+ * @param name the name of the route to be inserted.
+ * @param network the network to which to add the route
+ * @param routeOptions the options of the route to add
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Routes:insert")
+ @POST
+ @Consumes(APPLICATION_JSON)
+ @Produces(APPLICATION_JSON)
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(RouteBinder.class)
+ Operation createInNetwork(@PayloadParam("name") String name,
+ @PayloadParam("network") URI network,
+ @PayloadParam("options") RouteOptions routeOptions);
+
+ /**
+ * Retrieves the list of route resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the listFirstPage
- * @see org.jclouds.googlecomputeengine.options.ListOptions
- * @see org.jclouds.googlecomputeengine.domain.ListPage
+ * @return a page of the list
*/
@Named("Routes:list")
@GET
- @Path("/global/routes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRoutes.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Route> listAtMarker(String marker, ListOptions listOptions);
+ ListPage<Route> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see RouteApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Routes:list")
@GET
- @Path("/global/routes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRoutes.class)
@Transform(ParseRoutes.ToIteratorOfListPage.class)
@@ -106,55 +125,13 @@ public interface RouteApi {
Iterator<ListPage<Route>> list();
/**
- * A paged version of RegionApi#listFirstPage()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see RouteApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
- * @see org.jclouds.collect.PagedIterable
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Routes:list")
@GET
- @Path("/global/routes")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseRoutes.class)
@Transform(ParseRoutes.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Route>> list(ListOptions listOptions);
-
- /**
- * Deletes the specified route resource.
- *
- * @param routeName name of the route resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field. If the route did not exist the result is null.
- */
- @Named("Routes:delete")
- @DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/routes/{route}")
- @OAuthScopes(COMPUTE_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- @Nullable
- Operation delete(@PathParam("route") String routeName);
-
- /**
- * Creates a route resource in the specified project using the data included in the request.
- *
- * @param name the name of the route to be inserted.
- * @param network the network to which to add the route
- * @param routeOptions the options of the route to add
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
- @Named("Routes:insert")
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/global/routes")
- @OAuthScopes({COMPUTE_SCOPE})
- @MapBinder(RouteBinder.class)
- Operation createInNetwork(@PayloadParam("name") String name,
- @PayloadParam("network") URI network,
- @PayloadParam("options") RouteOptions routeOptions);
-
+ Iterator<ListPage<Route>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
index 840f1d4..f3741a7 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/SnapshotApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -28,7 +29,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -47,80 +47,62 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Snapshots via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/snapshots")
+@Consumes(APPLICATION_JSON)
public interface SnapshotApi {
- /**
- * Returns the specified snapshot resource.
- *
- * @param snapshotName name of the snapshot resource to return.
- * @return a Snapshot resource.
- */
+ /** Returns a snapshot by name or null if not found. */
@Named("Snapshots:get")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots/{snapshot}")
+ @Path("/{snapshot}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Snapshot get(@PathParam("snapshot") String snapshotName);
+ Snapshot get(@PathParam("snapshot") String snapshot);
- /**
- * Deletes the specified snapshot resource.
- *
- * @param snapshotName name of the snapshot resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes a snapshot by name and returns the operation in progress, or null if not found. */
@Named("Snapshots:delete")
@DELETE
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots/{snapshot}")
+ @Path("/{snapshot}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
- Operation delete(@PathParam("snapshot") String snapshotName);
+ Operation delete(@PathParam("snapshot") String snapshot);
/**
- * Retrieves the listPage of persistent disk resources contained within the specified project and zone.
- * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
- * not been set.
+ * Retrieves the list of snapshot resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
+ * @return a page of the list
*/
@Named("Snapshots:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseSnapshots.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Snapshot> listAtMarker(@QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+ ListPage<Snapshot> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * A paged version of SnapshotApi#listPage(String)
- *
- * @return an Iterator that is able to fetch additional pages when required
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Snapshots:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseSnapshots.class)
@Transform(ParseSnapshots.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
Iterator<ListPage<Snapshot>> list();
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
@Named("Snapshots:list")
@GET
- @Consumes(MediaType.APPLICATION_JSON)
- @Path("/global/snapshots")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseSnapshots.class)
@Transform(ParseSnapshots.ToIteratorOfListPage.class)
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
index a630fd7..7054563 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/TargetPoolApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -32,7 +33,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -58,23 +58,16 @@ import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
import org.jclouds.rest.binders.BindToJsonPayload;
-/**
- * Provides access to TargetPools via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticator.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/targetPools")
+@Consumes(APPLICATION_JSON)
public interface TargetPoolApi {
- /**
- * Returns the specified TargetPool resource.
- *
- * @param targetPool the name of the TargetPool resource to return.
- * @return a TargetPool resource.
- */
+ /** Returns a target pool by name or null if not found. */
@Named("TargetPools:get")
@GET
- @Path("/targetPools/{targetPool}")
+ @Path("/{targetPool}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
@@ -90,53 +83,22 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:insert")
@POST
- @Produces(MediaType.APPLICATION_JSON)
- @Path("/targetPools")
+ @Produces(APPLICATION_JSON)
+ @Path("")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(TargetPoolCreationBinder.class)
Operation create(@PayloadParam("name") String name, @PayloadParam("options") TargetPoolCreationOptions options);
- /**
- * Deletes the specified TargetPool resource.
- *
- * @param targetPool name of the persistent target pool resource to delete.
- * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
- * you, and look for the status field.
- */
+ /** Deletes a target pool by name and returns the operation in progress, or null if not found. */
@Named("TargetPools:delete")
@DELETE
- @Path("/targetPools/{targetPool}")
+ @Path("/{targetPool}")
@OAuthScopes(COMPUTE_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
@Nullable
Operation delete(@PathParam("targetPool") String targetPool);
/**
- * @return an Iterator that is able to fetch additional pages when required
- * @see org.jclouds.collect.PagedIterable
- */
- @Named("TargetPools:list")
- @GET
- @Path("/targetPools")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseTargetPools.class)
- @Transform(ParseTargetPools.ToIteratorOfListPage.class)
- @Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<TargetPool>> list();
-
- /**
- * @param options @see org.jclouds.googlecomputeengine.options.ListOptions
- * @return ListPage
- */
- @Named("TargetPools:list")
- @GET
- @Path("/targetPools")
- @OAuthScopes(COMPUTE_READONLY_SCOPE)
- @ResponseParser(ParseTargetPools.class)
- @Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<TargetPool> list(ListOptions options);
-
- /**
* Adds instance to the targetPool.
*
* @param targetPool the name of the target pool.
@@ -147,7 +109,7 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:addInstance")
@POST
- @Path("/targetPools/{targetPool}/addInstance")
+ @Path("/{targetPool}/addInstance")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(TargetPoolChangeInstancesBinder.class)
@Nullable
@@ -164,7 +126,7 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:removeInstance")
@POST
- @Path("/targetPools/{targetPool}/removeInstance")
+ @Path("/{targetPool}/removeInstance")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(TargetPoolChangeInstancesBinder.class)
@Nullable
@@ -181,7 +143,7 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:addHealthCheck")
@POST
- @Path("/targetPools/{targetPool}/addHealthCheck")
+ @Path("/{targetPool}/addHealthCheck")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(TargetPoolChangeHealthChecksBinder.class)
@Nullable
@@ -199,7 +161,7 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:removeHealthChek")
@POST
- @Path("/targetPools/{targetPool}/removeHealthCheck")
+ @Path("/{targetPool}/removeHealthCheck")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(TargetPoolChangeHealthChecksBinder.class)
@Nullable
@@ -214,14 +176,13 @@ public interface TargetPoolApi {
* WARNING: failoverRatio and BackupPool must either both be set or not set. This method
* is only for updating the backup pool on a Target Pool that already has a
* failoverRatio.
- * @see <a href = "https://cloud.google.com/compute/docs/reference/latest/targetPools/setBackup"/>
*
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
* you, and look for the status field.
*/
@Named("TargetPools:setBackup")
@POST
- @Path("/targetPools/{targetPool}/setBackup")
+ @Path("/{targetPool}/setBackup")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(BindToJsonPayload.class)
@Nullable
@@ -238,9 +199,47 @@ public interface TargetPoolApi {
*/
@Named("TargetPools:setBackup")
@POST
- @Path("/targetPools/{targetPool}/setBackup")
+ @Path("/{targetPool}/setBackup")
@OAuthScopes(COMPUTE_SCOPE)
@MapBinder(BindToJsonPayload.class)
@Nullable
Operation setBackup(@PathParam("targetPool") String targetPool, @QueryParam("failoverRatio") Float failoverRatio, @PayloadParam("target") URI target);
+
+ /**
+ * Retrieves the list of target pool resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
+ *
+ * @param token marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the list
+ */
+ @Named("TargetPools:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseTargetPools.class)
+ @Fallback(EmptyListPageOnNotFoundOr404.class)
+ ListPage<TargetPool> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("TargetPools:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseTargetPools.class)
+ @Transform(ParseTargetPools.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<TargetPool>> list();
+
+ /**
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("TargetPools:list")
+ @GET
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseTargetPools.class)
+ @Transform(ParseTargetPools.ToIteratorOfListPage.class)
+ @Fallback(EmptyIteratorOnNotFoundOr404.class)
+ Iterator<ListPage<TargetPool>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
index b043900..61716e3 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneApi.java
@@ -16,6 +16,7 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import java.util.Iterator;
@@ -25,7 +26,7 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
+import javax.ws.rs.QueryParam;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -34,6 +35,7 @@ import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.domain.Zone;
import org.jclouds.googlecomputeengine.functions.internal.ParseZones;
import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
import org.jclouds.oauth.v2.config.OAuthScopes;
import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
import org.jclouds.rest.annotations.Fallback;
@@ -42,49 +44,41 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Zones via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
-@Consumes(MediaType.APPLICATION_JSON)
+@Path("/zones")
+@Consumes(APPLICATION_JSON)
public interface ZoneApi {
- /**
- * Returns the specified zone resource
- *
- * @param zoneName name of the zone resource to return.
- * @return If successful, this method returns a Zone resource
- */
+ /** Returns a zone by name or null if not found. */
@Named("Zones:get")
@GET
- @Path("/zones/{zone}")
+ @Path("/{zone}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@Fallback(NullOnNotFoundOr404.class)
- Zone get(@PathParam("zone") String zoneName);
+ Zone get(@PathParam("zone") String zone);
/**
- * Retrieves the listFirstPage of zone resources available to the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Retrieves the list of zone resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
+ * @return a page of the list
*/
@Named("Zones:list")
@GET
- @Path("/zones")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseZones.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Zone> listAtMarker(String marker, ListOptions listOptions);
+ ListPage<Zone> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see ZoneApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Zones:list")
@GET
- @Path("/zones")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseZones.class)
@Transform(ParseZones.ToIteratorOfListPage.class)
@@ -92,17 +86,13 @@ public interface ZoneApi {
Iterator<ListPage<Zone>> list();
/**
- * A paged version of ZoneApi#listFirstPage()
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see ZoneApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("Zones:list")
@GET
- @Path("/zones")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
@ResponseParser(ParseZones.class)
@Transform(ParseZones.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Zone>> list(ListOptions listOptions);
+ Iterator<ListPage<Zone>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
index d486ea2..e89a10b 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/ZoneOperationApi.java
@@ -16,6 +16,8 @@
*/
package org.jclouds.googlecomputeengine.features;
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+import static org.jclouds.Fallbacks.VoidOnNotFoundOr404;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
@@ -28,7 +30,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.googlecomputeengine.GoogleComputeEngineFallbacks.EmptyIteratorOnNotFoundOr404;
@@ -46,88 +47,64 @@ import org.jclouds.rest.annotations.ResponseParser;
import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.annotations.Transform;
-/**
- * Provides access to Operations via their REST API.
- */
@SkipEncoding({'/', '='})
@RequestFilters(OAuthAuthenticationFilter.class)
+@Path("/operations")
+@Consumes(APPLICATION_JSON)
public interface ZoneOperationApi {
- /**
- * Retrieves the specified operation resource.
- *
- * @param zone the zone the operation is in
- * @param operationName name of the operation resource to return.
- * @return If successful, this method returns an Operation resource
- */
+ /** Returns an operation by name or null if not found. */
@Named("ZoneOperations:get")
@GET
- @Path("/zones/{zone}/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@Fallback(NullOnNotFoundOr404.class)
- Operation getInZone(@PathParam("zone") String zone, @PathParam("operation") String operationName);
+ @Nullable
+ Operation get(@PathParam("operation") String operation);
- /**
- * Deletes the specified operation resource.
- *
- * @param zone the zone the operation is in
- * @param operationName name of the operation resource to delete.
- */
+ /** Deletes an operation by name. */
@Named("ZoneOperations:delete")
@DELETE
- @Path("/zones/{zone}/operations/{operation}")
+ @Path("/{operation}")
@OAuthScopes(COMPUTE_SCOPE)
- @Fallback(NullOnNotFoundOr404.class)
- void deleteInZone(@PathParam("zone") String zone, @PathParam("operation") String operationName);
+ @Fallback(VoidOnNotFoundOr404.class)
+ void delete(@PathParam("operation") String operation);
/**
- * Retrieves the listFirstPage of operation resources contained within the specified project.
- * By default the listFirstPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults()
- * has not been set.
+ * Retrieves the list of operation resources available to the specified project.
+ * By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
+ * been set.
*
- * @param zone the zone to list in
- * @param marker marks the beginning of the next list page
+ * @param token marks the beginning of the next list page
* @param listOptions listing options
- * @return a page of the list, starting at marker
+ * @return a page of the list
*/
@Named("ZoneOperations:list")
@GET
- @Path("/zones/{zone}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseZoneOperations.class)
@Fallback(EmptyListPageOnNotFoundOr404.class)
- ListPage<Operation> listAtMarkerInZone(@PathParam("zone") String zone,
- @QueryParam("pageToken") @Nullable String marker,
- ListOptions listOptions);
+ ListPage<Operation> listPage(@Nullable @QueryParam("pageToken") String token, ListOptions listOptions);
/**
- * @see ZoneOperationApi#listInZone(String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("ZoneOperations:list")
@GET
- @Path("/zones/{zone}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseZoneOperations.class)
@Transform(ParseZoneOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Operation>> listInZone(@PathParam("zone") String zone);
+ Iterator<ListPage<Operation>> list();
/**
- * A paged version of ZoneOperationApi#listFirstPageInZone(String)
- *
- * @return an Iterator that is able to fetch additional pages when required
- * @see ZoneOperationApi#listAtMarkerInZone(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ * @see #list(org.jclouds.googlecomputeengine.options.ListOptions)
*/
@Named("ZoneOperations:list")
@GET
- @Path("/zones/{zone}/operations")
@OAuthScopes(COMPUTE_READONLY_SCOPE)
- @Consumes(MediaType.APPLICATION_JSON)
@ResponseParser(ParseZoneOperations.class)
@Transform(ParseZoneOperations.ToIteratorOfListPage.class)
@Fallback(EmptyIteratorOnNotFoundOr404.class)
- Iterator<ListPage<Operation>> listInZone(@PathParam("zone") String zone, ListOptions listOptions);
+ Iterator<ListPage<Operation>> list(ListOptions options);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
index 05cc6ee..66b9d75 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseToIteratorOfListPage.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.collect.Iterables.tryFind;
import java.util.Iterator;
+import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -33,7 +34,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.Iterators;
@Beta
-public abstract class BaseToIteratorOfListPage<T, I extends BaseToIteratorOfListPage<T, I>>
+abstract class BaseToIteratorOfListPage<T, I extends BaseToIteratorOfListPage<T, I>>
implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
private GeneratedHttpRequest request;
@@ -44,16 +45,15 @@ public abstract class BaseToIteratorOfListPage<T, I extends BaseToIteratorOfList
return Iterators.singletonIterator(input);
}
- Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+ List<Object> callerArgs = request.getCaller().get().getArgs();
- Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
+ assert callerArgs.size() == 1 : String.format("programming error, method %s should have 1 arg: project",
+ request.getCaller().get().getInvokable());
- assert project.isPresent() :
- String.format("programming error, method %s should have a string param for the " + "project",
- request.getCaller().get().getInvokable());
+ Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
return new AdvancingIterator<T>(input,
- fetchNextPage(project.get().toString(), (ListOptions) listOptions.orNull()));
+ fetchNextPage((String) callerArgs.get(0), (ListOptions) listOptions.orNull()));
}
protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName, ListOptions listOptions);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
index e522dc0..eab19e6 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithRegionToIteratorOfListPage.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.collect.Iterables.tryFind;
import java.util.Iterator;
+import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -33,7 +34,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.Iterators;
@Beta
-public abstract class BaseWithRegionToIteratorOfListPage<T, I extends BaseWithRegionToIteratorOfListPage<T, I>>
+abstract class BaseWithRegionToIteratorOfListPage<T, I extends BaseWithRegionToIteratorOfListPage<T, I>>
implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
private GeneratedHttpRequest request;
@@ -42,20 +43,15 @@ public abstract class BaseWithRegionToIteratorOfListPage<T, I extends BaseWithRe
if (input.nextPageToken() == null)
return Iterators.singletonIterator(input);
- Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+ List<Object> callerArgs = request.getCaller().get().getArgs();
- Optional<Object> region = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+ assert callerArgs.size() == 2 : String.format("programming error, method %s should have 2 args: project, region",
+ request.getCaller().get().getInvokable());
Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
- assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "project", request.getCaller().get().getInvokable());
-
- assert region.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "region", request.getCaller().get().getInvokable());
-
return new AdvancingIterator<T>(input,
- fetchNextPage(project.get().toString(), region.get().toString(), (ListOptions) listOptions.orNull()));
+ fetchNextPage((String) callerArgs.get(0), (String) callerArgs.get(1), (ListOptions) listOptions.orNull()));
}
protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName,
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
index 4d4b576..16bc345 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/BaseWithZoneToIteratorOfListPage.java
@@ -20,6 +20,7 @@ import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.collect.Iterables.tryFind;
import java.util.Iterator;
+import java.util.List;
import org.jclouds.googlecomputeengine.domain.ListPage;
import org.jclouds.googlecomputeengine.options.ListOptions;
@@ -33,7 +34,7 @@ import com.google.common.base.Optional;
import com.google.common.collect.Iterators;
@Beta
-public abstract class BaseWithZoneToIteratorOfListPage<T, I extends BaseWithZoneToIteratorOfListPage<T, I>>
+abstract class BaseWithZoneToIteratorOfListPage<T, I extends BaseWithZoneToIteratorOfListPage<T, I>>
implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
private GeneratedHttpRequest request;
@@ -43,20 +44,15 @@ public abstract class BaseWithZoneToIteratorOfListPage<T, I extends BaseWithZone
return Iterators.singletonIterator(input);
}
- Optional<Object> project = tryFind(request.getCaller().get().getArgs(), instanceOf(String.class));
+ List<Object> callerArgs = request.getCaller().get().getArgs();
- Optional<Object> zone = tryFind(request.getInvocation().getArgs(), instanceOf(String.class));
+ assert callerArgs.size() == 2 : String.format("programming error, method %s should have 2 args: project, zone",
+ request.getCaller().get().getInvokable());
Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
- assert project.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "project", request.getCaller().get().getInvokable());
-
- assert zone.isPresent() : String.format("programming error, method %s should have a string param for the "
- + "zone", request.getCaller().get().getInvokable());
-
return new AdvancingIterator<T>(input,
- fetchNextPage(project.get().toString(), zone.get().toString(), (ListOptions) listOptions.orNull()));
+ fetchNextPage((String) callerArgs.get(0), (String) callerArgs.get(1), (ListOptions) listOptions.orNull()));
}
protected abstract Function<String, ListPage<T>> fetchNextPage(String projectName,
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
index 24245af..35dd2c1 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseAddresses.java
@@ -47,7 +47,7 @@ public final class ParseAddresses extends ParseJson<ListPage<Address>> {
final String regionName, final ListOptions options) {
return new Function<String, ListPage<Address>>() {
@Override public ListPage<Address> apply(String input) {
- return api.getAddressApi(projectName).listAtMarkerInRegion(regionName, input, options);
+ return api.getAddressApi(projectName, regionName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
index 060460d..e9aa54f 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDiskTypes.java
@@ -47,7 +47,7 @@ public final class ParseDiskTypes extends ParseJson<ListPage<DiskType>> {
final String zoneName, final ListOptions options) {
return new Function<String, ListPage<DiskType>>() {
@Override public ListPage<DiskType> apply(String input) {
- return api.getDiskTypeApi(projectName).listAtMarkerInZone(zoneName, input, options);
+ return api.getDiskTypeApi(projectName, zoneName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
index 02361e7..6a8173b 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseDisks.java
@@ -48,7 +48,7 @@ public final class ParseDisks extends ParseJson<ListPage<Disk>> {
return new Function<String, ListPage<Disk>>() {
@Override public ListPage<Disk> apply(String input) {
- return api.getDiskApi(projectName).listAtMarkerInZone(zoneName, input, options);
+ return api.getDiskApi(projectName, zoneName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
index 348d7a4..cfe8605 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseFirewalls.java
@@ -47,7 +47,7 @@ public final class ParseFirewalls extends ParseJson<ListPage<Firewall>> {
final ListOptions options) {
return new Function<String, ListPage<Firewall>>() {
@Override public ListPage<Firewall> apply(String input) {
- return api.getFirewallApi(projectName).listAtMarker(input, options);
+ return api.getFirewallApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
index e7e1826..e8fc15d 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseForwardingRules.java
@@ -49,7 +49,7 @@ public final class ParseForwardingRules extends ParseJson<ListPage<ForwardingRul
final ListOptions options) {
return new Function<String, ListPage<ForwardingRule>>() {
@Override public ListPage<ForwardingRule> apply(String input) {
- return api.getForwardingRuleApi(projectName, regionName).list(options);
+ return api.getForwardingRuleApi(projectName, regionName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
index 99935e4..f45744f 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseGlobalOperations.java
@@ -48,7 +48,7 @@ public final class ParseGlobalOperations extends ParseJson<ListPage<Operation>>
final ListOptions options) {
return new Function<String, ListPage<Operation>>() {
@Override public ListPage<Operation> apply(String input) {
- return api.getGlobalOperationApi(projectName).listAtMarker(input, options);
+ return api.getGlobalOperationApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
index aba3d8d..da034e2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseHttpHealthChecks.java
@@ -50,7 +50,7 @@ public final class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCh
return new Function<String, ListPage<HttpHealthCheck>>() {
@Override public ListPage<HttpHealthCheck> apply(String input) {
- return api.getHttpHealthCheckApi(projectName).list(options);
+ return api.getHttpHealthCheckApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
index ada754b..dfdabc2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseImages.java
@@ -47,7 +47,7 @@ public final class ParseImages extends ParseJson<ListPage<Image>> {
final ListOptions options) {
return new Function<String, ListPage<Image>>() {
@Override public ListPage<Image> apply(String input) {
- return api.getImageApi(projectName).listAtMarker(input, options);
+ return api.getImageApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
index 0e48546..284f7cc 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseMachineTypes.java
@@ -35,8 +35,7 @@ public final class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
});
}
- public static class ToIteratorOfListPage
- extends BaseWithZoneToIteratorOfListPage<MachineType, ToIteratorOfListPage> {
+ public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<MachineType, ToIteratorOfListPage> {
private final GoogleComputeEngineApi api;
@@ -49,7 +48,7 @@ public final class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
return new Function<String, ListPage<MachineType>>() {
@Override public ListPage<MachineType> apply(String input) {
- return api.getMachineTypeApi(projectName).listAtMarkerInZone(zoneName, input, options);
+ return api.getMachineTypeApi(projectName, zoneName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
index 4d0a716..ad0837c 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseNetworks.java
@@ -47,7 +47,7 @@ public final class ParseNetworks extends ParseJson<ListPage<Network>> {
final ListOptions options) {
return new Function<String, ListPage<Network>>() {
@Override public ListPage<Network> apply(String input) {
- return api.getNetworkApi(projectName).listAtMarker(input, options);
+ return api.getNetworkApi(projectName).listPage(input, options);
}
};
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
index 95a39d8..8b19bd4 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegionOperations.java
@@ -48,7 +48,7 @@ public final class ParseRegionOperations extends ParseJson<ListPage<Operation>>
final String regionName, final ListOptions options) {
return new Function<String, ListPage<Operation>>() {
@Override public ListPage<Operation> apply(String input) {
- return api.getRegionOperationApi(projectName).listAtMarkerInRegion(regionName, input, options);
+ return api.getRegionOperationApi(projectName, regionName).listPage(input, options);
}
};
}