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/10 18:19:39 UTC

[3/6] jclouds-labs-google git commit: * Removed the need for users to manually specify the current project name everywhere. * Documented why we implicitly lookup project name using project id; corrected README, pom, ApiMetadata and added tests. * I

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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
deleted file mode 100644
index 9137642..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java
+++ /dev/null
@@ -1,77 +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.functions.internal;
-
-import static com.google.common.base.Predicates.instanceOf;
-import static com.google.common.collect.Iterables.tryFind;
-
-import java.util.Iterator;
-
-import javax.inject.Inject;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.json.Json;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.collect.Iterators;
-import com.google.inject.TypeLiteral;
-
-public final class ParseZoneOperations extends ParseJson<ListPage<Operation>> {
-
-   @Inject ParseZoneOperations(Json json) {
-      super(json, new TypeLiteral<ListPage<Operation>>() {
-      });
-   }
-
-   public static class ToIteratorOfListPage extends BaseWithZoneToIteratorOfListPage<Operation, ToIteratorOfListPage> {
-
-      private final GoogleComputeEngineApi api;
-
-      @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
-         this.api = api;
-      }
-
-      @Override public Iterator<ListPage<Operation>> apply(ListPage<Operation> input) {
-         if (input.nextPageToken() == null) {
-            return Iterators.singletonIterator(input);
-         }
-
-         String project = (String) request.getCaller().get().getArgs().get(0);
-         String zone = (String) request.getInvocation().getArgs().get(0);
-
-         Optional<Object> listOptions = tryFind(request.getInvocation().getArgs(), instanceOf(ListOptions.class));
-
-         return new AdvancingIterator<Operation>(input,
-               fetchNextPage(project, zone, (ListOptions) listOptions.orNull()));
-      }
-
-      @Override protected Function<String, ListPage<Operation>> fetchNextPage(final String projectName,
-            final String zoneName, final ListOptions options) {
-         return new Function<String, ListPage<Operation>>() {
-
-            @Override public ListPage<Operation> apply(String input) {
-               return api.getOperationApi(projectName).listPageInZone(zoneName, input, options);
-            }
-         };
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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
deleted file mode 100644
index fee1fdc..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java
+++ /dev/null
@@ -1,56 +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.functions.internal;
-
-import javax.inject.Inject;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.ListPage;
-import org.jclouds.googlecomputeengine.domain.Zone;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.http.functions.ParseJson;
-import org.jclouds.json.Json;
-
-import com.google.common.base.Function;
-import com.google.inject.TypeLiteral;
-
-public final class ParseZones extends ParseJson<ListPage<Zone>> {
-
-   @Inject ParseZones(Json json) {
-      super(json, new TypeLiteral<ListPage<Zone>>() {
-      });
-   }
-
-   public static final class ToIteratorOfListPage extends BaseToIteratorOfListPage<Zone, ToIteratorOfListPage> {
-
-      private final GoogleComputeEngineApi api;
-
-      @Inject ToIteratorOfListPage(GoogleComputeEngineApi api) {
-         this.api = api;
-      }
-
-      @Override
-      protected Function<String, ListPage<Zone>> fetchNextPage(final String projectName,
-            final ListOptions options) {
-         return new Function<String, ListPage<Zone>>() {
-            @Override public ListPage<Zone> apply(String input) {
-               return api.getZoneApi(projectName).listPage(input, options);
-            }
-         };
-      }
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/AdvancingIterator.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/AdvancingIterator.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/AdvancingIterator.java
new file mode 100644
index 0000000..ec62cc6
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/AdvancingIterator.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+
+import com.google.common.base.Function;
+import com.google.common.collect.AbstractIterator;
+
+final class AdvancingIterator<T> extends AbstractIterator<ListPage<T>> {
+
+   private final Function<String, ListPage<T>> tokenToNext;
+   private ListPage<T> current;
+   private boolean unread = true;
+
+   AdvancingIterator(ListPage<T> initial, Function<String, ListPage<T>> tokenToNext) {
+      this.current = initial;
+      this.tokenToNext = tokenToNext;
+   }
+
+   @Override protected ListPage<T> computeNext() {
+      if (unread) {
+         try {
+            return current;
+         } finally {
+            unread = false;
+         }
+      } else if (current.nextPageToken() != null) {
+         return current = tokenToNext.apply(current.nextPageToken());
+      } else {
+         return endOfData();
+      }
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseArg0ToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseArg0ToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseArg0ToIteratorOfListPage.java
new file mode 100644
index 0000000..051a2fc
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseArg0ToIteratorOfListPage.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import static org.jclouds.googlecomputeengine.internal.ListPages.listOptions;
+import static org.jclouds.googlecomputeengine.internal.ListPages.singletonOrEmptyIterator;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+
+@Beta
+public abstract class BaseArg0ToIteratorOfListPage<T, I extends BaseArg0ToIteratorOfListPage<T, I>>
+      implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+   GeneratedHttpRequest request;
+
+   @Override public Iterator<ListPage<T>> apply(ListPage<T> input) {
+      if (input.nextPageToken() == null) {
+         return singletonOrEmptyIterator(input);
+      }
+
+      String arg0 = (String) request.getInvocation().getArgs().get(0);
+      ListOptions options = listOptions(request.getInvocation().getArgs());
+
+      return new AdvancingIterator<T>(input, fetchNextPage(arg0, options));
+   }
+
+   /**
+    * This is used when you need to close over the first argument of this api.
+    *
+    * <p/> For example, {@code arg0} will become "myzone", which you can use to ensure the next page goes to the
+    * same zone: <pre>{@code api.operations().listInZone("myzone")}</pre>
+    */
+   protected abstract Function<String, ListPage<T>> fetchNextPage(String arg0, ListOptions listOptions);
+
+   @SuppressWarnings("unchecked")
+   @Override public I setContext(HttpRequest request) {
+      this.request = GeneratedHttpRequest.class.cast(request);
+      return (I) this;
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseCallerArg0ToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseCallerArg0ToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseCallerArg0ToIteratorOfListPage.java
new file mode 100644
index 0000000..083f59b
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseCallerArg0ToIteratorOfListPage.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import static org.jclouds.googlecomputeengine.internal.ListPages.listOptions;
+import static org.jclouds.googlecomputeengine.internal.ListPages.singletonOrEmptyIterator;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+
+@Beta
+public abstract class BaseCallerArg0ToIteratorOfListPage<T, I extends BaseCallerArg0ToIteratorOfListPage<T, I>>
+      implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+   private GeneratedHttpRequest request;
+
+   @Override public Iterator<ListPage<T>> apply(ListPage<T> input) {
+      if (input.nextPageToken() == null) {
+         return singletonOrEmptyIterator(input);
+      }
+
+      String arg0 = (String) request.getCaller().get().getArgs().get(0);
+      ListOptions options = listOptions(request.getInvocation().getArgs());
+
+      return new AdvancingIterator<T>(input, fetchNextPage(arg0, options));
+   }
+
+   /**
+    * This is used when you need to close over the argument that created the api.
+    *
+    * <p/> For example, {@code callerArg0} will become "myzone", which you can use to ensure the next page goes to the
+    * same zone: <pre>{@code api.instancesInZone("myzone").list()}</pre>
+    */
+   protected abstract Function<String, ListPage<T>> fetchNextPage(String callerArg0, ListOptions listOptions);
+
+   @SuppressWarnings("unchecked")
+   @Override public I setContext(HttpRequest request) {
+      this.request = GeneratedHttpRequest.class.cast(request);
+      return (I) this;
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseToIteratorOfListPage.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseToIteratorOfListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseToIteratorOfListPage.java
new file mode 100644
index 0000000..d9209f0
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/BaseToIteratorOfListPage.java
@@ -0,0 +1,54 @@
+/*
+ * 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.internal;
+
+import static org.jclouds.googlecomputeengine.internal.ListPages.listOptions;
+import static org.jclouds.googlecomputeengine.internal.ListPages.singletonOrEmptyIterator;
+
+import java.util.Iterator;
+
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.InvocationContext;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+
+@Beta
+public abstract class BaseToIteratorOfListPage<T, I extends BaseToIteratorOfListPage<T, I>>
+      implements Function<ListPage<T>, Iterator<ListPage<T>>>, InvocationContext<I> {
+
+   private GeneratedHttpRequest request;
+
+   @Override
+   public Iterator<ListPage<T>> apply(ListPage<T> input) {
+      if (input.nextPageToken() == null) {
+         return singletonOrEmptyIterator(input);
+      }
+      return new AdvancingIterator<T>(input, fetchNextPage(listOptions(request.getInvocation().getArgs())));
+   }
+
+   protected abstract Function<String, ListPage<T>> fetchNextPage(ListOptions listOptions);
+
+   @SuppressWarnings("unchecked")
+   @Override public I setContext(HttpRequest request) {
+      this.request = GeneratedHttpRequest.class.cast(request);
+      return (I) this;
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
index 5ab2420..b42a1b2 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.java
@@ -16,9 +16,15 @@
  */
 package org.jclouds.googlecomputeengine.internal;
 
+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;
+import org.jclouds.javax.annotation.Nullable;
 
 import com.google.common.collect.AbstractIterator;
 import com.google.common.collect.Iterators;
@@ -37,6 +43,14 @@ public final class ListPages {
       };
    }
 
+   @Nullable static ListOptions listOptions(List<Object> args) {
+      return (ListOptions) tryFind(args, instanceOf(ListOptions.class)).orNull();
+   }
+
+   static <T> Iterator<ListPage<T>> singletonOrEmptyIterator(ListPage<T> input) {
+      return input.isEmpty() ? Iterators.<ListPage<T>>emptyIterator() : Iterators.singletonIterator(input);
+   }
+
    private ListPages() {
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/PATCH.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/PATCH.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/PATCH.java
new file mode 100644
index 0000000..4efeee2
--- /dev/null
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/PATCH.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.internal;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.ws.rs.HttpMethod;
+
+/**
+ * Indicates that the annotated method responds to HTTP PATCH requests
+ *
+ * @see javax.ws.rs.HttpMethod
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@HttpMethod("PATCH")
+public @interface PATCH {
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
index 8961bb5..0d48e13 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/GoogleComputeEngineAuthenticatedRestContextLiveTest.java
@@ -16,6 +16,10 @@
  */
 package org.jclouds.googlecomputeengine;
 
+import java.util.Properties;
+
+import org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes;
+import org.jclouds.googlecomputeengine.internal.TestProperties;
 import org.jclouds.oauth.v2.internal.BaseOAuthAuthenticatedApiLiveTest;
 import org.testng.annotations.Test;
 
@@ -28,6 +32,10 @@ public class GoogleComputeEngineAuthenticatedRestContextLiveTest extends BaseOAu
 
    @Override
    public String getScopes() {
-      return GoogleComputeEngineConstants.COMPUTE_SCOPE;
+      return GoogleComputeEngineScopes.COMPUTE_SCOPE;
+   }
+
+   @Override protected Properties setupProperties() {
+      return TestProperties.apply(super.setupProperties());
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 5a9f52e..b27944c 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
@@ -17,7 +17,6 @@
 package org.jclouds.googlecomputeengine.compute;
 
 import static com.google.common.collect.Iterables.contains;
-import static org.jclouds.oauth.v2.OAuthTestUtils.setCredential;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
@@ -27,19 +26,14 @@ import org.jclouds.compute.domain.Hardware;
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
 import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.config.UserProject;
 import org.jclouds.googlecomputeengine.domain.MachineType;
-import org.jclouds.oauth.v2.config.CredentialType;
-import org.jclouds.oauth.v2.config.OAuthProperties;
+import org.jclouds.googlecomputeengine.internal.TestProperties;
 import org.jclouds.sshj.config.SshjSshClientModule;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
-import com.google.inject.Key;
 import com.google.inject.Module;
-import com.google.inject.TypeLiteral;
 
 @Test(groups = "live", singleThreaded = true)
 public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTest {
@@ -50,22 +44,14 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
       provider = "google-compute-engine";
    }
 
-   @Override
-   protected Properties setupProperties() {
-      Properties props = super.setupProperties();
-      if (!System.getProperty(OAuthProperties.CREDENTIAL_TYPE, "")
-            .equalsIgnoreCase(CredentialType.BEARER_TOKEN_CREDENTIALS.toString())) {
-      setCredential(props, provider + ".credential");
-      }
-      return props;
+   @Override protected Properties setupProperties() {
+      return TestProperties.apply(super.setupProperties());
    }
 
    public void testListHardwareProfiles() throws Exception {
       GoogleComputeEngineApi api = client.getContext().unwrapApi(GoogleComputeEngineApi.class);
-      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(), DEFAULT_ZONE_NAME).list().next()) {
+      for (MachineType machine : api.machineTypesInZone(DEFAULT_ZONE_NAME).list().next()) {
          if (machine.deprecated() != null) {
             deprecatedMachineTypes.add(machine.id());
          }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceMockTest.java
index fc2e3db..f161724 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceMockTest.java
@@ -46,10 +46,9 @@ import com.squareup.okhttp.mockwebserver.MockResponse;
 public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineApiMockTest {
 
    public void templateMatch() throws Exception {
-      server.enqueue(jsonResponse("/project.json"));
       server.enqueue(singleRegionSingleZoneResponse());
       server.enqueue(jsonResponse("/image_list.json"));
-      server.enqueue(jsonResponse("/image_list_debian.json")); // per GCE_IMAGE_PROJECTS = "debian-cloud"
+      server.enqueue(jsonResponse("/image_list_debian.json")); // per IMAGE_PROJECTS = "debian-cloud"
       server.enqueue(jsonResponse("/aggregated_machinetype_list.json"));
 
       ComputeService computeService = computeService();
@@ -68,7 +67,6 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
       Template toMatch = computeService.templateBuilder().imageId(template.getImage().getId()).build();
       assertEquals(toMatch.getImage(), template.getImage());
 
-      assertSent(server, "GET", "/projects/party");
       assertSent(server, "GET", "/projects/party/regions");
       assertSent(server, "GET", "/projects/party/global/images");
       assertSent(server, "GET", "/projects/debian-cloud/global/images");
@@ -77,7 +75,6 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
 
    public void networksAndFirewallDeletedWhenAllGroupNodesAreTerminated() throws IOException, InterruptedException {
       server.enqueue(instanceWithNetworkAndStatus("test-delete-networks", "test-network", RUNNING));
-      server.enqueue(jsonResponse("/project.json"));
       server.enqueue(singleRegionSingleZoneResponse());
       server.enqueue(jsonResponse("/aggregated_machinetype_list.json"));
       server.enqueue(jsonResponse("/operation.json"));
@@ -95,7 +92,6 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
       computeService.destroyNode(url("/jclouds/zones/us-central1-a/instances/test-delete-networks"));
 
       assertSent(server, "GET", "/jclouds/zones/us-central1-a/instances/test-delete-networks");
-      assertSent(server, "GET", "/projects/party");
       assertSent(server, "GET", "/projects/party/regions");
       assertSent(server, "GET", "/projects/party/aggregated/machineTypes");
       assertSent(server, "DELETE", "/jclouds/zones/us-central1-a/instances/test-delete-networks");
@@ -111,7 +107,6 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
    }
 
    public void listAssignableLocations() throws Exception {
-      server.enqueue(jsonResponse("/project.json"));
       server.enqueue(singleRegionSingleZoneResponse());
 
       ComputeService computeService = computeService();
@@ -133,12 +128,10 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
       assertTrue(firstZone.getIso3166Codes().isEmpty());
       assertTrue(firstZone.getParent().getIso3166Codes().isEmpty());
 
-      assertSent(server, "GET", "/projects/party");
       assertSent(server, "GET", "/projects/party/regions");
    }
 
    public void listNodes() throws Exception {
-      server.enqueue(jsonResponse("/project.json"));
       server.enqueue(aggregatedListWithInstanceNetworkAndStatus("test-0", "test-network", RUNNING));
       server.enqueue(singleRegionSingleZoneResponse());
       server.enqueue(jsonResponse("/aggregated_machinetype_list.json"));
@@ -148,17 +141,15 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
       NodeMetadata node = (NodeMetadata) nodes.iterator().next();
       assertNull(node.getImageId()); // not pre-cached by createNodes
 
-      assertSent(server, "GET", "/projects/party");
       assertSent(server, "GET", "/projects/party/aggregated/instances");
       assertSent(server, "GET", "/projects/party/regions");
       assertSent(server, "GET", "/projects/party/aggregated/machineTypes");
    }
 
    public void createNodeWhenNetworkNorFirewallExistDoesNotExist() throws Exception {
-      server.enqueue(jsonResponse("/project.json"));
       server.enqueue(singleRegionSingleZoneResponse());
       server.enqueue(jsonResponse("/image_list.json"));
-      server.enqueue(jsonResponse("/image_list_debian.json")); // per GCE_IMAGE_PROJECTS = "debian-cloud"
+      server.enqueue(jsonResponse("/image_list_debian.json")); // per IMAGE_PROJECTS = "debian-cloud"
       server.enqueue(jsonResponse("/aggregated_machinetype_list.json"));
       server.enqueue(new MockResponse().setResponseCode(404)); // Network
       server.enqueue(new MockResponse().setResponseCode(404)); // Network again?
@@ -183,7 +174,6 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
       // prove our caching works.
       assertEquals(node.getImageId(), template.getImage().getId());
 
-      assertSent(server, "GET", "/projects/party");
       assertSent(server, "GET", "/projects/party/regions");
       assertSent(server, "GET", "/projects/party/global/images");
       assertSent(server, "GET", "/projects/debian-cloud/global/images");
@@ -279,10 +269,5 @@ public class GoogleComputeEngineServiceMockTest extends BaseGoogleComputeEngineA
             stringFromResource("/aggregated_instance_list.json").replace("test-0", instanceName)
                   .replace("default", networkName).replace("RUNNING", status.toString()));
    }
-
-   private MockResponse diskResponseForInstance(String instanceName) {
-      return new MockResponse().setBody(
-            stringFromResource("/disk_get.json").replace("testimage1", instanceName + "-" + "TODO"));
-   }
 }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
index 588ef51..a50de5a 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/extensions/GoogleComputeEngineSecurityGroupExtensionLiveTest.java
@@ -16,7 +16,10 @@
  */
 package org.jclouds.googlecomputeengine.compute.extensions;
 
+import java.util.Properties;
+
 import org.jclouds.compute.extensions.internal.BaseSecurityGroupExtensionLiveTest;
+import org.jclouds.googlecomputeengine.internal.TestProperties;
 import org.testng.annotations.Test;
 
 @Test(groups = "live", singleThreaded = true, testName = "GoogleComputeEngineSecurityGroupExtensionLiveTest")
@@ -25,4 +28,8 @@ public class GoogleComputeEngineSecurityGroupExtensionLiveTest extends BaseSecur
    public GoogleComputeEngineSecurityGroupExtensionLiveTest() {
       provider = "google-compute-engine";
    }
+
+   @Override protected Properties setupProperties() {
+      return TestProperties.apply(super.setupProperties());
+   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/CreateNetworkIfNeededTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/CreateNetworkIfNeededTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/CreateNetworkIfNeededTest.java
index 778dbd6..75e8bd7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/CreateNetworkIfNeededTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/CreateNetworkIfNeededTest.java
@@ -27,18 +27,14 @@ import java.net.URI;
 import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
 import org.jclouds.googlecomputeengine.compute.domain.NetworkAndAddressRange;
 import org.jclouds.googlecomputeengine.compute.predicates.AtomicOperationDone;
-import org.jclouds.googlecomputeengine.config.UserProject;
 import org.jclouds.googlecomputeengine.domain.Network;
 import org.jclouds.googlecomputeengine.domain.Operation;
 import org.jclouds.googlecomputeengine.features.NetworkApi;
 import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.Provides;
 
 @Test
 public class CreateNetworkIfNeededTest {
@@ -61,9 +57,7 @@ public class CreateNetworkIfNeededTest {
 
       Operation createOp = new ParseGlobalOperationTest().expected();
 
-      Supplier<String> userProject = Suppliers.ofInstance("party");
-
-      expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce();
+      expect(api.networks()).andReturn(nwApi).atLeastOnce();
 
       expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0")) .andReturn(createOp);
       expect(resources.operation(createOp.selfLink())).andReturn(createOp);
@@ -76,7 +70,7 @@ public class CreateNetworkIfNeededTest {
 
       AtomicOperationDone pred = atomicOperationDone(api, resources);
 
-      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred);
+      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, pred);
 
       assertEquals(creator.apply(input), network);
 
@@ -99,9 +93,7 @@ public class CreateNetworkIfNeededTest {
 
       Operation createOp = new ParseGlobalOperationTest().expected();
 
-      Supplier<String> userProject = Suppliers.ofInstance("party");
-
-      expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce();
+      expect(api.networks()).andReturn(nwApi).atLeastOnce();
 
       expect(nwApi.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4")).andReturn(createOp);
       expect(resources.operation(createOp.selfLink())).andReturn(createOp);
@@ -114,7 +106,7 @@ public class CreateNetworkIfNeededTest {
 
       AtomicOperationDone pred = atomicOperationDone(api, resources);
 
-      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred);
+      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, pred);
 
       assertEquals(creator.apply(input), network);
 
@@ -128,10 +120,6 @@ public class CreateNetworkIfNeededTest {
             bind(GoogleComputeEngineApi.class).toInstance(api);
             bind(Resources.class).toInstance(resources);
          }
-
-         @Provides @UserProject Supplier<String> project() {
-            return Suppliers.ofInstance("party");
-         }
       }).getInstance(AtomicOperationDone.class);
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FindNetworkOrCreateTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FindNetworkOrCreateTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FindNetworkOrCreateTest.java
index 5df13f0..dfe4036 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FindNetworkOrCreateTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/FindNetworkOrCreateTest.java
@@ -36,8 +36,6 @@ import org.testng.annotations.Test;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.LoadingCache;
 import com.google.inject.AbstractModule;
@@ -45,7 +43,6 @@ import com.google.inject.Guice;
 
 @Test
 public class FindNetworkOrCreateTest {
-   private static final Supplier<String> USER_PROJECT = Suppliers.ofInstance("party");
    private static final String BASE_URL = "https://www.googleapis.com/compute/v1/projects";
    private static final Network NETWORK = Network.create( //
          "abcd", // id
@@ -60,7 +57,7 @@ public class FindNetworkOrCreateTest {
       GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
       NetworkApi nwApi = createMock(NetworkApi.class);
 
-      expect(api.getNetworkApi(USER_PROJECT.get())).andReturn(nwApi).atLeastOnce();
+      expect(api.networks()).andReturn(nwApi).atLeastOnce();
 
       expect(nwApi.get("this-network")).andReturn(NETWORK);
 
@@ -70,9 +67,9 @@ public class FindNetworkOrCreateTest {
 
       Predicate<AtomicReference<Operation>> operationDone = Predicates.alwaysFalse(); // No op should be created!
 
-      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, USER_PROJECT, operationDone);
+      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, operationDone);
 
-      FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, USER_PROJECT);
+      FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator);
 
       LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
 
@@ -91,7 +88,7 @@ public class FindNetworkOrCreateTest {
 
       Operation createOp = new ParseGlobalOperationTest().expected();
 
-      expect(api.getNetworkApi(USER_PROJECT.get())).andReturn(nwApi).atLeastOnce();
+      expect(api.networks()).andReturn(nwApi).atLeastOnce();
 
       expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0")).andReturn(createOp);
       expect(resources.operation(createOp.selfLink())).andReturn(createOp);
@@ -106,9 +103,9 @@ public class FindNetworkOrCreateTest {
 
       AtomicOperationDone pred = atomicOperationDone(resources);
 
-      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, USER_PROJECT, pred);
+      CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, pred);
 
-      FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator, USER_PROJECT);
+      FindNetworkOrCreate loader = new FindNetworkOrCreate(api, creator);
 
       LoadingCache<NetworkAndAddressRange, Network> cache = CacheBuilder.newBuilder().build(loader);
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 4533a06..55bbf2d 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
@@ -38,8 +38,6 @@ import org.jclouds.net.domain.IpProtocol;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
 
@@ -47,16 +45,13 @@ public class NetworkToSecurityGroupTest {
 
    @Test
    public void testApply() {
-      Supplier<String> projectSupplier = Suppliers.ofInstance("party");
-
       FirewallToIpPermission fwToPerm = new FirewallToIpPermission();
 
       GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
       FirewallApi fwApi = createMock(FirewallApi.class);
 
       ListOptions options = filter("network eq .*/party-test");
-      expect(api.getFirewallApi(projectSupplier.get()))
-              .andReturn(fwApi);
+      expect(api.firewalls()).andReturn(fwApi);
       expect(fwApi.list(options)).andReturn(
             singletonIterator(ListPage.create(ImmutableList.of(FirewallToIpPermissionTest.fwForTest()), null)));
 
@@ -71,7 +66,7 @@ public class NetworkToSecurityGroupTest {
             "1.2.3.4" // gatewayIPv4
       );
 
-      NetworkToSecurityGroup netToSg = new NetworkToSecurityGroup(fwToPerm, api, projectSupplier);
+      NetworkToSecurityGroup netToSg = new NetworkToSecurityGroup(fwToPerm, api);
 
       SecurityGroup group = netToSg.apply(network);
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/config/UseApiToResolveProjectNameMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/config/UseApiToResolveProjectNameMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/config/UseApiToResolveProjectNameMockTest.java
new file mode 100644
index 0000000..512f70e
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/config/UseApiToResolveProjectNameMockTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecomputeengine.config;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+import java.net.URI;
+
+import org.jclouds.domain.Credentials;
+import org.jclouds.googlecomputeengine.GoogleComputeEngineApiMetadata;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "UseApiToResolveProjectSelfLinkMockTest", singleThreaded = true)
+public class UseApiToResolveProjectNameMockTest extends BaseGoogleComputeEngineApiMockTest {
+   private final String projectNumber = "761326798069";
+
+   public void validClientEmail() throws Exception {
+      server.enqueue(jsonResponse("/project.json"));
+
+      URI projectSelfLink = fn().apply(new Credentials(projectNumber + "@developer.gserviceaccount.com", credential));
+
+      assertEquals(projectSelfLink.toString(), url("/projects/party"));
+
+      assertSent(server, "GET", "/projects/" + projectNumber);
+   }
+
+   public void validClientEmail_extendedUid() throws Exception {
+      server.enqueue(jsonResponse("/project.json"));
+
+      URI projectSelfLink = fn().apply(
+            new Credentials(projectNumber + "-r5mljlln1rd4lrbhg75efgigp36m78j5@developer.gserviceaccount.com", credential));
+
+      assertEquals(projectSelfLink.toString(), url("/projects/party"));
+
+      assertSent(server, "GET", "/projects/" + projectNumber);
+   }
+
+   /**
+    * We do not support just supplying the projectNumber, as this causes confusion when using oauth. OAuth JWT requires
+    * the whole email for the ISS field. This is better than confusing users with instructions like "Use the email,
+    * except if using bearer token. Then, you don't need the entire email, just put in the numeric id part of it."
+    */
+   public void justProjectIdIsInvalid() throws Exception {
+      server.enqueue(jsonResponse("/project.json"));
+
+      try {
+         fn().apply(new Credentials(projectNumber, credential));
+         fail();
+      } catch (IllegalArgumentException e) {
+         assertEquals(e.getMessage(), String.format("Identity %s is malformed. Should be %s", projectNumber,
+               new GoogleComputeEngineApiMetadata().getIdentityName()));
+      }
+
+      assertEquals(server.getRequestCount(), 0);
+   }
+
+   GoogleComputeEngineHttpApiModule.UseApiToResolveProjectName fn() {
+      return builder().buildInjector().getInstance(GoogleComputeEngineHttpApiModule.UseApiToResolveProjectName.class);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 cec6fbc..c29bfb1 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
@@ -16,8 +16,8 @@
  */
 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.config.GoogleComputeEngineScopes.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes.COMPUTE_SCOPE;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.AssertJUnit.assertNull;
@@ -44,11 +44,11 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goog
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/address_get.json")).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, get, response).addressesInRegion("us-central1");
 
       assertEquals(api.get("test-ip1"), new ParseAddressTest().expected());
    }
@@ -61,10 +61,10 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goog
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+      HttpResponse response = HttpResponse.builder().statusCode(404).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, get, response).addressesInRegion("us-central1");
 
       assertNull(api.get("test-ip1"));
    }
@@ -84,7 +84,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goog
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, insert,
-              insertAddressResponse).getAddressApi("party", "us-central1");
+              insertAddressResponse).addressesInRegion("us-central1");
 
       assertEquals(api.create("test-ip1"), new ParseRegionOperationTest().expected());
    }
@@ -101,7 +101,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goog
               .payload(payloadFromResource("/region_operation.json")).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, delete, deleteResponse).addressesInRegion("us-central1");
 
       assertEquals(api.delete("test-ip1"), new ParseRegionOperationTest().expected());
    }
@@ -117,40 +117,34 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goog
       HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, delete, deleteResponse).addressesInRegion("us-central1");
 
       assertNull(api.delete("test-ip1"));
    }
 
-   public void testListAddresssResponseIs2xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
+   HttpRequest list = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint(BASE_URL + "/party/regions/us-central1/addresses")
+         .addHeader("Accept", "application/json")
+         .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+   public void list() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/address_list.json")).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, list, response).addressesInRegion("us-central1");
 
-      assertEquals(api.list().next().toString(), new ParseAddressListTest().expected().toString());
+      assertEquals(api.list().next(), new ParseAddressListTest().expected());
    }
 
-   public void testListAddresssResponseIs4xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+   public void listEmpty() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/list_empty.json")).build();
 
       AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getAddressApi("party", "us-central1");
+              TOKEN_RESPONSE, list, response).addressesInRegion("us-central1");
 
       assertFalse(api.list().hasNext());
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 d5f71a8..e5feef5 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
@@ -32,7 +32,7 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    private static final String ADDRESS_NAME = "address-api-live-test-address";
 
    private AddressApi api() {
-      return api.getAddressApi(userProject.get(), DEFAULT_REGION_NAME);
+      return api.addressesInRegion(DEFAULT_REGION_NAME);
    }
 
    @Test(groups = "live")

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
index eb148ca..9c34ad7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiLiveTest.java
@@ -32,7 +32,7 @@ import org.testng.annotations.Test;
 public class AggregatedListApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
 
    private AggregatedListApi api() {
-      return api.aggregatedList(userProject.get());
+      return api.aggregatedList();
    }
 
    public void machineTypes() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
index 297eafd..8a1be6b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AggregatedListApiMockTest.java
@@ -28,7 +28,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
    public void machineTypes() throws Exception {
       server.enqueue(jsonResponse("/aggregated_machinetype_list.json"));
 
-      AggregatedListApi aggregatedList = api().aggregatedList("party");
+      AggregatedListApi aggregatedList = api().aggregatedList();
 
       assertTrue(aggregatedList.machineTypes().hasNext());
 
@@ -38,7 +38,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
    public void machineTypesResponseIs4xx() throws Exception {
       server.enqueue(jsonResponse("/aggregated_instance_list_empty.json"));
 
-      AggregatedListApi aggregatedList = api().aggregatedList("party");
+      AggregatedListApi aggregatedList = api().aggregatedList();
 
       assertFalse(aggregatedList.machineTypes().hasNext());
 
@@ -48,7 +48,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
    public void instances() throws Exception {
       server.enqueue(jsonResponse("/aggregated_instance_list.json"));
 
-      AggregatedListApi aggregatedList = api().aggregatedList("party");
+      AggregatedListApi aggregatedList = api().aggregatedList();
 
       assertTrue(aggregatedList.instances().hasNext());
 
@@ -58,7 +58,7 @@ public class AggregatedListApiMockTest extends BaseGoogleComputeEngineApiMockTes
    public void instancesResponseIs4xx() throws Exception {
       server.enqueue(jsonResponse("/aggregated_instance_list_empty.json"));
 
-      AggregatedListApi aggregatedList = api().aggregatedList("party");
+      AggregatedListApi aggregatedList = api().aggregatedList();
 
       assertFalse(aggregatedList.instances().hasNext());
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 a3c9d45..b7d4545 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
@@ -16,8 +16,8 @@
  */
 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.config.GoogleComputeEngineScopes.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes.COMPUTE_SCOPE;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.AssertJUnit.assertNull;
@@ -50,11 +50,11 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/disk_get.json")).build();
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, get, response).disksInZone("us-central1-a");
 
       assertEquals(api.get("testimage1"),
               new ParseDiskTest().expected());
@@ -68,10 +68,10 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+      HttpResponse response = HttpResponse.builder().statusCode(404).build();
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, get, response).disksInZone("us-central1-a");
 
       assertNull(api.get("testimage1"));
    }
@@ -91,7 +91,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, insert,
-              insertDiskResponse).getDiskApi("party", "us-central1-a");
+              insertDiskResponse).disksInZone("us-central1-a");
 
       assertEquals(api.create("testimage1", 1), new ParseZoneOperationTest().expected());
    }
