Skip to content

Commit e9414ea

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 2515 b: refs/heads/update-datastore c: e063bc5 h: refs/heads/master i: 2513: 582b133 2511: d2b14c4
1 parent 81de373 commit e9414ea

62 files changed

Lines changed: 589 additions & 2080 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/gh-pages: 4e0561bb4504bf647db669a14417b2b2c87ba45d
55
refs/heads/bigquery: 762fa5830e6c398c0396177e3e7fd243bd62cfc3
66
refs/heads/pubsub-alpha: 1a0e970f265af871e02274085b9662b3fe29058b
77
refs/heads/resource-manager: ebf4adc5ee835cd2086c4ac5b4e78d01a5a005a7
8-
refs/heads/update-datastore: a23d8f9773334a2698eb5770deaee3e6d140f751
8+
refs/heads/update-datastore: e063bc5707ae1cac53f8d2ec0d3d971dd94e617e
99
refs/tags/0.0.9: 22f1839238f66c39e67ed4dfdcd273b1ae2e8444
1010
refs/tags/v0.0.10: 207ebd2a3472fddee69fe1298eb90429e3306efd
1111
refs/tags/v0.0.11: ffbfba48a6426ff63c08ff2117e58681f251fbf2

branches/update-datastore/README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ If you are using Maven, add this to your pom.xml file
2525
<dependency>
2626
<groupId>com.google.gcloud</groupId>
2727
<artifactId>gcloud-java</artifactId>
28-
<version>0.0.12</version>
28+
<version>0.0.10</version>
2929
</dependency>
3030
```
3131
If you are using Gradle, add this to your dependencies
3232
```Groovy
33-
compile 'com.google.gcloud:gcloud-java:jar:0.0.12'
33+
compile 'com.google.gcloud:gcloud-java:jar:0.0.10'
3434
```
3535
If you are using SBT, add this to your dependencies
3636
```Scala
37-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.0.12"
37+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.0.10"
3838
```
3939

4040
Example Applications
@@ -75,9 +75,7 @@ Most `gcloud-java` libraries require a project ID. There are multiple ways to s
7575
Authentication
7676
--------------
7777

78-
First, ensure that the necessary Google Cloud APIs are enabled for your project. To do this, follow the instructions on the [authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication) shared by all the gcloud language libraries.
79-
80-
Next, choose a method for authenticating API requests from within your project:
78+
There are multiple ways to authenticate to use Google Cloud services.
8179

8280
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
8381
2. When using `gcloud-java` libraries elsewhere, there are two options:
@@ -98,9 +96,9 @@ Next, choose a method for authenticating API requests from within your project:
9896
`gcloud-java` looks for credentials in the following order, stopping once it finds credentials:
9997
10098
1. Credentials supplied when building the service options
101-
2. App Engine credentials
102-
3. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
103-
4. Google Cloud SDK credentials
99+
2. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
100+
3. Google Cloud SDK credentials
101+
4. App Engine credentials
104102
5. Compute Engine credentials
105103
106104
Google Cloud Datastore
@@ -123,7 +121,7 @@ import com.google.gcloud.datastore.Entity;
123121
import com.google.gcloud.datastore.Key;
124122
import com.google.gcloud.datastore.KeyFactory;
125123
126-
Datastore datastore = DatastoreOptions.defaultInstance().service();
124+
Datastore datastore = DatastoreOptions.getDefaultInstance().service();
127125
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
128126
Key key = keyFactory.newKey(keyName);
129127
Entity entity = datastore.get(key);
@@ -166,7 +164,8 @@ import com.google.gcloud.storage.StorageOptions;
166164
import java.nio.ByteBuffer;
167165
import java.nio.channels.WritableByteChannel;
168166
169-
Storage storage = StorageOptions.defaultInstance().service();
167+
StorageOptions options = StorageOptions.builder().projectId("project").build();
168+
Storage storage = options.service();
170169
BlobId blobId = BlobId.of("bucket", "blob_name");
171170
Blob blob = Blob.load(storage, blobId);
172171
if (blob == null) {
@@ -182,11 +181,6 @@ if (blob == null) {
182181
}
183182
```
184183
185-
Troubleshooting
186-
---------------
187-
188-
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
189-
190184
Java Versions
191185
-------------
192186
@@ -213,7 +207,7 @@ Contributing
213207
214208
Contributions to this library are always welcome and highly encouraged.
215209
216-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
210+
See [CONTRIBUTING] for more information on how to get started.
217211
218212
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
219213
@@ -224,7 +218,7 @@ Apache 2.0 - See [LICENSE] for more information.
224218
225219
226220
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
227-
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
221+
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md
228222
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
229223
[TESTING]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md
230224
[cloud-platform]: https://cloud.google.com/

