Skip to content

Commit d095a5a

Browse files
committed
---
yaml --- r: 175 b: refs/heads/master c: 7ec1eb0 h: refs/heads/master i: 173: fba1b64 171: 830999b 167: 2bcbeeb 159: 1fbee25 v: v3
1 parent a4dc687 commit d095a5a

89 files changed

Lines changed: 1876 additions & 1340 deletions

File tree

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
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 22fc5693ee14027489c4c5780cb2837c682832e9
2+
refs/heads/master: 7ec1eb0e602d713da4352bcf054481e0f38b0005

trunk/.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nguage: java
1+
language: java
22
jdk:
33
- oraclejdk8
44
- oraclejdk7
@@ -7,8 +7,8 @@ before_install:
77
- mvn clean
88
- git clone -b travis `git config --get remote.origin.url` target/travis
99
- cp target/travis/settings.xml ~/.m2/settings.xml
10-
install: mvn install -Dgpg.skip=true
11-
script: mvn verify -Dgpg.skip=true
10+
install: mvn install
11+
script: mvn verify
1212
branches:
1313
only:
1414
- master

trunk/README.md

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,124 @@
1-
Google Cloud for Java
2-
=====================
1+
Google Cloud Java Client
2+
==========================
3+
4+
Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
35

46
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java)
57
[![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master)
68

7-
Java idiomatic client for Google Cloud Platform services. Supported APIs include:
9+
- [Homepage] (https://googlecloudplatform.github.io/gcloud-java/)
10+
- [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs)
11+
- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html)
12+
13+
This client supports the following Google Cloud Platform services:
814

9-
* Google Cloud Datastore
15+
- [Google Cloud Datastore] (https://cloud.google.com/datastore/)
1016

17+
<!---
18+
- [Google Cloud Storage] (https://cloud.google.com/storage/)
19+
--->
1120

12-
> Note: This package is a work-in-progress, and may occasionally
21+
> Note: This client is a work-in-progress, and may occasionally
1322
> make backwards-incompatible changes.
1423
24+
Quickstart
25+
----------
26+
Add this to your pom.xml file
27+
```xml
28+
<dependency>
29+
<groupId>com.google.gcloud</groupId>
30+
<artifactId>gcloud-java</artifactId>
31+
<version>LATEST</version>
32+
</dependency>
33+
```
34+
35+
<!---
36+
Example Applications
37+
--------------------
1538
16-
Documentation and examples are available [here](http://googlecloudplatform.github.io/gcloud-java/apidocs).
39+
- `java-datastore-sample`_ - A sample using Cloud Datastore
40+
.. _java-datastore-sample: https://github.com/GoogleCloudPlatform/java-datastore-sample
41+
--->
1742

18-
## Google Cloud Datastore
43+
Google Cloud Datastore
44+
----------------------
1945

20-
[Google Cloud Datastore][cloud-datastore] ([docs][cloud-datastore-docs]) is a fully
21-
managed, schemaless database for storing non-relational data. Cloud Datastore
22-
automatically scales with your users and supports ACID transactions, high availability
23-
of reads and writes, strong consistency for reads and ancestor queries, and eventual
46+
Google [Cloud Datastore][cloud-datastore] is a fully managed, schemaless database for
47+
storing non-relational data. Cloud Datastore automatically scales with
48+
your users and supports ACID transactions, high availability of reads and
49+
writes, strong consistency for reads and ancestor queries, and eventual
2450
consistency for all other queries.
2551

26-
Follow the [activation instructions][cloud-datastore-activation] to use the Google
27-
Cloud Datastore API with your project.
52+
See the [Google Cloud Datastore docs][cloud-datastore-activation] for more details on how to activate
53+
Cloud Datastore for your project.
54+
55+
See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact
56+
with the Cloud Datastore using this Client Library.
2857

2958
```java
3059
import com.google.gcloud.datastore.DatastoreService;
3160
import com.google.gcloud.datastore.DatastoreServiceFactory;
3261
import com.google.gcloud.datastore.DatastoreServiceOptions;
62+
import com.google.gcloud.datastore.DateTime;
3363
import com.google.gcloud.datastore.Entity;
3464
import com.google.gcloud.datastore.Key;
3565
import com.google.gcloud.datastore.KeyFactory;
3666

37-
DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build();
67+
DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset(DATASET).build();
3868
DatastoreService datastore = DatastoreServiceFactory.getDefault(options);
39-
KeyFactory keyFactory = new KeyFactory(datastore).kind("...");
69+
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
4070
Key key = keyFactory.newKey(keyName);
4171
Entity entity = datastore.get(key);
4272
if (entity == null) {
4373
entity = Entity.builder(key)
4474
.set("name", "John Do")
4575
.set("age", 30)
46-
.set("updated", false)
76+
.set("access_time", DateTime.now())
4777
.build();
4878
datastore.put(entity);
79+
} else {
80+
System.out.println("Updating access_time for " + entity.getString("name"));
81+
entity = Entity.builder(entity)
82+
.set("access_time", DateTime.now())
83+
.build();
84+
datastore.update(entity);
4985
}
5086
```
5187

52-
## Contributing
88+
Contributing
89+
------------
90+
91+
Contributions to this library are always welcome and highly encouraged.
92+
93+
See [CONTRIBUTING] for more information on how to get started.
94+
95+
Java Versions
96+
-------------
97+
98+
Java 7 or above is required for using this client.
99+
100+
Versioning
101+
----------
102+
103+
This library follows [Semantic Versioning] (http://semver.org/).
104+
105+
It is currently in major version zero (``0.y.z``), which means that anything
106+
may change at any time and the public API should not be considered
107+
stable.
108+
109+
License
110+
-------
111+
112+
Apache 2.0 - See [LICENSE] for more information.
53113

54-
Contributions are welcome. Please, see the
55-
[CONTRIBUTING](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md)
56-
document for details.
57114

58-
[cloud-datastore]: https://cloud.google.com/datastore/
115+
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
116+
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
117+
[cloud-platform]: https://cloud.google.com/
118+
[cloud-datastore]: https://cloud.google.com/datastore/docs
59119
[cloud-datastore-docs]: https://cloud.google.com/datastore/docs
60120
[cloud-datastore-activation]: https://cloud.google.com/datastore/docs/activate
121+
[datastore-api]: http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/datastore/package-summary.html
61122

62123
[cloud-pubsub]: https://cloud.google.com/pubsub/
63124
[cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs

trunk/pom.xml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.google.gcloud</groupId>
55
<artifactId>gcloud-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.0.1</version>
7+
<version>0.0.4</version>
88
<name>GCloud Java</name>
99
<url>https://github.com/GoogleCloudPlatform/gcloud-java</url>
1010
<description>
@@ -49,6 +49,16 @@
4949
</repository>
5050
</distributionManagement>
5151
<dependencies>
52+
<dependency>
53+
<groupId>com.google.auth</groupId>
54+
<artifactId>google-auth-library-credentials</artifactId>
55+
<version>0.1.0</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>com.google.auth</groupId>
59+
<artifactId>google-auth-library-oauth2-http</artifactId>
60+
<version>0.1.0</version>
61+
</dependency>
5262
<dependency>
5363
<groupId>com.google.http-client</groupId>
5464
<artifactId>google-http-client</artifactId>
@@ -69,7 +79,7 @@
6979
<dependency>
7080
<groupId>com.google.apis</groupId>
7181
<artifactId>google-api-services-datastore-protobuf</artifactId>
72-
<version>v1beta2-rev1-2.1.0</version>
82+
<version>v1beta2-rev1-2.1.2</version>
7383
<scope>compile</scope>
7484
</dependency>
7585
<dependency>
@@ -156,6 +166,26 @@
156166
</pluginRepositories>
157167
<build>
158168
<plugins>
169+
<plugin>
170+
<groupId>org.codehaus.mojo</groupId>
171+
<artifactId>exec-maven-plugin</artifactId>
172+
<version>1.3.2</version>
173+
<executions>
174+
<execution>
175+
<goals>
176+
<goal>java</goal>
177+
</goals>
178+
</execution>
179+
</executions>
180+
<configuration>
181+
<!--
182+
to get rid of the warning: [WARNING] Warning: killAfter is now deprecated. Do you need it ?
183+
Please comment on MEXEC-6. see: method execute() in
184+
https://github.com/ispringer/exec-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/exec/ExecJavaMojo.java
185+
-->
186+
<killAfter>-1</killAfter>
187+
</configuration>
188+
</plugin>
159189
<plugin>
160190
<groupId>org.apache.maven.plugins</groupId>
161191
<artifactId>maven-failsafe-plugin</artifactId>
@@ -196,6 +226,7 @@
196226
<source>1.7</source>
197227
<target>1.7</target>
198228
<encoding>UTF-8</encoding>
229+
<compilerArgument>-Xlint:unchecked</compilerArgument>
199230
</configuration>
200231
</plugin>
201232
<plugin>
@@ -231,7 +262,7 @@
231262
<executions>
232263
<execution>
233264
<id>sign-artifacts</id>
234-
<phase>verify</phase>
265+
<phase>deploy</phase>
235266
<goals>
236267
<goal>sign</goal>
237268
</goals>
@@ -269,6 +300,9 @@
269300
<includes>
270301
<include>com/google/gcloud/**/*.class</include>
271302
</includes>
303+
<excludes>
304+
<exclude>com/google/gcloud/examples/**/*.class</exclude>
305+
</excludes>
272306
</instrumentation>
273307
<check />
274308
<maxmem>256m</maxmem>

trunk/src/main/java/com/google/gcloud/AuthConfig.java renamed to trunk/src/main/java/com/google/gcloud/AuthCredentials.java

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@
2626
import com.google.api.client.http.HttpTransport;
2727
import com.google.api.client.http.javanet.NetHttpTransport;
2828
import com.google.api.client.json.jackson.JacksonFactory;
29+
import com.google.auth.http.HttpCredentialsAdapter;
30+
import com.google.auth.oauth2.GoogleCredentials;
2931

3032
import java.io.IOException;
3133
import java.security.GeneralSecurityException;
3234
import java.security.PrivateKey;
3335
import java.util.Set;
3436

35-
public abstract class AuthConfig {
37+
/**
38+
* Credentials for accessing Google Cloud services.
39+
*/
40+
public abstract class AuthCredentials {
3641

37-
private static class AppEngineAuthConfig extends AuthConfig {
42+
private static class AppEngineAuthCredentials extends AuthCredentials {
3843

3944
@Override
4045
protected HttpRequestInitializer httpRequestInitializer(
@@ -43,17 +48,17 @@ protected HttpRequestInitializer httpRequestInitializer(
4348
}
4449
}
4550

46-
private static class ServiceAccountAuthConfig extends AuthConfig {
51+
private static class ServiceAccountAuthCredentials extends AuthCredentials {
4752

4853
private final String account;
4954
private final PrivateKey privateKey;
5055

51-
ServiceAccountAuthConfig(String account, PrivateKey privateKey) {
56+
ServiceAccountAuthCredentials(String account, PrivateKey privateKey) {
5257
this.account = checkNotNull(account);
5358
this.privateKey = checkNotNull(privateKey);
5459
}
5560

56-
ServiceAccountAuthConfig() {
61+
ServiceAccountAuthCredentials() {
5762
account = null;
5863
privateKey = null;
5964
}
@@ -76,13 +81,14 @@ protected HttpRequestInitializer httpRequestInitializer(
7681
protected abstract HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
7782
Set<String> scopes);
7883

79-
public static AuthConfig createForAppEngine() {
80-
return new AppEngineAuthConfig();
84+
public static AuthCredentials createForAppEngine() {
85+
return new AppEngineAuthCredentials();
8186
}
8287

83-
public static AuthConfig createForComputeEngine() throws IOException, GeneralSecurityException {
88+
public static AuthCredentials createForComputeEngine()
89+
throws IOException, GeneralSecurityException {
8490
final ComputeCredential cred = getComputeCredential();
85-
return new AuthConfig() {
91+
return new AuthCredentials() {
8692
@Override
8793
protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
8894
Set<String> scopes) {
@@ -91,12 +97,34 @@ protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
9197
};
9298
}
9399

94-
public static AuthConfig createFor(String account, PrivateKey privateKey) {
95-
return new ServiceAccountAuthConfig(account, privateKey);
100+
/**
101+
* Returns the Application Default Credentials.
102+
*
103+
* <p>Returns the Application Default Credentials which are credentials that identify and
104+
* authorize the whole application. This is the built-in service account if running on Google
105+
* Compute Engine or the credentials file from the path in the environment variable
106+
* GOOGLE_APPLICATION_CREDENTIALS.</p>
107+
*
108+
* @return the credentials instance.
109+
* @throws IOException if the credentials cannot be created in the current environment.
110+
*/
111+
public static AuthCredentials createApplicationDefaults() throws IOException {
112+
final GoogleCredentials credentials = GoogleCredentials.getApplicationDefault();
113+
return new AuthCredentials() {
114+
@Override
115+
protected HttpRequestInitializer httpRequestInitializer(HttpTransport transport,
116+
Set<String> scopes) {
117+
return new HttpCredentialsAdapter(credentials);
118+
}
119+
};
120+
}
121+
122+
public static AuthCredentials createFor(String account, PrivateKey privateKey) {
123+
return new ServiceAccountAuthCredentials(account, privateKey);
96124
}
97125

98-
public static AuthConfig noCredentials() {
99-
return new ServiceAccountAuthConfig();
126+
public static AuthCredentials noCredentials() {
127+
return new ServiceAccountAuthCredentials();
100128
}
101129

102130
static ComputeCredential getComputeCredential() throws IOException, GeneralSecurityException {

0 commit comments

Comments
 (0)