@@ -111,7 +111,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
                                           TOKEN_RESPONSE, insert,
-                                          insertDiskResponse).getDiskApi("party", "us-central1-a");
+                                          insertDiskResponse).disksInZone("us-central1-a");
 
       DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL));
       assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
@@ -132,7 +132,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
 
     DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
                                        TOKEN_RESPONSE, insert,
-                                       insertDiskResponse).getDiskApi("party", "us-central1-a");
+                                       insertDiskResponse).disksInZone("us-central1-a");
 
     DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL));
     assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
@@ -153,7 +153,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, createSnapshotRequest,
-              createSnapshotResponse).getDiskApi("party", "us-central1-a");
+              createSnapshotResponse).disksInZone("us-central1-a");
 
       assertEquals(api.createSnapshot("testimage1", "test-snap"),
             new ParseZoneOperationTest().expected());
@@ -174,7 +174,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, createSnapshotRequest,
-              createSnapshotResponse).getDiskApi("party", "us-central1-a");
+              createSnapshotResponse).disksInZone("us-central1-a");
 
       api.createSnapshot("testimage1", "test-snap");
    }
@@ -191,7 +191,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
               .payload(payloadFromResource("/zone_operation.json")).build();
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, delete, deleteResponse).disksInZone("us-central1-a");
 
       assertEquals(api.delete("testimage1"),
               new ParseZoneOperationTest().expected());