branches/update-datastore/RELEASING.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ This script takes an optional argument denoting the new version. By default, if
1010
2. Create a PR to update the pom.xml version.
1111
The PR should look something like [#225](https://github.com/GoogleCloudPlatform/gcloud-java/pull/225). After this PR is merged into GoogleCloudPlatform/gcloud-java, Travis CI will push a new website to GoogleCloudPlatform/gh-pages, push a new artifact to the Maven Central Repository, and update versions in the README files.
1212

13-
3. Before moving on, verify that the artifacts have successfully been pushed to the Maven Central Repository. Open Travis CI, click the ["Build History" tab](https://travis-ci.org/GoogleCloudPlatform/gcloud-java/builds), and open the second build's logs for Step 2's PR. Be sure that you are not opening the "Pull Request" build logs. When the build finishes, scroll to the end of the log and verify that the artifacts were successfully staged and deployed. You can also search for `gcloud-java` on the [Sonatype website](https://oss.sonatype.org/#nexus-search;quick~gcloud-java) and check the latest version number. If the deployment didn't succeed because of a flaky test, rerun the build.
14-
15-
4. Create a release on Github manually.
13+
3. Create a release on Github manually.
1614
Go to the [releases page](https://github.com/GoogleCloudPlatform/gcloud-java/releases) and click "Draft a new release." Use `vX.Y.Z` as the "Tag Version" and `X.Y.Z` as the "Release Title", where `X.Y.Z` is the release version as listed in the `pom.xml` files.
1715

18-
5. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
16+
4. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
1917
As mentioned before, there is an optional version argument. By default, the script will update the version from "X.Y.Z" to "X.Y.Z+1-SNAPSHOT". Suppose a different version is desired, for example X+1.0.0-SNAPSHOT. Then the appropriate command to run would be `utilities/update_pom_version.sh X+1.0.0-SNAPSHOT`.
2018

21-
6. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
19+
5. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
2220

2321
### To push a snapshot version
2422

branches/update-datastore/gcloud-java-core/README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@ If you are using Maven, add this to your pom.xml file
1717
<dependency>
1818
<groupId>com.google.gcloud</groupId>
1919
<artifactId>gcloud-java-core</artifactId>
20-
<version>0.0.12</version>
20+
<version>0.0.10</version>
2121
</dependency>
2222
```
2323
If you are using Gradle, add this to your dependencies
2424
```Groovy
25-
compile 'com.google.gcloud:gcloud-java-core:jar:0.0.12'
25+
compile 'com.google.gcloud:gcloud-java-core:jar:0.0.10'
2626
```
2727
If you are using SBT, add this to your dependencies
2828
```Scala
29-
libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.0.12"
29+
libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.0.10"
3030
```
3131

32-
Troubleshooting
33-
---------------
34-
35-
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
36-
3732
Java Versions
3833
-------------
3934

@@ -44,9 +39,7 @@ Contributing
4439

4540
Contributions to this library are always welcome and highly encouraged.
4641

47-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
48-
49-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
42+
See [CONTRIBUTING] for more information on how to get started.
5043

5144
Versioning
5245
----------
@@ -64,6 +57,5 @@ Apache 2.0 - See [LICENSE] for more information.
6457

6558

6659
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
67-
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
6860
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
6961
[cloud-platform]: https://cloud.google.com/

branches/update-datastore/gcloud-java-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.google.gcloud</groupId>
1313
<artifactId>gcloud-java-pom</artifactId>
14-
<version>0.0.13-SNAPSHOT</version>
14+
<version>0.0.11-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>gcloud-java-core</site.installationModule>

branches/update-datastore/gcloud-java-core/src/main/java/com/google/gcloud/AuthCredentials.java

Lines changed: 3 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@
1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
22-
import com.google.api.client.googleapis.compute.ComputeCredential;
23-
import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential;
24-
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
2522
import com.google.api.client.http.HttpRequestInitializer;
2623
import com.google.api.client.http.HttpTransport;
27-
import com.google.api.client.http.javanet.NetHttpTransport;
2824
import com.google.api.client.json.jackson.JacksonFactory;
2925
import com.google.auth.http.HttpCredentialsAdapter;
3026
import com.google.auth.oauth2.GoogleCredentials;
31-
import com.google.auth.oauth2.ServiceAccountCredentials;
3227

3328
import java.io.IOException;
3429
import java.io.InputStream;
3530
import java.io.Serializable;
36-
import java.security.GeneralSecurityException;
3731
import java.security.PrivateKey;
3832
import java.util.Objects;
3933
import java.util.Set;
@@ -43,45 +37,6 @@
4337
*/
4438
public abstract class AuthCredentials implements Restorable<AuthCredentials> {
4539

46-
private static class AppEngineAuthCredentials extends AuthCredentials {
47-
48-
private static final AuthCredentials INSTANCE = new AppEngineAuthCredentials();
49-
private static final AppEngineAuthCredentialsState STATE =
50-
new AppEngineAuthCredentialsState();
51-
52-
private static class AppEngineAuthCredentialsState
53-
implements RestorableState<AuthCredentials>, Serializable {
54-
55-
private static final long serialVersionUID = 3558563960848658928L;
56-
57-
@Override
58-
public AuthCredentials restore() {
59-
return INSTANCE;
60-
}
61-
62-
@Override
63-
public int hashCode() {
64-
return getClass().getName().hashCode();
65-
}
66-
67-
@Override
68-
public boolean equals(Object obj) {
69-
return obj instanceof AppEngineAuthCredentialsState;
70-
}
71-
}
72-
73-
@Override
74-
protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
75-
Set<String> scopes) {
76-
return new AppIdentityCredential(scopes);
77-
}
78-
79-
@Override
80-
public RestorableState<AuthCredentials> capture() {
81-
return STATE;
82-
}
83-
}
84-
8540
public static class ServiceAccountAuthCredentials extends AuthCredentials {
8641

8742
private final String account;
@@ -164,56 +119,7 @@ public RestorableState<AuthCredentials> capture() {
164119
}
165120
}
166121

167-
private static class ComputeEngineAuthCredentials extends AuthCredentials {
168-
169-
private ComputeCredential computeCredential;
170-
171-
private static final ComputeEngineAuthCredentialsState STATE =
172-
new ComputeEngineAuthCredentialsState();
173-
174-
private static class ComputeEngineAuthCredentialsState
175-
implements RestorableState<AuthCredentials>, Serializable {
176-
177-
private static final long serialVersionUID = -6168594072854417404L;
178-
179-
@Override
180-
public AuthCredentials restore() {
181-
try {
182-
return new ComputeEngineAuthCredentials();
183-
} catch (IOException | GeneralSecurityException e) {
184-
throw new IllegalStateException(
185-
"Could not restore " + ComputeEngineAuthCredentials.class.getSimpleName(), e);
186-
}
187-
}
188-
189-
@Override
190-
public int hashCode() {
191-
return getClass().getName().hashCode();
192-
}
193-
194-
@Override
195-
public boolean equals(Object obj) {
196-
return obj instanceof ComputeEngineAuthCredentialsState;
197-
}
198-
}
199-
200-
ComputeEngineAuthCredentials() throws IOException, GeneralSecurityException {
201-
computeCredential = getComputeCredential();
202-
}
203-
204-
@Override
205-
protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
206-
Set<String> scopes) {
207-
return computeCredential;
208-
}
209-
210-
@Override
211-
public RestorableState<AuthCredentials> capture() {
212-
return STATE;
213-
}
214-
}
215-
216-
public static class ApplicationDefaultAuthCredentials extends AuthCredentials {
122+
private static class ApplicationDefaultAuthCredentials extends AuthCredentials {
217123

218124
private GoogleCredentials googleCredentials;
219125

@@ -253,16 +159,7 @@ public boolean equals(Object obj) {
253159
@Override
254160
protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
255161
Set<String> scopes) {
256-
return new HttpCredentialsAdapter(googleCredentials.createScoped(scopes));
257-
}
258-
259-
public ServiceAccountAuthCredentials toServiceAccountCredentials() {
260-
if (googleCredentials instanceof ServiceAccountCredentials) {
261-
ServiceAccountCredentials credentials = (ServiceAccountCredentials) googleCredentials;
262-
return new ServiceAccountAuthCredentials(credentials.getClientEmail(),
263-
credentials.getPrivateKey());
264-
}
265-
return null;
162+
return new HttpCredentialsAdapter(googleCredentials);
266163
}
267164

268165
@Override
@@ -274,21 +171,12 @@ public RestorableState<AuthCredentials> capture() {
274171
protected abstract HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
275172
Set<String> scopes);
276173

277-
public static AuthCredentials createForAppEngine() {
278-
return AppEngineAuthCredentials.INSTANCE;
279-
}
280-
281-
public static AuthCredentials createForComputeEngine()
282-
throws IOException, GeneralSecurityException {
283-
return new ComputeEngineAuthCredentials();
284-
}
285-
286174
/**
287175
* Returns the Application Default Credentials.
288176
*
289177
* <p>Returns the Application Default Credentials which are credentials that identify and
290178
* authorize the whole application. This is the built-in service account if running on
291-
* Google Compute Engine or the credentials file can be read from the path in the environment
179+
* Google App/Compute Engine or the credentials file can be read from the path in the environment
292180
* variable GOOGLE_APPLICATION_CREDENTIALS.
293181
* </p>
294182
*
@@ -337,13 +225,4 @@ public static ServiceAccountAuthCredentials createForJson(InputStream jsonCreden
337225
public static AuthCredentials noCredentials() {
338226
return ServiceAccountAuthCredentials.NO_CREDENTIALS;
339227
}
340-
341-
static ComputeCredential getComputeCredential() throws IOException, GeneralSecurityException {
342-
NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
343-
// Try to connect using Google Compute Engine service account credentials.
344-
ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());
345-
// Force token refresh to detect if we are running on Google Compute Engine.
346-
credential.refreshToken();
347-
return credential;
348-
}
349228
}

branches/update-datastore/gcloud-java-core/src/main/java/com/google/gcloud/ExceptionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ void verifyCaller(Callable<?> callable) {
231231
}
232232
}
233233

234-
public Set<Class<? extends Exception>> retriableExceptions() {
234+
public Set<Class<? extends Exception>> getRetriableExceptions() {
235235
return retriableExceptions;
236236
}
237237

238-
public Set<Class<? extends Exception>> nonRetriableExceptions() {
238+
public Set<Class<? extends Exception>> getNonRetriableExceptions() {
239239
return nonRetriableExceptions;
240240
}
241241

@@ -262,7 +262,7 @@ boolean shouldRetry(Exception ex) {
262262
/**
263263
* Returns an instance which retry any checked exception and abort on any runtime exception.
264264
*/
265-
public static ExceptionHandler defaultInstance() {
265+
public static ExceptionHandler getDefaultInstance() {
266266
return DEFAULT_INSTANCE;
267267
}
268268

0 commit comments

Comments
 (0)