http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java index 01c039e..afa05ac 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecloudstorage.domain.Bucket; import org.jclouds.googlecloudstorage.domain.Bucket.Cors; import org.jclouds.googlecloudstorage.domain.Bucket.Logging; @@ -36,7 +37,6 @@ import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; -import org.jclouds.googlecloudstorage.domain.ListPage; import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate; import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageApiLiveTest; @@ -182,7 +182,6 @@ public class BucketApiLiveTest extends BaseGoogleCloudStorageApiLiveTest { assertNotNull(iteratedBucket); assertSame(bucketAsList.size(), 1); - } @Test(groups = "live", dependsOnMethods = "testCreateBucket")
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectApiLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectApiLiveTest.java index 0fb79af..9b21d2a 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectApiLiveTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/ObjectApiLiveTest.java @@ -33,7 +33,7 @@ import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Destinatio import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Projection; import org.jclouds.googlecloudstorage.domain.GCSObject; -import org.jclouds.googlecloudstorage.domain.ListPage; +import org.jclouds.googlecloudstorage.domain.ListPageWithPrefixes; import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; import org.jclouds.googlecloudstorage.domain.templates.BucketTemplate; import org.jclouds.googlecloudstorage.domain.templates.ComposeObjectTemplate; @@ -262,7 +262,7 @@ public class ObjectApiLiveTest extends BaseGoogleCloudStorageApiLiveTest { @Test(groups = "live", dependsOnMethods = "testComposeObjectWithOptions") public void listObjects() { - ListPage<GCSObject> list = api().listObjects(BUCKET_NAME); + ListPageWithPrefixes<GCSObject> list = api().listObjects(BUCKET_NAME); assertNotNull(list); assertEquals(list.get(0) instanceof GCSObject, true); @@ -271,7 +271,7 @@ public class ObjectApiLiveTest extends BaseGoogleCloudStorageApiLiveTest { @Test(groups = "live", dependsOnMethods = "testComposeObjectWithOptions") public void testListObjectsWithOptions() { ListObjectOptions options = new ListObjectOptions().maxResults(1); - ListPage<GCSObject> list = api().listObjects(BUCKET_NAME, options); + ListPageWithPrefixes<GCSObject> list = api().listObjects(BUCKET_NAME, options); while (list.nextPageToken() != null) { assertNotNull(list); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiExpectTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiExpectTest.java index cde42ed..088932b 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiExpectTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiExpectTest.java @@ -22,8 +22,7 @@ import org.jclouds.googlecloudstorage.GoogleCloudStorageApi; public class BaseGoogleCloudStorageApiExpectTest extends BaseGoogleCloudStorageExpectTest<GoogleCloudStorageApi> { - @Override - protected Properties setupProperties() { + @Override protected Properties setupProperties() { Properties properties = super.setupProperties(); properties.put("google-cloud-storage.identity", "JcloudTest"); return properties; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiLiveTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiLiveTest.java index 6642bf0..b69b4c3 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiLiveTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageApiLiveTest.java @@ -19,7 +19,11 @@ package org.jclouds.googlecloudstorage.internal; import java.util.Properties; import org.jclouds.apis.BaseApiLiveTest; +import org.jclouds.googlecloud.internal.TestProperties; import org.jclouds.googlecloudstorage.GoogleCloudStorageApi; +import org.jclouds.googlecloudstorage.GoogleCloudStorageProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + import com.google.inject.Injector; import com.google.inject.Module; @@ -27,13 +31,20 @@ public class BaseGoogleCloudStorageApiLiveTest extends BaseApiLiveTest<GoogleClo protected static final String PROJECT_NUMBER = System.getProperty("test.google-cloud-storage.project-number"); - public BaseGoogleCloudStorageApiLiveTest() { + protected BaseGoogleCloudStorageApiLiveTest() { provider = "google-cloud-storage"; } - protected GoogleCloudStorageApi create(Properties props, Iterable<Module> modules) { + @Override protected ProviderMetadata createProviderMetadata(){ + return new GoogleCloudStorageProviderMetadata(); + } + + @Override protected Properties setupProperties() { + return TestProperties.apply(provider, super.setupProperties()); + } + + @Override protected GoogleCloudStorageApi create(Properties props, Iterable<Module> modules) { Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); return injector.getInstance(GoogleCloudStorageApi.class); } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageExpectTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageExpectTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageExpectTest.java index 40e26cd..fe35910 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageExpectTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageExpectTest.java @@ -39,24 +39,22 @@ import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; -import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MediaType; -import org.jclouds.apis.ApiMetadata; import org.jclouds.crypto.Crypto; -import org.jclouds.googlecloudstorage.GoogleCloudStorageApiMetadata; +import org.jclouds.googlecloudstorage.GoogleCloudStorageProviderMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payload; import org.jclouds.io.payloads.ByteSourcePayload; import org.jclouds.oauth.v2.functions.BuildTokenRequest; import org.jclouds.oauth.v2.functions.BuildTokenRequest.TestBuildTokenRequest; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.internal.BaseRestApiExpectTest; -import org.jclouds.ssh.SshKeys; import com.google.common.base.Joiner; import com.google.common.base.Supplier; @@ -86,14 +84,11 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T .payload(payloadFromString("{\n" + " \"access_token\" : \"" + TOKEN + "\",\n" + " \"token_type\" : \"Bearer\",\n" + " \"expires_in\" : 3600\n" + "}")).build(); - protected String openSshKey; - - public BaseGoogleCloudStorageExpectTest() { + protected BaseGoogleCloudStorageExpectTest() { provider = "google-cloud-storage"; } - @Override - protected Module createModule() { + @Override protected Module createModule() { return new Module() { @Override public void configure(Binder binder) { @@ -106,7 +101,6 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T PublicKey publicKey = keyfactory .generatePublic(publicKeySpec(ByteSource.wrap(PUBLIC_KEY.getBytes(UTF_8)))); KeyPair keyPair = new KeyPair(publicKey, privateKey); - openSshKey = SshKeys.encodeAsOpenSSH(RSAPublicKey.class.cast(publicKey)); final Crypto crypto = createMock(Crypto.class); KeyPairGenerator rsaKeyPairGenerator = createMock(KeyPairGenerator.class); final SecureRandom secureRandom = createMock(SecureRandom.class); @@ -137,16 +131,15 @@ public class BaseGoogleCloudStorageExpectTest<T> extends BaseRestApiExpectTest<T }; } - @Override - protected Properties setupProperties() { + @Override protected Properties setupProperties() { Properties props = super.setupProperties(); // use no sig algorithm for expect tests (means no credential is required either) props.put(JWS_ALG, NONE); return props; } - @Override protected ApiMetadata createApiMetadata(){ - return new GoogleCloudStorageApiMetadata(); + @Override protected ProviderMetadata createProviderMetadata(){ + return new GoogleCloudStorageProviderMetadata(); } @Override http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageParseTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageParseTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageParseTest.java index 7b9d087..9209269 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageParseTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/internal/BaseGoogleCloudStorageParseTest.java @@ -25,8 +25,7 @@ import com.google.inject.Injector; public abstract class BaseGoogleCloudStorageParseTest<T> extends BaseItemParserTest<T> { - @Override - protected Injector injector() { + @Override protected Injector injector() { return Guice.createInjector(new GsonModule(), new GoogleCloudStorageParserModule()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java index 14d473b..3f2759b 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/FullBucketGetTest.java @@ -25,9 +25,9 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecloudstorage.domain.Bucket; import org.jclouds.googlecloudstorage.domain.Bucket.Cors; import org.jclouds.googlecloudstorage.domain.BucketAccessControls; +import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole; -import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; import org.jclouds.googlecloudstorage.domain.ObjectAccessControls; import org.jclouds.googlecloudstorage.domain.Owner; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/NoAclBucketListTest.java ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/NoAclBucketListTest.java b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/NoAclBucketListTest.java index af160fd..91c8074 100644 --- a/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/NoAclBucketListTest.java +++ b/google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/parse/NoAclBucketListTest.java @@ -22,10 +22,11 @@ import javax.ws.rs.Consumes; import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.googlecloud.domain.ForwardingListPage; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecloudstorage.domain.Bucket; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location; import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass; -import org.jclouds.googlecloudstorage.domain.ListPage; import org.jclouds.googlecloudstorage.domain.Owner; import org.jclouds.googlecloudstorage.internal.BaseGoogleCloudStorageParseTest; @@ -55,6 +56,6 @@ public class NoAclBucketListTest extends BaseGoogleCloudStorageParseTest<ListPag @Override @Consumes(MediaType.APPLICATION_JSON) public ListPage<Bucket> expected() { - return ListPage.create(Arrays.asList(item1), "bhashbucket", null); + return ForwardingListPage.create(Arrays.asList(item1), "bhashbucket"); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-cloud-storage/src/test/resources/logback.xml ---------------------------------------------------------------------- diff --git a/google-cloud-storage/src/test/resources/logback.xml b/google-cloud-storage/src/test/resources/logback.xml new file mode 100644 index 0000000..864a5a5 --- /dev/null +++ b/google-cloud-storage/src/test/resources/logback.xml @@ -0,0 +1,83 @@ +<?xml version="1.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. + +--> +<configuration scan="false"> + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <appender name="WIREFILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds-wire.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <appender name="COMPUTEFILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds-compute.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <appender name="SSHFILE" class="ch.qos.logback.core.FileAppender"> + <file>target/test-data/jclouds-ssh.log</file> + + <encoder> + <Pattern>%d %-5p [%c] [%thread] %m%n</Pattern> + </encoder> + </appender> + + <root> + <level value="warn" /> + </root> + + <logger name="org.jclouds"> + <level value="TRACE" /> + <appender-ref ref="FILE" /> + </logger> + + <logger name="jclouds.wire"> + <level value="TRACE" /> + <appender-ref ref="WIREFILE" /> + </logger> + + <logger name="jclouds.headers"> + <level value="TRACE" /> + <appender-ref ref="WIREFILE" /> + </logger> + + <logger name="jclouds.compute"> + <level value="TRACE" /> + <appender-ref ref="COMPUTEFILE" /> + </logger> + + <logger name="jclouds.ssh"> + <level value="TRACE" /> + <appender-ref ref="SSHFILE" /> + </logger> + +</configuration> + http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/pom.xml ---------------------------------------------------------------------- diff --git a/google-compute-engine/pom.xml b/google-compute-engine/pom.xml index dd9a379..4c01bbc 100644 --- a/google-compute-engine/pom.xml +++ b/google-compute-engine/pom.xml @@ -36,7 +36,7 @@ <test.google-compute-engine.identity>client_email which usually looks like [email protected]</test.google-compute-engine.identity> <test.google-compute-engine.credential>Private key (PEM encoded PKCS12 file or literal) associated with the client_email</test.google-compute-engine.credential> <!-- Add this property to use a different project, or avoid looking up the project for each test. --> - <test.jclouds.google-compute-engine.project-name></test.jclouds.google-compute-engine.project-name> + <test.jclouds.googlecloud.project-name></test.jclouds.googlecloud.project-name> <test.jclouds.oauth.credential-type>p12PrivateKeyCredentials</test.jclouds.oauth.credential-type> <test.google-compute-engine.api-version>v1</test.google-compute-engine.api-version> <test.google-compute-engine.build-version/> @@ -51,13 +51,13 @@ </dependency> <dependency> <groupId>org.apache.jclouds.labs</groupId> - <artifactId>oauth</artifactId> + <artifactId>googlecloud</artifactId> <version>${project.version}</version> <type>jar</type> </dependency> <dependency> <groupId>org.apache.jclouds.labs</groupId> - <artifactId>oauth</artifactId> + <artifactId>googlecloud</artifactId> <version>${project.version}</version> <type>test-jar</type> <scope>test</scope> @@ -142,7 +142,7 @@ <systemPropertyVariables> <test.google-compute-engine.identity>${test.google-compute-engine.identity}</test.google-compute-engine.identity> <test.google-compute-engine.credential>${test.google-compute-engine.credential}</test.google-compute-engine.credential> - <test.jclouds.google-compute-engine.project-name>${test.jclouds.google-compute-engine.project-name}</test.jclouds.google-compute-engine.project-name> + <test.jclouds.googlecloud.project-name>${test.jclouds.googlecloud.project-name}</test.jclouds.googlecloud.project-name> <test.jclouds.oauth.credential-type>${test.jclouds.oauth.credential-type}</test.jclouds.oauth.credential-type> <test.google-compute-engine.api-version>${test.google-compute-engine.api-version}</test.google-compute-engine.api-version> <test.google-compute-engine.build-version>${test.google-compute-engine.build-version}</test.google-compute-engine.build-version> http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 4757c9d..b8cc72f 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 @@ -21,7 +21,7 @@ import java.io.Closeable; import javax.ws.rs.Path; import javax.ws.rs.PathParam; -import org.jclouds.googlecomputeengine.config.CurrentProject; +import org.jclouds.googlecloud.config.CurrentProject; import org.jclouds.googlecomputeengine.features.AddressApi; import org.jclouds.googlecomputeengine.features.AggregatedListApi; import org.jclouds.googlecomputeengine.features.DiskApi; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java index 4ddea1b..9f11321 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApiMetadata.java @@ -18,10 +18,10 @@ package org.jclouds.googlecomputeengine; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; +import static org.jclouds.googlecloud.config.GoogleCloudProperties.PROJECT_NAME; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.IMAGE_PROJECTS; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.OPERATION_COMPLETE_INTERVAL; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.OPERATION_COMPLETE_TIMEOUT; -import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.PROJECT_NAME; import static org.jclouds.oauth.v2.config.OAuthProperties.AUDIENCE; import static org.jclouds.oauth.v2.config.OAuthProperties.JWS_ALG; import static org.jclouds.reflect.Reflection2.typeToken; @@ -30,6 +30,7 @@ import java.net.URI; import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.googlecloud.config.CurrentProject; import org.jclouds.googlecomputeengine.compute.config.GoogleComputeEngineServiceContextModule; import org.jclouds.googlecomputeengine.config.GoogleComputeEngineHttpApiModule; import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule; @@ -73,8 +74,7 @@ public class GoogleComputeEngineApiMetadata extends BaseHttpApiMetadata<GoogleCo protected Builder() { id("google-compute-engine") .name("Google Compute Engine Api") - .identityName("client_email which usually looks like [email protected] or " // - + "[email protected]") + .identityName(CurrentProject.ClientEmail.DESCRIPTION) .credentialName("PEM encoded P12 private key associated with client_email") .documentation(URI.create("https://developers.google.com/compute/docs")) .version("v1") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 cd1816c..ed7c5fb 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 @@ -19,7 +19,7 @@ package org.jclouds.googlecomputeengine.compute; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; -import static org.jclouds.googlecomputeengine.internal.ListPages.concat; +import static org.jclouds.googlecloud.internal.ListPages.concat; import java.util.Map; import java.util.Set; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 7f15ebb..bad4249 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 @@ -21,9 +21,9 @@ import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Lists.newArrayList; import static java.lang.String.format; +import static org.jclouds.googlecloud.internal.ListPages.concat; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.IMAGE_PROJECTS; import static org.jclouds.googlecomputeengine.domain.NewInstance.Disk; -import static org.jclouds.googlecomputeengine.internal.ListPages.concat; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 f98c894..9185edf 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 @@ -19,12 +19,12 @@ package org.jclouds.googlecomputeengine.compute.extensions; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static org.jclouds.googlecloud.internal.ListPages.concat; import static org.jclouds.googlecomputeengine.compute.predicates.NetworkFirewallPredicates.equalsIpPermission; import static org.jclouds.googlecomputeengine.compute.predicates.NetworkFirewallPredicates.providesIpPermission; import static org.jclouds.googlecomputeengine.compute.strategy.CreateNodesWithGroupEncodedIntoNameThenAddToSet.DEFAULT_INTERNAL_NETWORK_RANGE; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.OPERATION_COMPLETE_INTERVAL; import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.OPERATION_COMPLETE_TIMEOUT; -import static org.jclouds.googlecomputeengine.internal.ListPages.concat; import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.jclouds.util.Predicates2.retry; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 8306f8b..0afcc17 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 @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.compute.functions; -import static org.jclouds.googlecomputeengine.internal.ListPages.concat; +import static org.jclouds.googlecloud.internal.ListPages.concat; import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import javax.inject.Inject; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/CurrentProject.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/CurrentProject.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/CurrentProject.java deleted file mode 100644 index 52d1817..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/CurrentProject.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.config; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -/** Associated bindings with the current <a href="https://cloud.google.com/compute/docs/projects">project</a>. */ -@Retention(value = RetentionPolicy.RUNTIME) -@Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) -@Qualifier -public @interface CurrentProject { -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java index b89fd92..af06083 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java @@ -16,18 +16,15 @@ */ package org.jclouds.googlecomputeengine.config; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Suppliers.compose; import static java.util.concurrent.TimeUnit.SECONDS; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.jclouds.googlecomputeengine.config.GoogleComputeEngineProperties.PROJECT_NAME; +import static org.jclouds.googlecloud.config.GoogleCloudProperties.PROJECT_NAME; import static org.jclouds.rest.config.BinderUtils.bindHttpApi; import java.net.URI; import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import javax.inject.Inject; import javax.inject.Named; @@ -38,6 +35,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import org.jclouds.domain.Credentials; +import org.jclouds.googlecloud.config.CurrentProject; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Project; import org.jclouds.googlecomputeengine.handlers.GoogleComputeEngineErrorHandler; @@ -116,7 +114,6 @@ public final class GoogleComputeEngineHttpApiModule extends HttpApiModule<Google * targetPools. */ static final class UseApiToResolveProjectName implements Function<Credentials, URI> { - public static final Pattern PROJECT_NUMBER_PATTERN = Pattern.compile("^([0-9]+)[@-].*"); @SkipEncoding({ '/', '=' }) @RequestFilters(OAuthAuthenticationFilter.class) @@ -139,9 +136,8 @@ public final class GoogleComputeEngineHttpApiModule extends HttpApiModule<Google } @Override public URI apply(Credentials in) { - Matcher matcher = PROJECT_NUMBER_PATTERN.matcher(in.identity); - checkArgument(matcher.find(), "Identity %s is malformed. Should be %s", in.identity, identityName); - return URI.create(defaultEndpoint.get() + "/projects/" + api.get(matcher.group(1)).name()); + String projectNumber = CurrentProject.ClientEmail.toProjectNumber(in.identity); + return URI.create(defaultEndpoint.get() + "/projects/" + api.get(projectNumber).name()); } } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java index 892da57..a0c7fdd 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineParserModule.java @@ -18,36 +18,27 @@ package org.jclouds.googlecomputeengine.config; import static org.jclouds.googlecomputeengine.domain.Firewall.Rule; -import java.io.IOException; -import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.Map; import java.util.Set; import javax.inject.Singleton; +import org.jclouds.googlecloud.config.ListPageAdapterFactory; import org.jclouds.googlecomputeengine.domain.Firewall; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.options.FirewallOptions; import org.jclouds.googlecomputeengine.options.RouteOptions; import org.jclouds.json.config.GsonModule; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; -import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; import com.google.inject.AbstractModule; import com.google.inject.Provides; @@ -143,79 +134,4 @@ public final class GoogleComputeEngineParserModule extends AbstractModule { } return array; } - - static final class ListPageAdapterFactory implements TypeAdapterFactory { - static final class ListPageAdapter extends TypeAdapter<ListPage<?>> { - private final TypeAdapter<?> itemAdapter; - - ListPageAdapter(TypeAdapter<?> itemAdapter) { - this.itemAdapter = itemAdapter; - nullSafe(); - } - - public void write(JsonWriter out, ListPage<?> value) throws IOException { - throw new UnsupportedOperationException("We only read ListPages!"); - } - - public ListPage<?> read(JsonReader in) throws IOException { - ImmutableList.Builder<Object> items = ImmutableList.builder(); - String nextPageToken = null; - in.beginObject(); - while (in.hasNext()) { - String name = in.nextName(); - if (name.equals("items")) { - if (in.peek() == JsonToken.BEGIN_ARRAY) { - readItems(in, items); - } else { // aggregated - readAggregate(in, items); - } - } else if (name.equals("nextPageToken")) { - nextPageToken = in.nextString(); - } else { - in.skipValue(); - } - } - in.endObject(); - return ListPage.create(items.build(), nextPageToken); - } - - private void readItems(JsonReader in, ImmutableList.Builder<Object> items) throws IOException { - in.beginArray(); - while (in.hasNext()) { - Object item = itemAdapter.read(in); - if (item != null) { - items.add(item); - } - } - in.endArray(); - } - - private void readAggregate(JsonReader in, ImmutableList.Builder<Object> items) throws IOException { - in.beginObject(); // enter zone name -> type -> items map - while (in.hasNext()) { - String scope = in.nextName(); // skip zone name - in.beginObject(); // enter zone map - while (in.hasNext()) { - String resourceTypeOrWarning = in.nextName(); - if (!resourceTypeOrWarning.equals("warning")) { - readItems(in, items); - } else { - in.skipValue(); - } - } - in.endObject(); // end zone map - } - in.endObject(); // end item wrapper - } - } - - @SuppressWarnings("unchecked") public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> ownerType) { - Type type = ownerType.getType(); - if (ownerType.getRawType() != ListPage.class || !(type instanceof ParameterizedType)) - return null; - Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0]; - TypeAdapter<?> itemAdapter = gson.getAdapter(TypeToken.get(elementType)); - return (TypeAdapter<T>) new ListPageAdapter(itemAdapter); - } - } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineProperties.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineProperties.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineProperties.java index e554fc0..526ea93 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineProperties.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineProperties.java @@ -16,27 +16,14 @@ */ package org.jclouds.googlecomputeengine.config; -import org.jclouds.oauth.v2.config.OAuthProperties; - import com.google.common.annotations.Beta; -/** Configuration properties keys used in {@link org.jclouds.ContextBuilder#overrides(java.util.Properties)}. */ +/** + * Configuration properties keys used in {@link org.jclouds.ContextBuilder#overrides(java.util.Properties)}. + * <p/> Note that these are in addition to properties defined in {@link org.jclouds.googlecloud.config.GoogleCloudProperties}. + */ public final class GoogleComputeEngineProperties { - /** - * How requests are authorized using OAuth. Defaults to {@link org.jclouds.oauth.v2.config.CredentialType#P12_PRIVATE_KEY_CREDENTIALS}. - * - * @see org.jclouds.oauth.v2.config.CredentialType - */ - public static final String CREDENTIAL_TYPE = OAuthProperties.CREDENTIAL_TYPE; - - /** - * Set this property to specify the <a href="https://cloud.google.com/compute/docs/projects">project name</a> this - * context applies to. - * <p/> This is an alternative to looking up the project name at runtime. - */ - public static final String PROJECT_NAME = "jclouds.google-compute-engine.project-name"; - /** The total time, in msecs, to wait for an operation to complete. */ @Beta public static final String OPERATION_COMPLETE_TIMEOUT = "jclouds.google-compute-engine.operation-complete-timeout"; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java index e8e4add..25ac6eb 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java index 91c15f4..6c420b4 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java deleted file mode 100644 index 8d66104..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ListPage.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; - -import java.beans.ConstructorProperties; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.collect.ForwardingList; - -/** An immutable list that includes a token, if there is another page available. */ -public final class ListPage<T> extends ForwardingList<T> { - - private final List<T> items; - private final String nextPageToken; - - public static <T> ListPage<T> create(List<T> items, String nextPageToken) { - return new ListPage<T>(items, nextPageToken); - } - - @ConstructorProperties({ "items", "nextPageToken" }) - ListPage(List<T> items, String nextPageToken) { - this.items = copyOf(items); - this.nextPageToken = nextPageToken; - } - - @Nullable public String nextPageToken() { - return nextPageToken; - } - - @Override protected List<T> delegate() { - return items; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java index 3cfd92b..973a4b1 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/MachineType.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java index 8d6ade4..4cabead 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.Date; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java index d5bb303..480f23f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java index 2b4a425..f055091 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java index 4af546e..ac8774f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetPool.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetPool.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetPool.java index bb006dd..ee7fe7b 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetPool.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetPool.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.List; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java index fd8877e..68b9a31 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java @@ -16,7 +16,7 @@ */ package org.jclouds.googlecomputeengine.domain; -import static org.jclouds.googlecomputeengine.internal.NullSafeCopies.copyOf; +import static org.jclouds.googlecloud.internal.NullSafeCopies.copyOf; import java.net.URI; import java.util.Date; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 8ecc1c4..3826c42 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 @@ -32,9 +32,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Address; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java index 86232b4..eb6522f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/AggregatedListApi.java @@ -27,9 +27,9 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.QueryParam; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Instance; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.MachineType; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 132937f..dca0bfc 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 @@ -32,10 +32,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.DiskCreationBinder; import org.jclouds.googlecomputeengine.domain.Disk; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.DiskCreationOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 a0a00be..9aecc49 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 @@ -29,9 +29,9 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.DiskType; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.javax.annotation.Nullable; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 9c25376..233065e 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 @@ -34,13 +34,12 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.FirewallBinder; import org.jclouds.googlecomputeengine.domain.Firewall; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; -import org.jclouds.googlecomputeengine.internal.PATCH; import org.jclouds.googlecomputeengine.options.FirewallOptions; import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.javax.annotation.Nullable; @@ -48,6 +47,7 @@ import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Fallback; import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PATCH; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 90a591b..166821d 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 @@ -33,10 +33,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.ForwardingRuleCreationBinder; import org.jclouds.googlecomputeengine.domain.ForwardingRule; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 767f6a3..ed41b2c 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 @@ -33,10 +33,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.HttpHealthCheckCreationBinder; import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 e4faa6f..52c7d5f 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 @@ -33,10 +33,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.config.CurrentProject; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.config.CurrentProject; import org.jclouds.googlecomputeengine.domain.Image; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 05bc23a..09ffcdf 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 @@ -34,9 +34,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.Instance; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Metadata; import org.jclouds.googlecomputeengine.domain.NewInstance; import org.jclouds.googlecomputeengine.domain.Operation; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 543c15f..9a4f143 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 @@ -29,8 +29,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.MachineType; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 7ef7e0e..6718393 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 @@ -32,8 +32,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Network; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/OperationApi.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/OperationApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/OperationApi.java index 938fd85..f137469 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/OperationApi.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/features/OperationApi.java @@ -32,9 +32,9 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.config.CurrentProject; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.config.CurrentProject; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseArg0ToIteratorOfListPage; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 658ec86..e022c8e 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 @@ -29,8 +29,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Region; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 aedbc1b..4d26316 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 @@ -33,9 +33,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.RouteBinder; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.domain.Route; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 9af65a6..321aa9d 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 @@ -30,8 +30,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.domain.Snapshot; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 534d769..841f917 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 @@ -34,11 +34,11 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder; import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder; import org.jclouds.googlecomputeengine.binders.TargetPoolCreationBinder; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.domain.TargetPool; import org.jclouds.googlecomputeengine.internal.BaseCallerArg0ToIteratorOfListPage; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 e06efa6..5eeea49 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 @@ -29,8 +29,8 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Zone; import org.jclouds.googlecomputeengine.internal.BaseToIteratorOfListPage; import org.jclouds.googlecomputeengine.options.ListOptions; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 deleted file mode 100644 index ec62cc6..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/AdvancingIterator.java +++ /dev/null @@ -1,48 +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.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/f191c8fb/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 index 051a2fc..bb39a13 100644 --- 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 @@ -16,48 +16,8 @@ */ 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; - } + extends org.jclouds.googlecloud.internal.BaseArg0ToIteratorOfListPage<T, ListOptions, I> { } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 index 083f59b..97ca5a4 100644 --- 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 @@ -16,48 +16,8 @@ */ 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; - } + extends org.jclouds.googlecloud.internal.BaseCallerArg0ToIteratorOfListPage<T, ListOptions, I> { } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 index d9209f0..5f53618 100644 --- 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 @@ -16,39 +16,8 @@ */ 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; - } + extends org.jclouds.googlecloud.internal.BaseToIteratorOfListPage<T, ListOptions, I> { } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f191c8fb/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 deleted file mode 100644 index b42a1b2..0000000 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/internal/ListPages.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.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; - -public final class ListPages { - - public static <T> Iterable<T> concat(final Iterator<ListPage<T>> input) { - return new Iterable<T>() { - @Override public Iterator<T> iterator() { - return Iterators.concat(new AbstractIterator<Iterator<T>>() { - @Override protected Iterator<T> computeNext() { - return input.hasNext() ? input.next().iterator() : endOfData(); - } - }); - } - }; - } - - @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() { - } -}