@@ -208,40 +208,34 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleC
       HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, delete, deleteResponse).disksInZone("us-central1-a");
 
       assertNull(api.delete("testimage1"));
    }
 
-   public void testListDisksResponseIs2xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
+   HttpRequest list = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
+         .addHeader("Accept", "application/json")
+         .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+   public void list() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/disk_list.json")).build();
 
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, list, response).disksInZone("us-central1-a");
 
-      assertEquals(api.list().next().toString(), new ParseDiskListTest().expected().toString());
+      assertEquals(api.list().next(), new ParseDiskListTest().expected());
    }
 
-   public void testListDisksResponseIs4xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
+   public void listEmpty() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/list_empty.json")).build();
+      
       DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getDiskApi("party", "us-central1-a");
+              TOKEN_RESPONSE, list, response).disksInZone("us-central1-a");
 
       assertFalse(api.list().hasNext());
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 8b61648..32a1943 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
@@ -37,7 +37,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    public static final int sizeGb = 1;
 
    private DiskApi api() {
-      return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME);
+      return api.disksInZone(DEFAULT_ZONE_NAME);
    }
 
    @Test(groups = "live")
@@ -71,12 +71,12 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    private void assertDiskEquals(Disk result) {
       assertEquals(result.name(), DISK_NAME);
       assertEquals(result.sizeGb(), sizeGb);
-      assertEquals(result.zone(), getDefaultZoneUrl(userProject.get()));
+      assertEquals(result.zone(), getDefaultZoneUrl());
    }
 
    @Test(groups = "live")
    public void testInsertSSDDisk() {
-      URI diskType = getDiskTypeUrl(userProject.get(), DEFAULT_ZONE_NAME, "pd-ssd");
+      URI diskType = getDiskTypeUrl(DEFAULT_ZONE_NAME, "pd-ssd");
       DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(diskType);
       assertOperationDoneSuccessfully(api().create(SSD_DISK_NAME, sizeGb, diskCreationOptions));
    }
