Skip to content

Commit 5352b92

Browse files
author
Frank Natividad
committed
Merge branch 'master' into discovery-endpoints-migration
2 parents 7ef7d53 + c2e1c03 commit 5352b92

File tree

85 files changed

+1330
-206
lines changed

Some content is hidden

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

85 files changed

+1330
-206
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# java-docs-samples
22

3-
[![Build Status](https://travis-ci.org/GoogleCloudPlatform/java-docs-samples.svg?branch=master)](https://travis-ci.org/GoogleCloudPlatform/java-docs-samples)
3+
[![Circle-CI Build Status](https://circleci.com/gh/GoogleCloudPlatform/java-docs-samples.svg?style=shield&circle-token=117b41ead030b212fc7d519519ee9262c4f3480b)](https://circleci.com/gh/GoogleCloudPlatform/java-docs-samples)
44
[![ghit.me](https://ghit.me/badge.svg?repo=GoogleCloudPlatform/java-docs-samples)](https://ghit.me/repo/GoogleCloudPlatform/java-docs-samples)
55
[![Coverage Status](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples/branch/master/graph/badge.svg)](https://codecov.io/gh/GoogleCloudPlatform/java-docs-samples)
66

appengine/channel/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<relativePath>..</relativePath>
2727
</parent>
2828
<properties>
29-
<objectify.version>5.1.15</objectify.version>
29+
<objectify.version>5.1.16</objectify.version>
3030
</properties>
3131
<!-- [START set_versions] -->
3232
<prerequisites>

appengine/datastore/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>com.google.auto.value</groupId>
4646
<artifactId>auto-value</artifactId>
47-
<version>1.3</version>
47+
<version>1.4</version>
4848
<scope>provided</scope>
4949
</dependency>
5050
<dependency>

appengine/endpoints-frameworks-v2/backend/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
<properties>
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333

34-
<endpoints.framework.version>2.0.4</endpoints.framework.version>
34+
<endpoints.framework.version>2.0.5</endpoints.framework.version>
3535
<endpoints.management.version>1.0.2</endpoints.management.version>
3636

3737
<endpoints.project.id>YOUR_PROJECT_ID</endpoints.project.id>
3838
<maven.compiler.target>1.7</maven.compiler.target>
3939
<maven.compiler.source>1.7</maven.compiler.source>
40-
<appengine.maven.plugin.version>1.0.0</appengine.maven.plugin.version>
40+
<appengine.maven.plugin.version>1.2.0</appengine.maven.plugin.version>
4141
</properties>
4242

4343
<dependencies>

appengine/endpoints-frameworks-v2/migration-example/jenkins.sh

100644100755
+4
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,27 @@ function TestEndpoints () {
2222
# Test getGreeting Endpoint (hello world!)
2323
curl -X GET \
2424
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/0" | \
25+
tee "$ERROR_OUTPUT_DIR/response.json" | \
2526
grep "hello version-${2}"
2627

2728
# Test getGreeting Endpoint (goodbye world!)
2829
curl -X GET \
2930
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
31+
tee "$ERROR_OUTPUT_DIR/response.json" | \
3032
grep "goodbye world!"
3133

3234
# Test listGreeting Endpoint (hello world! and goodbye world!)
3335
curl -X GET \
3436
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting" | \
37+
tee "$ERROR_OUTPUT_DIR/response.json" | \
3538
grep "hello world!\|goodbye world!"
3639

3740
# Test multiply Endpoint (This is a greeting.)
3841
curl -X POST \
3942
-H "Content-Type: application/json" \
4043
--data "{'message':'This is a greeting from instance ${2}'}." \
4144
"https://${2}-dot-${1}.appspot.com/_ah/api/helloworld/v1/hellogreeting/1" | \
45+
tee "$ERROR_OUTPUT_DIR/response.json" | \
4246
grep "This is a greeting from instance ${2}."
4347
}
4448

appengine/endpoints-frameworks-v2/migration-example/src/main/java/com/example/helloendpoints/Greetings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Greetings {
4343
public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();
4444

4545
static {
46-
greetings.add(new HelloGreeting("hello version-jerjou-test!"));
46+
greetings.add(new HelloGreeting("hello world!"));
4747
greetings.add(new HelloGreeting("goodbye world!"));
4848
}
4949
//[END api_def]

appengine/firebase-event-proxy/gae-firebase-event-proxy/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
<dependency>
6565
<groupId>com.fasterxml.jackson.core</groupId>
6666
<artifactId>jackson-core</artifactId>
67-
<version>2.9.0.pr1</version>
67+
<version>2.9.0.pr2</version>
6868
</dependency>
6969
<dependency>
7070
<groupId>com.fasterxml.jackson.core</groupId>
7171
<artifactId>jackson-databind</artifactId>
72-
<version>2.9.0.pr1</version>
72+
<version>2.9.0.pr2</version>
7373
</dependency>
7474

7575
<!-- Test Dependencies -->

appengine/firebase-tictactoe/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
<relativePath>..</relativePath>
2727
</parent>
2828
<properties>
29-
<objectify.version>5.1.15</objectify.version>
29+
<objectify.version>5.1.16</objectify.version>
3030
<servlet-api.version>2.5</servlet-api.version>
3131
<gson.version>2.7</gson.version>
3232
<guava.version>20.0</guava.version>
3333
<google-api-client.version>1.22.0</google-api-client.version>
3434
<junit.version>4.12</junit.version>
3535
<mockito.version>1.10.19</mockito.version>
3636
<google-truth.version>0.32</google-truth.version>
37-
<appengine-maven.version>1.0.0</appengine-maven.version>
37+
<appengine-maven.version>1.2.0</appengine-maven.version>
3838
</properties>
3939
<!-- [START set_versions] -->
4040
<prerequisites>

appengine/guestbook-objectify/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<groupId>com.example.appengine</groupId>
2424
<artifactId>appengine-guestbook-objectify</artifactId>
2525
<properties>
26-
<objectify.version>5.1.15</objectify.version>
26+
<objectify.version>5.1.16</objectify.version>
2727
<guava.version>20.0</guava.version>
2828
</properties>
2929
<parent>

appengine/memcache/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Copyright 2015 Google Inc.
4545
<dependency>
4646
<groupId>com.googlecode.xmemcached</groupId>
4747
<artifactId>xmemcached</artifactId>
48-
<version>2.3.0</version>
48+
<version>2.3.1</version>
4949
</dependency>
5050
<!-- [END dependencies] -->
5151
</dependencies>

appengine/multitenancy/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<artifactId>appengine-multitenancy</artifactId>
2525

2626
<properties>
27-
<objectify.version>5.1.15</objectify.version>
27+
<objectify.version>5.1.16</objectify.version>
2828
<guava.version>20.0</guava.version>
2929
</properties>
3030
<parent>

appengine/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<dependency>
105105
<groupId>org.mockito</groupId>
106106
<artifactId>mockito-core</artifactId>
107-
<version>2.7.14</version>
107+
<version>2.7.19</version>
108108
<scope>test</scope>
109109
</dependency>
110110
<dependency>

bigquery/README.md

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
# Getting Started with BigQuery and the Google Java API Client library
1+
# Getting Started with BigQuery
22

3-
Google's BigQuery Service features a REST-based API that allows developers to create applications to run ad-hoc queries
4-
on massive datasets. These sample Java applications demonstrate how to access the BigQuery API using the Google Java API
5-
Client Libraries.
3+
Google's BigQuery Service features a REST-based API that allows developers to
4+
create applications to run ad-hoc queries on massive datasets. These sample
5+
Java applications demonstrate how to access the BigQuery API.
66

7-
For more information, read the [Getting Started with BigQuery and the Google Java API Client
8-
library][1] codelab.
7+
## API Libraries
8+
9+
We provide samples for multiple methods of accessing the APIs in case you need
10+
lower-level access, but the `cloud-client` samples are idiomatic and show the
11+
recommended way to access the API.
12+
13+
- cloud-client (Preferred Option)
14+
- This uses [Google Cloud Client
15+
Libraries](http://googlecloudplatform.github.io/google-cloud-java/), and
16+
the idiomatic and
17+
[recommended](https://cloud.google.com/bigquery/docs/reference/libraries)
18+
way to interact with BigQuery.
19+
- rest
20+
- This uses BigQuery's RESTful API directly. Not recommended.
21+
- src
22+
- This uses [Google API Client Libraries](https://developers.google.com/api-client-library/java/). Not recommended.
923

1024
## Quickstart
1125

@@ -26,11 +40,6 @@ You can then run a given `ClassName` via:
2640
## Language
2741
- [Java][3]
2842

29-
## Dependencies
30-
- [Google APIs Client Library for Java][4]
31-
32-
[1]: https://cloud.google.com/bigquery/bigquery-api-quickstart
33-
[2]: https://developers.google.com/bigquery
43+
[2]: https://cloud.google.com/bigquery
3444
[3]: https://java.com
35-
[4]: http://code.google.com/p/google-api-java-client/
3645

bigquery/cloud-client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.google.cloud</groupId>
3939
<artifactId>google-cloud-bigquery</artifactId>
40-
<version>0.9.4-beta</version>
40+
<version>0.10.0-beta</version>
4141
</dependency>
4242
<dependency>
4343
<groupId>joda-time</groupId>

bigquery/cloud-client/src/main/java/com/example/bigquery/SimpleApp.java

+30-9
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@
2121
import com.google.cloud.bigquery.BigQuery;
2222
import com.google.cloud.bigquery.BigQueryOptions;
2323
import com.google.cloud.bigquery.FieldValue;
24-
import com.google.cloud.bigquery.QueryRequest;
24+
import com.google.cloud.bigquery.Job;
25+
import com.google.cloud.bigquery.JobId;
26+
import com.google.cloud.bigquery.JobInfo;
27+
import com.google.cloud.bigquery.QueryJobConfiguration;
2528
import com.google.cloud.bigquery.QueryResponse;
2629
import com.google.cloud.bigquery.QueryResult;
2730

2831
import java.util.Iterator;
2932
import java.util.List;
33+
import java.util.UUID;
3034
// [END create_client]
3135

3236
public class SimpleApp {
@@ -35,18 +39,35 @@ public static void main(String... args) throws Exception {
3539
BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();
3640
// [END create_client]
3741
// [START run_query]
38-
QueryRequest queryRequest =
39-
QueryRequest
40-
.newBuilder(
41-
"SELECT "
42-
+ "APPROX_TOP_COUNT(corpus, 10) as title, "
43-
+ "COUNT(*) as unique_words "
44-
+ "FROM `publicdata.samples.shakespeare`;")
42+
QueryJobConfiguration queryConfig =
43+
QueryJobConfiguration.newBuilder(
44+
"SELECT "
45+
+ "APPROX_TOP_COUNT(corpus, 10) as title, "
46+
+ "COUNT(*) as unique_words "
47+
+ "FROM `publicdata.samples.shakespeare`;")
4548
// Use standard SQL syntax for queries.
4649
// See: https://cloud.google.com/bigquery/sql-reference/
4750
.setUseLegacySql(false)
4851
.build();
49-
QueryResponse response = bigquery.query(queryRequest);
52+
53+
// Create a job ID so that we can safely retry.
54+
JobId jobId = JobId.of(UUID.randomUUID().toString());
55+
Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build());
56+
57+
// Wait for the query to complete.
58+
queryJob = queryJob.waitFor();
59+
60+
// Check for errors
61+
if (queryJob == null) {
62+
throw new RuntimeException("Job no longer exists");
63+
} else if (queryJob.getStatus().getError() != null) {
64+
// You can also look at queryJob.getStatus().getExecutionErrors() for all
65+
// errors, not just the latest one.
66+
throw new RuntimeException(queryJob.getStatus().getError().toString());
67+
}
68+
69+
// Get the results.
70+
QueryResponse response = bigquery.getQueryResults(jobId);
5071
// [END run_query]
5172

5273
// [START print_results]

bigquery/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>com.google.apis</groupId>
2525
<artifactId>google-api-services-bigquery</artifactId>
26-
<version>v2-rev336-1.22.0</version>
26+
<version>v2-rev338-1.22.0</version>
2727
<exclusions>
2828
<exclusion> <!-- exclude an old version of Guava -->
2929
<groupId>com.google.guava</groupId>

bigquery/src/test/java/com/google/cloud/bigquery/samples/test/Constants.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
package com.google.cloud.bigquery.samples.test;
1818

1919
public class Constants {
20-
public static final String PROJECT_ID = "cloud-samples-tests";
20+
public static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
21+
public static final String BUCKET = PROJECT_ID;
2122
public static final String DATASET_ID = "test_dataset_java";
2223
public static final String CURRENT_TABLE_ID = "test_table_java";
2324
public static final String NEW_TABLE_ID = "test_table_java_2";
24-
public static final String CLOUD_STORAGE_INPUT_URI = "gs://cloud-samples-tests/data.csv";
25-
public static final String CLOUD_STORAGE_OUTPUT_URI = "gs://cloud-samples-tests/output.csv";
25+
public static final String CLOUD_STORAGE_INPUT_URI = "gs://" + BUCKET + "/data.csv";
26+
public static final String CLOUD_STORAGE_OUTPUT_URI = "gs://" + BUCKET + "/output.csv";
2627
public static final String QUERY =
2728
"SELECT corpus FROM publicdata:samples.shakespeare GROUP BY corpus;";
2829
}

bigquery/src/test/java/com/google/cloud/bigquery/samples/test/ListDatasetsProjectsTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*/
3636
@RunWith(JUnit4.class)
3737
public class ListDatasetsProjectsTest {
38+
private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT");
3839
private static final PrintStream REAL_OUT = System.out;
3940
private static final PrintStream REAL_ERR = System.err;
4041

@@ -72,6 +73,6 @@ public void testMain() throws Exception {
7273

7374
assertThat(out).named("stdout").contains("Listing all the Projects");
7475
assertThat(out).named("stdout").contains("Project list:");
75-
assertThat(out).named("stdout").containsMatch("Bigquery Samples|cloud-samples-tests");
76+
assertThat(out).named("stdout").containsMatch("Bigquery Samples|" + PROJECT_ID);
7677
}
7778
}

circle.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
machine:
2+
java:
3+
version: oraclejdk8
4+
environment:
5+
chromedriver_path: /usr/local/bin/chromedriver
6+
dependencies:
7+
pre:
8+
- sudo mkdir /opt/webdriver/
9+
- curl -LO https://github.com/mozilla/geckodriver/releases/download/v0.15.0/geckodriver-v0.15.0-linux64.tar.gz
10+
&& sudo tar -zxf geckodriver-*.tar.gz -C /opt/webdriver/
11+
- sudo apt-add-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe"
12+
- sudo apt-get update
13+
- sudo apt-get install -t trusty-backports shellcheck
14+
- sudo apt-get install expect
15+
test:
16+
override:
17+
- bash ./travis.sh

compute/cmdline/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ limitations under the License.
8989
</dependency>
9090
</dependencies>
9191
<properties>
92-
<project.compute.version>v1-rev138-1.22.0</project.compute.version>
92+
<project.compute.version>v1-rev139-1.22.0</project.compute.version>
9393
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9494
</properties>
9595
</project>

datastore/cloud-client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>com.google.cloud</groupId>
3939
<artifactId>google-cloud-datastore</artifactId>
40-
<version>0.9.4-beta</version>
40+
<version>0.10.0-beta</version>
4141
</dependency>
4242

4343
<!-- Test dependencies -->

datastore/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<dependency>
4242
<groupId>com.google.cloud</groupId>
4343
<artifactId>google-cloud-datastore</artifactId>
44-
<version>0.9.4-beta</version>
44+
<version>0.10.0-beta</version>
4545
</dependency>
4646

4747
<!-- Test dependencies -->

flexible/analytics/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<maven.compiler.target>1.8</maven.compiler.target>
3232
<maven.compiler.source>1.8</maven.compiler.source>
3333

34-
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
34+
<appengine.maven.plugin>1.2.0</appengine.maven.plugin>
3535
<jetty.maven.plugin>9.3.8.v20160314</jetty.maven.plugin>
3636

3737
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->

flexible/async-rest/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<properties>
3232
<places.appkey>YOUR_PLACES_APP_KEY</places.appkey>
3333

34-
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
34+
<appengine.maven.plugin>1.2.0</appengine.maven.plugin>
3535
<jetty.version>9.3.8.v20160314</jetty.version>
3636

3737
<maven.compiler.target>1.8</maven.compiler.target>

flexible/cloudsql/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<maven.compiler.target>1.8</maven.compiler.target>
4242
<maven.compiler.source>1.8</maven.compiler.source>
4343

44-
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
44+
<appengine.maven.plugin>1.2.0</appengine.maven.plugin>
4545
<jetty.maven.plugin>9.3.8.v20160314</jetty.maven.plugin>
4646

4747
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->

flexible/cloudstorage/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<maven.compiler.target>1.8</maven.compiler.target>
3232
<maven.compiler.source>1.8</maven.compiler.source>
3333

34-
<appengine.maven.plugin>1.0.0</appengine.maven.plugin>
34+
<appengine.maven.plugin>1.2.0</appengine.maven.plugin>
3535
<jetty.maven.plugin>9.3.8.v20160314</jetty.maven.plugin>
3636

3737
<failOnMissingWebXml>false</failOnMissingWebXml> <!-- REQUIRED -->
@@ -49,7 +49,7 @@
4949
<dependency>
5050
<groupId>com.google.cloud</groupId>
5151
<artifactId>google-cloud-storage</artifactId>
52-
<version>0.9.4-beta</version>
52+
<version>0.10.0-beta</version>
5353
</dependency>
5454
<!-- [END dependencies] -->
5555
</dependencies>

0 commit comments

Comments
 (0)