|
1 | | -Google Cloud for Java |
2 | | -===================== |
| 1 | +Google Cloud Java Client |
| 2 | +========================== |
| 3 | + |
| 4 | +Java idiomatic client for [Google Cloud Platform][cloud-platform] services. |
3 | 5 |
|
4 | 6 | [](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) |
5 | 7 | [](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) |
6 | 8 |
|
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: |
8 | 14 |
|
9 | | - * Google Cloud Datastore |
| 15 | +- [Google Cloud Datastore] (https://cloud.google.com/datastore/) |
10 | 16 |
|
| 17 | +<!--- |
| 18 | +- [Google Cloud Storage] (https://cloud.google.com/storage/) |
| 19 | +---> |
11 | 20 |
|
12 | | -> Note: This package is a work-in-progress, and may occasionally |
| 21 | +> Note: This client is a work-in-progress, and may occasionally |
13 | 22 | > make backwards-incompatible changes. |
14 | 23 |
|
| 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 | +-------------------- |
15 | 38 |
|
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 | +---> |
17 | 42 |
|
18 | | -## Google Cloud Datastore |
| 43 | +Google Cloud Datastore |
| 44 | +---------------------- |
19 | 45 |
|
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 |
24 | 50 | consistency for all other queries. |
25 | 51 |
|
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. |
28 | 57 |
|
29 | 58 | ```java |
30 | 59 | import com.google.gcloud.datastore.DatastoreService; |
31 | 60 | import com.google.gcloud.datastore.DatastoreServiceFactory; |
32 | 61 | import com.google.gcloud.datastore.DatastoreServiceOptions; |
| 62 | +import com.google.gcloud.datastore.DateTime; |
33 | 63 | import com.google.gcloud.datastore.Entity; |
34 | 64 | import com.google.gcloud.datastore.Key; |
35 | 65 | import com.google.gcloud.datastore.KeyFactory; |
36 | 66 |
|
37 | | -DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset("...").build(); |
| 67 | +DatastoreServiceOptions options = DatastoreServiceOptions.builder().dataset(DATASET).build(); |
38 | 68 | DatastoreService datastore = DatastoreServiceFactory.getDefault(options); |
39 | | -KeyFactory keyFactory = new KeyFactory(datastore).kind("..."); |
| 69 | +KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND); |
40 | 70 | Key key = keyFactory.newKey(keyName); |
41 | 71 | Entity entity = datastore.get(key); |
42 | 72 | if (entity == null) { |
43 | 73 | entity = Entity.builder(key) |
44 | 74 | .set("name", "John Do") |
45 | 75 | .set("age", 30) |
46 | | - .set("updated", false) |
| 76 | + .set("access_time", DateTime.now()) |
47 | 77 | .build(); |
48 | 78 | 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); |
49 | 85 | } |
50 | 86 | ``` |
51 | 87 |
|
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. |
53 | 113 |
|
54 | | -Contributions are welcome. Please, see the |
55 | | -[CONTRIBUTING](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md) |
56 | | -document for details. |
57 | 114 |
|
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 |
59 | 119 | [cloud-datastore-docs]: https://cloud.google.com/datastore/docs |
60 | 120 | [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 |
61 | 122 |
|
62 | 123 | [cloud-pubsub]: https://cloud.google.com/pubsub/ |
63 | 124 | [cloud-pubsub-docs]: https://cloud.google.com/pubsub/docs |
|
0 commit comments