@@ -96,7 +96,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    private void assertSSDDiskEquals(Disk result) {
       assertEquals(result.name(), SSD_DISK_NAME);
       assertEquals(result.sizeGb(), sizeGb);
-      assertEquals(result.zone(), getDefaultZoneUrl(userProject.get()));
-      assertEquals(result.type(), getDiskTypeUrl(userProject.get(), DEFAULT_ZONE_NAME, "pd-ssd"));
+      assertEquals(result.zone(), getDefaultZoneUrl());
+      assertEquals(result.type(), getDiskTypeUrl(DEFAULT_ZONE_NAME, "pd-ssd"));
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 451f819..d312ee4 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
@@ -16,7 +16,7 @@
  */
 package org.jclouds.googlecomputeengine.features;
 
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes.COMPUTE_READONLY_SCOPE;
 import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
@@ -53,11 +53,11 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/disktype.json")).build();
 
       DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("party", "us-central1-a");
+              TOKEN_RESPONSE, get, response).diskTypesInZone("us-central1-a");
 
       assertEquals(diskTypeApi.get("pd-standard"),
               new ParseDiskTypeTest().expected());
@@ -71,32 +71,31 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+      HttpResponse response = HttpResponse.builder().statusCode(404).build();
 
       DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("party", "us-central1-a");
