From 68408bf96f704b094f9c709a833e0d99f7afc007 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 12 Oct 2015 10:14:30 -0700 Subject: [PATCH 1/4] Standardize readme files --- README.md | 55 +++++++++++++++++++-------------- gcloud-java-core/README.md | 12 +++---- gcloud-java-datastore/README.md | 40 ++++++++++++++++-------- gcloud-java-examples/README.md | 15 ++++----- gcloud-java-storage/README.md | 42 ++++++++++++++++--------- 5 files changed, 100 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 48eb4e8f90ca..34a238460747 100644 --- a/README.md +++ b/README.md @@ -9,17 +9,12 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services. - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) This client supports the following Google Cloud Platform services: - [Google Cloud Datastore] (#google-cloud-datastore) - [Google Cloud Storage] (#google-cloud-storage) - - > Note: This client is a work-in-progress, and may occasionally > make backwards-incompatible changes. @@ -34,13 +29,23 @@ Add this to your pom.xml file ``` - +- [`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) - A simple command line interface for the Cloud Datastore + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html). +- [`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality + - Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html). + +Authentication +-------------- + +There are multiple ways to authenticate to use Google Cloud services. + +1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary. +2. When using `gcloud-java` libraries elsewhere, there are two options: + * [Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). Supply a path to the downloaded JSON credentials file when building the options supplied to datastore/storage constructor. + * If running locally for development/testing, you can use use [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK authentication, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already. Then login using the SDK (`gcloud auth login` in command line), and set your current project using `gcloud config set project PROJECT_ID`. Google Cloud Datastore ---------------------- @@ -57,6 +62,8 @@ Cloud Datastore for your project. See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact with the Cloud Datastore using this Client Library. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) if running this snippet elsewhere. + ```java import com.google.gcloud.datastore.Datastore; import com.google.gcloud.datastore.DatastoreFactory; @@ -101,6 +108,8 @@ Cloud Storage for your project. See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact with the Cloud Storage using this Client Library. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) if running this snippet elsewhere. + ```java import static java.nio.charset.StandardCharsets.UTF_8; @@ -127,6 +136,11 @@ if (!blob.exists()) { } ``` +Java Versions +------------- + +Java 7 or above is required for using this client. + Testing ------- @@ -134,20 +148,6 @@ This library provides tools to help write tests for code that uses gcloud-java s See [TESTING] to read more about using our testing helpers. -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - -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. - -Java Versions -------------- - -Java 7 or above is required for using this client. - Versioning ---------- @@ -157,6 +157,15 @@ It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable. +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + +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. + License ------- diff --git a/gcloud-java-core/README.md b/gcloud-java-core/README.md index 2b89014e41e4..e8b0191e7e3d 100644 --- a/gcloud-java-core/README.md +++ b/gcloud-java-core/README.md @@ -5,10 +5,10 @@ This module provides common functionality required by service-specific modules o [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg)](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-core.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/package-summary.html) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) Quickstart ---------- @@ -21,6 +21,11 @@ Add this to your pom.xml file ``` +Java Versions +------------- + +Java 7 or above is required for using this client. + Contributing ------------ @@ -28,11 +33,6 @@ Contributions to this library are always welcome and highly encouraged. See [CONTRIBUTING] for more information on how to get started. -Java Versions -------------- - -Java 7 or above is required for using this client. - Versioning ---------- diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index ebb94863c068..dc8dd2a5a0c8 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -5,10 +5,10 @@ Java idiomatic client for [Google Cloud Datastore] (https://cloud.google.com/dat [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-datastore.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-datastore.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/datastore/package-summary.html) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html) > Note: This client is a work-in-progress, and may occasionally > make backwards-incompatible changes. @@ -24,6 +24,18 @@ Add this to your pom.xml file ``` +Example Application +-------------------- +[`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) is a simple command line interface for the Cloud Datastore. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html). + +Authentication +-------------- + +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README. + +About Google Cloud Datastore +---------------------------- + Google [Cloud Datastore][cloud-datastore] is a fully managed, schemaless database for storing non-relational data. Cloud Datastore automatically scales with your users and supports ACID transactions, high availability of reads and @@ -36,6 +48,8 @@ Cloud Datastore for your project. See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact with the Cloud Datastore using this Client Library. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere. + ```java import com.google.gcloud.datastore.Datastore; import com.google.gcloud.datastore.DatastoreFactory; @@ -66,6 +80,11 @@ if (entity == null) { } ``` +Java Versions +------------- + +Java 7 or above is required for using this client. + Testing ------- @@ -73,18 +92,6 @@ This library has tools to help write tests for code that uses the Datastore. See [TESTING] to read more about testing. -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - -Java Versions -------------- - -Java 7 or above is required for using this client. - Versioning ---------- @@ -94,6 +101,13 @@ It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable. +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + License ------- diff --git a/gcloud-java-examples/README.md b/gcloud-java-examples/README.md index 991e0ef5fd91..671af870b63e 100644 --- a/gcloud-java-examples/README.md +++ b/gcloud-java-examples/README.md @@ -5,6 +5,7 @@ Examples for gcloud-java (Java idiomatic client for [Google Cloud Platform][clou [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-examples.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-examples.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) @@ -49,13 +50,6 @@ To run examples from your command line: $mvn exec:java -Dexec.mainClass="com.google.gcloud.examples.StorageExample" -Dexec.args="delete test.txt" ``` -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - Java Versions ------------- @@ -70,6 +64,13 @@ It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable. +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + License ------- diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index 909fc7abfacc..bf3b7deafed4 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -5,10 +5,10 @@ Java idiomatic client for [Google Cloud Storage] (https://cloud.google.com/stora [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-storage.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java-storage.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html) > Note: This client is a work-in-progress, and may occasionally > make backwards-incompatible changes. @@ -24,8 +24,18 @@ Add this to your pom.xml file ``` -Google Cloud Storage ----------------------- +Example Application +------------------- + +[`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) is a simple command line interface that provides some of Cloud Storage's functionality. Read more about using the application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html). + +Authentication +-------------- + +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README. + +About Google Cloud Storage +-------------------------- [Google Cloud Storage][cloud-storage] is a durable and highly available object storage service. Google Cloud Storage is almost infinitely scalable @@ -38,6 +48,8 @@ Cloud Storage for your project. See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact with the Cloud Storage using this Client Library. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere. + ```java import static java.nio.charset.StandardCharsets.UTF_8; @@ -64,6 +76,11 @@ if (!blob.exists()) { } ``` +Java Versions +------------- + +Java 7 or above is required for using this client. + Testing ------- @@ -71,18 +88,6 @@ This library has tools to help make tests for code using Cloud Storage. See [TESTING] to read more about testing. -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - -Java Versions -------------- - -Java 7 or above is required for using this client. - Versioning ---------- @@ -92,6 +97,13 @@ It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable. +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + License ------- From 41a2a7a32099540ef3637aeeefafee666f5f0bf9 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 12 Oct 2015 11:01:40 -0700 Subject: [PATCH 2/4] Standardize gcloud-java/gcloud-java/README --- gcloud-java/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gcloud-java/README.md b/gcloud-java/README.md index a933f06f7f05..868f93a09a49 100644 --- a/gcloud-java/README.md +++ b/gcloud-java/README.md @@ -5,10 +5,10 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services. [![Build Status](https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/gcloud-java) [![Coverage Status](https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master)](https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master) +[![Maven](https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg)]( https://img.shields.io/maven-central/v/com.google.gcloud/gcloud-java.svg) - [Homepage] (https://googlecloudplatform.github.io/gcloud-java/) - [API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs) -- [Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html) This client supports the following Google Cloud Platform services: @@ -29,13 +29,6 @@ Add this to your pom.xml file ``` -Contributing ------------- - -Contributions to this library are always welcome and highly encouraged. - -See [CONTRIBUTING] for more information on how to get started. - Java Versions ------------- @@ -50,6 +43,13 @@ It is currently in major version zero (``0.y.z``), which means that anything may change at any time and the public API should not be considered stable. +Contributing +------------ + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING] for more information on how to get started. + License ------- From e868ca3bd9599cb8e94aa3eebb65e581cba3c4b1 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 12 Oct 2015 11:26:23 -0700 Subject: [PATCH 3/4] Update README.md Removing duplicated description and project ID from code snippets. --- README.md | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 34a238460747..4bd3c34d2e8c 100644 --- a/README.md +++ b/README.md @@ -50,19 +50,14 @@ There are multiple ways to authenticate to use Google Cloud services. Google Cloud Datastore ---------------------- -[Google Cloud Datastore][cloud-datastore] is a fully managed, schemaless database for -storing non-relational data. Cloud Datastore automatically scales with -your users and supports ACID transactions, high availability of reads and -writes, strong consistency for reads and ancestor queries, and eventual -consistency for all other queries. +- [API Documentation][datastore-api] +- [Official Documentation][cloud-datastore-docs] -See the [Google Cloud Datastore docs][cloud-datastore-activation] for more details on how to activate -Cloud Datastore for your project. +*Follow the [activation instructions][cloud-datastore-activation] to use the Google Cloud Datastore API with your project.* -See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact -with the Cloud Datastore using this Client Library. +#### Preview -Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) if running this snippet elsewhere. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere. ```java import com.google.gcloud.datastore.Datastore; @@ -73,7 +68,7 @@ import com.google.gcloud.datastore.Entity; import com.google.gcloud.datastore.Key; import com.google.gcloud.datastore.KeyFactory; -DatastoreOptions options = DatastoreOptions.builder().projectId(PROJECT_ID).build(); +DatastoreOptions options = DatastoreOptions.builder().build(); Datastore datastore = DatastoreFactory.instance().get(options); KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND); Key key = keyFactory.newKey(keyName); @@ -97,18 +92,14 @@ if (entity == null) { Google Cloud Storage ---------------------- -[Google Cloud Storage][cloud-storage] is a durable and highly available -object storage service. Google Cloud Storage is almost infinitely scalable -and guarantees consistency: when a write succeeds, the latest copy of the -object will be returned to any GET, globally. +- [API Documentation][storage-api] +- [Official Documentation][cloud-storage-docs] -See the [Google Cloud Storage docs][cloud-storage-activation] for more details on how to activate -Cloud Storage for your project. +*Follow the [activation instructions][cloud-storage-activation] to use the Google Cloud Storage API with your project.* -See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact -with the Cloud Storage using this Client Library. +#### Preview -Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) if running this snippet elsewhere. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](#authentication) and a project ID if running this snippet elsewhere. ```java import static java.nio.charset.StandardCharsets.UTF_8; @@ -121,7 +112,7 @@ import com.google.gcloud.storage.StorageOptions; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; -StorageOptions options = StorageOptions.builder().projectId(PROJECT_ID).build(); +StorageOptions options = StorageOptions.builder().build(); Storage storage = StorageFactory.instance().get(options); Blob blob = new Blob(storage, "bucket", "blob_name"); if (!blob.exists()) { From ea493d59ffbf420fc091062723da12af97432991 Mon Sep 17 00:00:00 2001 From: Ajay Kannan Date: Mon, 12 Oct 2015 11:38:52 -0700 Subject: [PATCH 4/4] simplify code snippets --- README.md | 6 ++---- gcloud-java-datastore/README.md | 7 +++---- gcloud-java-storage/README.md | 7 +++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4bd3c34d2e8c..c0edb57fbf37 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,7 @@ import com.google.gcloud.datastore.Entity; import com.google.gcloud.datastore.Key; import com.google.gcloud.datastore.KeyFactory; -DatastoreOptions options = DatastoreOptions.builder().build(); -Datastore datastore = DatastoreFactory.instance().get(options); +Datastore datastore = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance()); KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND); Key key = keyFactory.newKey(keyName); Entity entity = datastore.get(key); @@ -112,8 +111,7 @@ import com.google.gcloud.storage.StorageOptions; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; -StorageOptions options = StorageOptions.builder().build(); -Storage storage = StorageFactory.instance().get(options); +Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance()); Blob blob = new Blob(storage, "bucket", "blob_name"); if (!blob.exists()) { storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8)); diff --git a/gcloud-java-datastore/README.md b/gcloud-java-datastore/README.md index dc8dd2a5a0c8..572b5fa009d4 100644 --- a/gcloud-java-datastore/README.md +++ b/gcloud-java-datastore/README.md @@ -31,7 +31,7 @@ Example Application Authentication -------------- -See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README. +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. About Google Cloud Datastore ---------------------------- @@ -48,7 +48,7 @@ Cloud Datastore for your project. See the ``gcloud-java`` API [datastore documentation][datastore-api] to learn how to interact with the Cloud Datastore using this Client Library. -Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere. ```java import com.google.gcloud.datastore.Datastore; @@ -59,8 +59,7 @@ import com.google.gcloud.datastore.Entity; import com.google.gcloud.datastore.Key; import com.google.gcloud.datastore.KeyFactory; -DatastoreOptions options = DatastoreOptions.builder().projectId(PROJECT_ID).build(); -Datastore datastore = DatastoreFactory.instance().get(options); +Datastore datastore = DatastoreFactory.instance().get(DatastoreOptions.getDefaultInstance()); KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND); Key key = keyFactory.newKey(keyName); Entity entity = datastore.get(key); diff --git a/gcloud-java-storage/README.md b/gcloud-java-storage/README.md index bf3b7deafed4..65ab1cca2dd8 100644 --- a/gcloud-java-storage/README.md +++ b/gcloud-java-storage/README.md @@ -32,7 +32,7 @@ Example Application Authentication -------------- -See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the main repository's README. +See the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) section in the base directory's README. About Google Cloud Storage -------------------------- @@ -48,7 +48,7 @@ Cloud Storage for your project. See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact with the Cloud Storage using this Client Library. -Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) if running this snippet elsewhere. +Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere. ```java import static java.nio.charset.StandardCharsets.UTF_8; @@ -61,8 +61,7 @@ import com.google.gcloud.storage.StorageOptions; import java.nio.ByteBuffer; import java.nio.channels.WritableByteChannel; -StorageOptions options = StorageOptions.builder().projectId(PROJECT_ID).build(); -Storage storage = StorageFactory.instance().get(options); +Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance()); Blob blob = new Blob(storage, "bucket", "blob_name"); if (!blob.exists()) { storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));