From 0d6353f03ab7b4b7e07cdb5ae9c1767ee15759d8 Mon Sep 17 00:00:00 2001 From: Tianzi Cai Date: Mon, 20 Sep 2021 12:08:22 -0700 Subject: [PATCH 1/2] docs(samples): add readme --- samples/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 samples/README.md diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 000000000..e3f4b6c98 --- /dev/null +++ b/samples/README.md @@ -0,0 +1,20 @@ +# How to run the samples + +1. Clone this repo and navigate to the `snippets` directory. + ```shell + git clone https://github.com/googlepis/java-pubsub + cd java-pubsub/samples/snippets + ``` + +1. With [Maven] installed and the environment variable `GOOGLE_APPLICATION_CREDENTIALS` set to point to your [GCP service account] key file, run a sample that has the to-do section completed: + ```shell + mvn clean compile exec:java -Dexec.mainClass=pubsub.CreateTopicExample + ``` + +1. To run the samples test: + ```shell + mvn -Dtest=pubsub.AdminIT test + ``` + +[Maven]: https://maven.apache.org/ +[GCP Service account]: https://cloud.google.com/iam/docs/service-accounts From 4cc28e382d77d79cafafd99efe00f369971cc573 Mon Sep 17 00:00:00 2001 From: Tianzi Cai Date: Mon, 20 Sep 2021 13:42:46 -0700 Subject: [PATCH 2/2] address reviewer comments --- samples/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/README.md b/samples/README.md index e3f4b6c98..5656f6f4d 100644 --- a/samples/README.md +++ b/samples/README.md @@ -6,7 +6,12 @@ cd java-pubsub/samples/snippets ``` -1. With [Maven] installed and the environment variable `GOOGLE_APPLICATION_CREDENTIALS` set to point to your [GCP service account] key file, run a sample that has the to-do section completed: +1. [Obtain GCP user access credentials] via a web flow for your application. + ```shell + gcloud auth application-default login + ``` + +1. With [Maven] installed, run a sample that has the to-do section completed: ```shell mvn clean compile exec:java -Dexec.mainClass=pubsub.CreateTopicExample ``` @@ -17,4 +22,4 @@ ``` [Maven]: https://maven.apache.org/ -[GCP Service account]: https://cloud.google.com/iam/docs/service-accounts +[Obtain GCP user access credentials]: https://cloud.google.com/sdk/gcloud/reference/auth/application-default/login \ No newline at end of file