+              TOKEN_RESPONSE, get, response).diskTypesInZone("us-central1-a");
 
       assertNull(diskTypeApi.get("pd-standard"));
    }
 
-   public void testListDiskTypeNoOptionsResponseIs2xx() throws Exception {
+   public void list() throws Exception {
 
       DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi
-            ("party", "us-central1-a");
+            TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).diskTypesInZone("us-central1-a");
 
-      assertEquals(diskTypeApi.list().next().toString(), new ParseDiskTypeListTest().expected().toString());
+      assertEquals(diskTypeApi.list().next(), new ParseDiskTypeListTest().expected());
    }
 
-   public void testListDiskTypesWithPaginationOptionsResponseIs4xx() {
-
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
+   public void listWithOptionsEmpty() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/list_empty.json")).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, listRequestWithOptions, operationResponse).getDiskTypeApi("party", "us-central1-a");
+              TOKEN_RESPONSE, listRequestWithOptions, response).diskTypesInZone("us-central1-a");
 
       assertFalse(diskTypeApi.list(maxResults(1)).hasNext());
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 5e252f8..e776a20 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
@@ -33,7 +33,7 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    private DiskType diskType;
 
    private DiskTypeApi api() {
-      return api.getDiskTypeApi(userProject.get(), DEFAULT_ZONE_NAME);
+      return api.diskTypesInZone(DEFAULT_ZONE_NAME);
    }
 
    @Test(groups = "live")

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
index 3d0d878..f7f2b16 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
@@ -19,8 +19,8 @@ package org.jclouds.googlecomputeengine.features;
 import static com.google.common.base.Joiner.on;
 import static com.google.common.collect.Iterables.transform;
 import static java.lang.String.format;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineScopes.COMPUTE_SCOPE;
 import static org.jclouds.io.Payloads.newStringPayload;
 import static org.jclouds.util.Strings2.toStringAndClose;
 import static org.testng.Assert.assertEquals;
@@ -64,7 +64,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
    public void testGetFirewallResponseIs2xx() throws Exception {
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApi("party");
+              TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).firewalls();
 
       assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
    }
@@ -106,10 +106,10 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+      HttpResponse response = HttpResponse.builder().statusCode(404).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, operationResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, get, response).firewalls();
 
       assertNull(api.get("jclouds-test"));
    }
@@ -135,7 +135,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .payload(payloadFromResource("/operation.json")).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, request, insertFirewallResponse).firewalls();
 
       assertEquals(api.createInNetwork("myfw", URI.create(BASE_URL + "/party/global/networks/default"),
               new FirewallOptions()
@@ -167,7 +167,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, update,
-              updateFirewallResponse).getFirewallApi("party");
+              updateFirewallResponse).firewalls();
 
       assertEquals(api.update("myfw",
               new FirewallOptions()
@@ -200,7 +200,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, update,
-              updateFirewallResponse).getFirewallApi("party");
+              updateFirewallResponse).firewalls();
 
       assertEquals(api.patch("myfw",
               new FirewallOptions()
@@ -224,7 +224,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .payload(payloadFromResource("/operation.json")).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, delete, deleteResponse).firewalls();
 
       assertEquals(api.delete("default-allow-internal"),
               new ParseOperationTest().expected());
@@ -241,40 +241,34 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
       HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, delete, deleteResponse).firewalls();
 
       assertNull(api.delete("default-allow-internal"));
    }
 
-   public void testListFirewallsResponseIs2xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/global/firewalls")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
+   HttpRequest list = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint(BASE_URL + "/party/global/firewalls")
+         .addHeader("Accept", "application/json")
+         .addHeader("Authorization", "Bearer " + TOKEN).build();
 
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
+   public void testListFirewallsResponseIs2xx() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
               .payload(payloadFromResource("/firewall_list.json")).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, list, response).firewalls();
 
-      assertEquals(api.list().next().toString(), new ParseFirewallListTest().expected().toString());
+      assertEquals(api.list().next(), new ParseFirewallListTest().expected());
    }
 
-   public void testListFirewallsResponseIs4xx() {
-      HttpRequest list = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/global/firewalls")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
+   public void listEmpty() {
+      HttpResponse response = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/list_empty.json")).build();
 
       FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, operationResponse).getFirewallApi("party");
+              TOKEN_RESPONSE, list, response).firewalls();
 
       assertFalse(api.list().hasNext());
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/37e0397d/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 0d7371a..a4098c2 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
@@ -39,14 +39,14 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    private static final String IPV4_RANGE = "10.0.0.0/8";
 
    private FirewallApi api() {
-      return api.getFirewallApi(userProject.get());
+      return api.firewalls();
    }
 
    @Test(groups = "live")
    public void testInsertFirewall() {
       // need to insert the network first
       assertOperationDoneSuccessfully(
-            api.getNetworkApi(userProject.get()).createInIPv4Range(FIREWALL_NETWORK_NAME, IPV4_RANGE));
+            api.networks().createInIPv4Range(FIREWALL_NETWORK_NAME, IPV4_RANGE));
 
       FirewallOptions firewall = new FirewallOptions()
               .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22")))
@@ -55,14 +55,14 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
               .addTargetTag("tag2");
 
       assertOperationDoneSuccessfully(
-            api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME), firewall));
+            api().createInNetwork(FIREWALL_NAME, getNetworkUrl(FIREWALL_NETWORK_NAME), firewall));
    }
 
    @Test(groups = "live", dependsOnMethods = "testInsertFirewall")
    public void testUpdateFirewall() {
       FirewallOptions firewall = new FirewallOptions()
               .name(FIREWALL_NAME)
-              .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+              .network(getNetworkUrl(FIREWALL_NETWORK_NAME))
               .addSourceRange("10.0.0.0/8")
               .addSourceTag("tag1")
               .addTargetTag("tag2")
@@ -75,7 +75,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    public void testPatchFirewall() {
       FirewallOptions firewall = new FirewallOptions()
               .name(FIREWALL_NAME)
-              .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+              .network(getNetworkUrl(FIREWALL_NETWORK_NAME))
               .allowedRules(ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("22")),
                     Firewall.Rule.create("tcp", ImmutableList.of("23"))))
               .addSourceRange("10.0.0.0/8")
@@ -89,7 +89,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    public void testGetFirewall() {
       FirewallOptions patchedFirewall = new FirewallOptions()
               .name(FIREWALL_NAME)
-              .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
+              .network(getNetworkUrl(FIREWALL_NETWORK_NAME))
               .allowedRules(ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("22")),
                     Firewall.Rule.create("tcp", ImmutableList.of("23"))))
               .addSourceRange("10.0.0.0/8")
@@ -111,7 +111,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
    @Test(groups = "live", dependsOnMethods = "testListFirewall")
    public void testDeleteFirewall() {
       assertOperationDoneSuccessfully(api().delete(FIREWALL_NAME));
-      assertOperationDoneSuccessfully(api.getNetworkApi(userProject.get()).delete(FIREWALL_NETWORK_NAME));
+      assertOperationDoneSuccessfully(api.networks().delete(FIREWALL_NETWORK_NAME));
    }
 
    private void assertFirewallEquals(Firewall result, FirewallOptions expected) {