diff --git a/.travis.yml b/.travis.yml
index 3cea8e9d2a1..128e302fb89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
-# Copyright 2016 Google Inc. All Rights Reserved.
+# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index 40352cb272d..61281c1f694 100644
--- a/README.md
+++ b/README.md
@@ -6,3 +6,41 @@
This is a repository that contains java code snippets on [Cloud Platform Documentation](https://cloud.google.com/docs/).
+The repo is organized as follows:
+
+* [App Engine Standard](appengine)
+ * [TaskQueue](taskqueue)
+ * [Unit Tests](unittests)
+* [App Engine Flexible](flexible)
+* [Compute Engine](compute)
+
+Technology Samples:
+
+* [Bigquery](bigquery)
+* [Datastore](datastore)
+* [Endpoints](endpoints)
+* [Key Management Service](kms)
+* [Logging](logging)
+* [Monitoring](monitoring)
+* [Natural Language](language)
+* [PubSub](pubsub)
+* [Cloud Spanner](spanner)
+* [Speech](speech)
+* [Cloud Storage](storage)
+* [Translate](translate)
+* [Vision](vision)
+
+## Credentials Example
+
+The documentation for [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials).
+
+`BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService();`
+
+The client library looks for credentials using the following rules:
+
+1. `GOOGLE_APPLICATION_CREDENTIALS` environment variable, pointing to a service account key JSON file path.
+2. Cloud SDK credentials `gcloud auth application-default login`
+3. App Engine standard environment credentials.
+4. Compute Engine credentials.
+
+You can override this behavior using setCredentials in `BigQueryOptions.newBuilder()` by adding `setCredentials(Credentials credentials)` from [ServiceOptions.builder](http://googlecloudplatform.github.io/google-cloud-java/0.12.0/apidocs/com/google/cloud/ServiceOptions.Builder.html#setCredentials-com.google.auth.Credentials-) and [Credentials](http://google.github.io/google-auth-library-java/releases/0.6.0/apidocs/com/google/auth/Credentials.html?is-external=true).
diff --git a/appengine/.gitignore b/appengine/.gitignore
index 453750bc157..c94f025e98b 100644
--- a/appengine/.gitignore
+++ b/appengine/.gitignore
@@ -1,4 +1,4 @@
-# Copyright 2015 Google Inc. All Rights Reserved.
+# Copyright 2015 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
diff --git a/appengine/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java b/appengine/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java
index ee8f5a678c4..4fd2d6186b6 100644
--- a/appengine/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java
+++ b/appengine/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2015 Google Inc. All Rights Reserved.
+ * Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/appengine/analytics/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/analytics/src/main/webapp/WEB-INF/appengine-web.xml
index efa1efaa42f..68ee6e05f5e 100644
--- a/appengine/analytics/src/main/webapp/WEB-INF/appengine-web.xml
+++ b/appengine/analytics/src/main/webapp/WEB-INF/appengine-web.xml
@@ -1,7 +1,7 @@
mysql
mysql-connector-java
- 5.1.40
+ 6.0.5
com.google.cloud.sql
diff --git a/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java b/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java
index da3ada939cb..9e09fbede8e 100644
--- a/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java
+++ b/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2016 Google Inc. All Rights Reserved.
+ * Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml
index 2ca4fde21ca..731d5aa24ed 100644
--- a/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml
+++ b/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml
@@ -1,6 +1,6 @@
+
diff --git a/appengine/datastore/indexes-exploding/src/main/webapp/WEB-INF/web.xml b/appengine/datastore/indexes-exploding/src/main/webapp/WEB-INF/web.xml
index 049fd7a05e7..6af27edbd87 100644
--- a/appengine/datastore/indexes-exploding/src/main/webapp/WEB-INF/web.xml
+++ b/appengine/datastore/indexes-exploding/src/main/webapp/WEB-INF/web.xml
@@ -1,6 +1,6 @@
+
diff --git a/appengine/datastore/indexes/src/main/webapp/WEB-INF/web.xml b/appengine/datastore/indexes/src/main/webapp/WEB-INF/web.xml
index 049fd7a05e7..6af27edbd87 100644
--- a/appengine/datastore/indexes/src/main/webapp/WEB-INF/web.xml
+++ b/appengine/datastore/indexes/src/main/webapp/WEB-INF/web.xml
@@ -1,6 +1,6 @@
javax.servlet
servlet-api
- 2.5
+ 3.0-alpha-1
jar
provided
diff --git a/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveCallServlet.java b/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveCallServlet.java
index 1332a62b08f..1e5aabda0cf 100644
--- a/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveCallServlet.java
+++ b/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveCallServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2015 Google Inc. All Rights Reserved.
+ * Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveSmsServlet.java b/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveSmsServlet.java
index cd99f8f083c..aa7bb6db308 100644
--- a/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveSmsServlet.java
+++ b/appengine/twilio/src/main/java/com/example/appengine/twilio/ReceiveSmsServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2015 Google Inc. All Rights Reserved.
+ * Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/appengine/twilio/src/main/java/com/example/appengine/twilio/SendSmsServlet.java b/appengine/twilio/src/main/java/com/example/appengine/twilio/SendSmsServlet.java
index da6ecb0c941..6cb0c30a46e 100644
--- a/appengine/twilio/src/main/java/com/example/appengine/twilio/SendSmsServlet.java
+++ b/appengine/twilio/src/main/java/com/example/appengine/twilio/SendSmsServlet.java
@@ -1,5 +1,5 @@
/**
- * Copyright 2015 Google Inc. All Rights Reserved.
+ * Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/appengine/twilio/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/twilio/src/main/webapp/WEB-INF/appengine-web.xml
index 34cd5e0b3ad..ffb8546d95f 100644
--- a/appengine/twilio/src/main/webapp/WEB-INF/appengine-web.xml
+++ b/appengine/twilio/src/main/webapp/WEB-INF/appengine-web.xml
@@ -1,6 +1,6 @@
- com.google.guava
- guava-jdk5
-
-
-
-
- com.google.guava
- guava
- 20.0
-
-
- com.google.oauth-client
- google-oauth-client
- 1.22.0
-
-
- com.google.http-client
- google-http-client-jackson2
- 1.22.0
-
-
- com.google.oauth-client
- google-oauth-client-jetty
- 1.22.0
-
-
- com.google.code.gson
- gson
- 2.8.0
-
-
- junit
- junit
- 4.12
- test
-
-
- com.google.truth
- truth
- 0.32
- test
-
-
-
-
- UTF-8
-
-
-
- src/main/java
-
-
- src/main/resources
-
-
-
-
-
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/AsyncQuerySample.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/AsyncQuerySample.java
deleted file mode 100644
index e0384da0867..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/AsyncQuerySample.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * Copyright (c) 2015 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain
- * a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.Bigquery.Jobs.GetQueryResults;
-import com.google.api.services.bigquery.model.GetQueryResultsResponse;
-import com.google.api.services.bigquery.model.Job;
-import com.google.api.services.bigquery.model.JobConfiguration;
-import com.google.api.services.bigquery.model.JobConfigurationQuery;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- * Example of authorizing with BigQuery and reading from a public dataset.
- */
-public class AsyncQuerySample {
- private static final String DEFAULT_QUERY =
- "SELECT corpus FROM `publicdata.samples.shakespeare` GROUP BY corpus;";
-
- // [START main]
- /**
- * Prompts for all the parameters required to make a query.
- *
- * @param args Command line args
- * @throws IOException IOException
- * @throws InterruptedException InterruptedException
- */
- public static void main(final String[] args) throws IOException, InterruptedException {
- String projectId = System.getProperty("projectId");
- if (projectId == null || projectId.isEmpty()) {
- System.err.println("The projectId property must be set.");
- System.exit(1);
- }
- System.out.printf("projectId: %s\n", projectId);
-
- String queryString = System.getProperty("query");
- if (queryString == null || queryString.isEmpty()) {
- System.out.println("The query property was not set, using default.");
- queryString = DEFAULT_QUERY;
- }
- System.out.printf("query: %s\n", queryString);
-
- String useBatchString = System.getProperty("useBatchMode");
- if (useBatchString == null || useBatchString.isEmpty()) {
- useBatchString = "false";
- }
- boolean useBatchMode = Boolean.parseBoolean(useBatchString);
- System.out.printf("useBatchMode: %b\n", useBatchMode);
-
- String waitTimeString = System.getProperty("waitTime");
- if (waitTimeString == null || waitTimeString.isEmpty()) {
- waitTimeString = "1000";
- }
- long waitTime = Long.parseLong(waitTimeString);
- System.out.printf("waitTime: %d (milliseconds)\n", waitTime);
-
- String useLegacySqlString = System.getProperty("useLegacySql");
- if (useLegacySqlString == null || useLegacySqlString.isEmpty()) {
- useLegacySqlString = "false";
- }
- boolean useLegacySql = Boolean.parseBoolean(useLegacySqlString);
-
- Iterator pages =
- run(projectId, queryString, useBatchMode, waitTime, useLegacySql);
- while (pages.hasNext()) {
- BigQueryUtils.printRows(pages.next().getRows(), System.out);
- }
- }
- // [END main]
-
- // [START run]
- /**
- * Run the query.
- *
- * @param projectId Get this from Google Developers console
- * @param queryString Query we want to run against BigQuery
- * @param useBatchMode True if you want to batch the queries
- * @param waitTime How long to wait before retries
- * @param useLegacySql Boolean that is false if using standard SQL syntax.
- * @return An iterator to the result of your pages
- * @throws IOException Thrown if there's an IOException
- * @throws InterruptedException Thrown if there's an Interrupted Exception
- */
- public static Iterator run(
- final String projectId,
- final String queryString,
- final boolean useBatchMode,
- final long waitTime,
- final boolean useLegacySql)
- throws IOException, InterruptedException {
-
- Bigquery bigquery = BigQueryServiceFactory.getService();
-
- Job query = asyncQuery(bigquery, projectId, queryString, useBatchMode, useLegacySql);
- Bigquery.Jobs.Get getRequest =
- bigquery.jobs().get(projectId, query.getJobReference().getJobId());
-
- // Poll every waitTime milliseconds,
- // retrying at most retries times if there are errors
- BigQueryUtils.pollJob(getRequest, waitTime);
-
- GetQueryResults resultsRequest =
- bigquery.jobs().getQueryResults(projectId, query.getJobReference().getJobId());
-
- return BigQueryUtils.getPages(resultsRequest);
- }
- // [END run]
-
- // [START asyncQuery]
- /**
- * Inserts an asynchronous query Job for a particular query.
- *
- * @param bigquery an authorized BigQuery client
- * @param projectId a String containing the project ID
- * @param querySql the actual query string
- * @param useBatchMode True if you want to run the query as BATCH
- * @param useLegacySql Boolean that is false if using standard SQL syntax.
- * @return a reference to the inserted query job
- * @throws IOException Thrown if there's a network exception
- */
- public static Job asyncQuery(
- final Bigquery bigquery,
- final String projectId,
- final String querySql,
- final boolean useBatchMode,
- final boolean useLegacySql)
- throws IOException {
-
- JobConfigurationQuery queryConfig =
- new JobConfigurationQuery()
- .setQuery(querySql)
- // Set the useLegacySql parameter to false to use standard SQL syntax. See:
- // https://cloud.google.com/bigquery/sql-reference/enabling-standard-sql
- .setUseLegacySql(useLegacySql);
-
- if (useBatchMode) {
- queryConfig.setPriority("BATCH");
- }
-
- Job job = new Job().setConfiguration(new JobConfiguration().setQuery(queryConfig));
-
- return bigquery.jobs().insert(projectId, job).execute();
- }
- // [END asyncQuery]
-
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryServiceFactory.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryServiceFactory.java
deleted file mode 100644
index 9d6daee7185..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryServiceFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2015 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.cloud.bigquery.samples;
-
-// [START imports]
-import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.client.json.JsonFactory;
-import com.google.api.client.json.jackson2.JacksonFactory;
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.BigqueryScopes;
-// [END imports]
-
-import java.io.IOException;
-import java.util.Collection;
-
-/**
- * This class creates our Service to connect to BigQuery including auth.
- */
-public final class BigQueryServiceFactory {
-
- /**
- * Private constructor to disable creation of this utility Factory class.
- */
- private BigQueryServiceFactory() {}
-
- /**
- * Singleton service used through the app.
- */
- private static Bigquery service = null;
-
- /**
- * Mutex created to create the singleton in thread-safe fashion.
- */
- private static Object serviceLock = new Object();
-
- /**
- * Threadsafe Factory that provides an authorized BigQuery service.
- * @return The BigQuery service
- * @throws IOException Throw if there is an error connecting to BigQuery.
- */
- public static Bigquery getService() throws IOException {
- if (service == null) {
- synchronized (serviceLock) {
- if (service == null) {
- service = createAuthorizedClient();
- }
- }
- }
- return service;
- }
-
- /**
- * Creates an authorized client to Google BigQuery.
- *
- * @return The BigQuery Service
- * @throws IOException Thrown if there is an error connecting
- */
- // [START get_service]
- private static Bigquery createAuthorizedClient() throws IOException {
- // Create the credential
- HttpTransport transport = new NetHttpTransport();
- JsonFactory jsonFactory = new JacksonFactory();
- GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory);
-
- // Depending on the environment that provides the default credentials (e.g. Compute Engine, App
- // Engine), the credentials may require us to specify the scopes we need explicitly.
- // Check for this case, and inject the BigQuery scope if required.
- if (credential.createScopedRequired()) {
- Collection bigqueryScopes = BigqueryScopes.all();
- credential = credential.createScoped(bigqueryScopes);
- }
-
- return new Bigquery.Builder(transport, jsonFactory, credential)
- .setApplicationName("BigQuery Samples")
- .build();
- }
- // [END get_service]
-
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryUtils.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryUtils.java
deleted file mode 100644
index 33f9fb247d6..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/BigQueryUtils.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- Copyright 2015, Google, Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.client.json.GenericJson;
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.Bigquery.Datasets;
-import com.google.api.services.bigquery.BigqueryRequest;
-import com.google.api.services.bigquery.model.DatasetList;
-import com.google.api.services.bigquery.model.Job;
-import com.google.api.services.bigquery.model.TableCell;
-import com.google.api.services.bigquery.model.TableFieldSchema;
-import com.google.api.services.bigquery.model.TableRow;
-import com.google.api.services.bigquery.model.TableSchema;
-import com.google.gson.Gson;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-/**
- * Helper functions for the other classes.
- */
-public class BigQueryUtils {
-
- /**
- * Private constructor to prevent creation of this class, which is just all
- * static helper methods.
- */
- private BigQueryUtils() {}
-
- /**
- * Print rows to the output stream in a formatted way.
- * @param rows rows in bigquery
- * @param out Output stream we want to print to
- */
- // [START print_rows]
- public static void printRows(final List rows, final PrintStream out) {
- for (TableRow row : rows) {
- for (TableCell field : row.getF()) {
- out.printf("%-50s", field.getV());
- }
- out.println();
- }
- }
- // [END print_rows]
-
- /**
- * Polls the job for completion.
- * @param request The bigquery request to poll for completion
- * @param interval Number of milliseconds between each poll
- * @return The finished job
- * @throws IOException IOException
- * @throws InterruptedException InterruptedException
- */
- // [START poll_job]
- public static Job pollJob(final Bigquery.Jobs.Get request, final long interval)
- throws IOException, InterruptedException {
- Job job = request.execute();
- while (!job.getStatus().getState().equals("DONE")) {
- System.out.println(
- "Job is " + job.getStatus().getState() + " waiting " + interval + " milliseconds...");
- Thread.sleep(interval);
- job = request.execute();
- }
- return job;
- }
- // [END poll_job]
-
- /**
- * Pages through the results of an arbitrary Bigquery request.
- * @param requestTemplate The object that represents the call to fetch
- * the results.
- * @param The type of the returned objects
- * @return An iterator that pages through the returned object
- */
- // [START paging]
- public static Iterator getPages(
- final BigqueryRequest requestTemplate) {
-
- /**
- * An iterator class that pages through a Bigquery request.
- */
- class PageIterator implements Iterator {
-
- private BigqueryRequest request;
- private boolean hasNext = true;
-
- /**
- * Inner class that represents our iterator to page through results.
- * @param requestTemplate The object that represents the call to fetch
- * the results.
- */
- public PageIterator(final BigqueryRequest requestTemplate) {
- this.request = requestTemplate;
- }
-
- /**
- * Checks whether there is another page of results.
- * @return True if there is another page of results.
- */
- public boolean hasNext() {
- return hasNext;
- }
-
- /**
- * Returns the next page of results.
- * @return The next page of resul.ts
- */
- public T next() {
- if (!hasNext) {
- throw new NoSuchElementException();
- }
- try {
- T response = request.execute();
- if (response.containsKey("pageToken")) {
- request = request.set("pageToken", response.get("pageToken"));
- } else {
- hasNext = false;
- }
- return response;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- /**
- * Skips the page by moving the iterator to the next page.
- */
- public void remove() {
- this.next();
- }
- }
-
- return new PageIterator(requestTemplate);
- }
- // [END paging]
-
- /**
- * Loads a Bigquery schema.
- * @param schemaSource The source of the schema
- * @return The TableSchema
- */
- // [START load_schema]
- public static TableSchema loadSchema(final Reader schemaSource) {
- TableSchema sourceSchema = new TableSchema();
-
- List fields =
- (new Gson())
- .>fromJson(
- schemaSource, (new ArrayList()).getClass());
-
- sourceSchema.setFields(fields);
-
- return sourceSchema;
- }
- // [END load_schema]
-
- // [START list_datasets]
- /**
- * Display all BigQuery datasets associated with a project.
- *
- * @param bigquery an authorized BigQuery client
- * @param projectId a string containing the current project ID
- * @throws IOException Thrown if there is a network error connecting to
- * Bigquery.
- */
- public static void listDatasets(final Bigquery bigquery, final String projectId)
- throws IOException {
- Datasets.List datasetRequest = bigquery.datasets().list(projectId);
- DatasetList datasetList = datasetRequest.execute();
- if (datasetList.getDatasets() != null) {
- List datasets = datasetList.getDatasets();
- System.out.println("Available datasets\n----------------");
- System.out.println(datasets.toString());
- for (DatasetList.Datasets dataset : datasets) {
- System.out.format("%s\n", dataset.getDatasetReference().getDatasetId());
- }
- }
- }
- // [END list_datasets]
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/ExportDataCloudStorageSample.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/ExportDataCloudStorageSample.java
deleted file mode 100644
index 03316dddc05..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/ExportDataCloudStorageSample.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Copyright 2015, Google, Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.model.Job;
-import com.google.api.services.bigquery.model.JobConfiguration;
-import com.google.api.services.bigquery.model.JobConfigurationExtract;
-import com.google.api.services.bigquery.model.TableReference;
-
-import java.io.IOException;
-import java.util.Scanner;
-
-/**
- * Sample of how to Export Cloud Data.
- */
-public class ExportDataCloudStorageSample {
- /**
- * Protected constructor since this is a collection of static functions.
- */
- protected ExportDataCloudStorageSample() {
- super();
- }
-
- /**
- * This program can be run to demonstrate running a Bigquery query from the
- * CLI.
- * @param args Command line args
- * @throws IOException If there is an error connceting to bigquery
- * @throws InterruptedException Should never be thrown.
- */
- // [START main]
- public static void main(final String[] args) throws IOException, InterruptedException {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter your project id: ");
- String projectId = scanner.nextLine();
- System.out.println("Enter your dataset id: ");
- String datasetId = scanner.nextLine();
- System.out.println("Enter your table id: ");
- String tableId = scanner.nextLine();
- System.out.println("Enter the Google Cloud Storage Path to which you'd " + "like to export: ");
- String cloudStoragePath = scanner.nextLine();
- System.out.println("Enter how often to check if your job is complete " + "(milliseconds): ");
- long interval = scanner.nextLong();
- scanner.close();
-
- run(cloudStoragePath, projectId, datasetId, tableId, interval);
- }
- // [END main]
-
- /**
- * Run the bigquery ClI.
- * @param cloudStoragePath The bucket we are using
- * @param projectId Project id
- * @param datasetId datasetid
- * @param tableId tableid
- * @param interval interval to wait between polling in milliseconds
- * @throws IOException Thrown if there is an error connecting to Bigquery.
- * @throws InterruptedException Should never be thrown
- */
- // [START run]
- public static void run(
- final String cloudStoragePath,
- final String projectId,
- final String datasetId,
- final String tableId,
- final long interval)
- throws IOException, InterruptedException {
-
- Bigquery bigquery = BigQueryServiceFactory.getService();
-
- Job extractJob =
- extractJob(
- bigquery,
- cloudStoragePath,
- new TableReference()
- .setProjectId(projectId)
- .setDatasetId(datasetId)
- .setTableId(tableId));
-
- Bigquery.Jobs.Get getJob =
- bigquery
- .jobs()
- .get(
- extractJob.getJobReference().getProjectId(),
- extractJob.getJobReference().getJobId());
-
- BigQueryUtils.pollJob(getJob, interval);
-
- System.out.println("Export is Done!");
- }
- // [END run]
-
- /**
- * A job that extracts data from a table.
- * @param bigquery Bigquery service to use
- * @param cloudStoragePath Cloud storage bucket we are inserting into
- * @param table Table to extract from
- * @return The job to extract data from the table
- * @throws IOException Thrown if error connceting to Bigtable
- */
- // [START extract_job]
- public static Job extractJob(
- final Bigquery bigquery, final String cloudStoragePath, final TableReference table)
- throws IOException {
-
- JobConfigurationExtract extract =
- new JobConfigurationExtract().setSourceTable(table).setDestinationUri(cloudStoragePath);
-
- return bigquery
- .jobs()
- .insert(
- table.getProjectId(),
- new Job().setConfiguration(new JobConfiguration().setExtract(extract)))
- .execute();
- }
- // [END extract_job]
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/GettingStarted.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/GettingStarted.java
deleted file mode 100644
index b4549b62240..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/GettingStarted.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2012 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.cloud.bigquery.samples;
-
-// [START all]
-import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
-import com.google.api.client.http.HttpTransport;
-import com.google.api.client.http.javanet.NetHttpTransport;
-import com.google.api.client.json.JsonFactory;
-import com.google.api.client.json.jackson2.JacksonFactory;
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.BigqueryScopes;
-import com.google.api.services.bigquery.model.GetQueryResultsResponse;
-import com.google.api.services.bigquery.model.QueryRequest;
-import com.google.api.services.bigquery.model.QueryResponse;
-import com.google.api.services.bigquery.model.TableCell;
-import com.google.api.services.bigquery.model.TableRow;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Scanner;
-
-/**
- * Example of authorizing with Bigquery and reading from a public dataset.
- *
- * Specifically, this queries the shakespeare dataset to fetch the 10 of Shakespeare's works with
- * the greatest number of distinct words.
- */
-public class GettingStarted {
- // [START build_service]
- /**
- * Creates an authorized Bigquery client service using Application Default Credentials.
- *
- * @return an authorized Bigquery client
- * @throws IOException if there's an error getting the default credentials.
- */
- public static Bigquery createAuthorizedClient() throws IOException {
- // Create the credential
- HttpTransport transport = new NetHttpTransport();
- JsonFactory jsonFactory = new JacksonFactory();
- GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory);
-
- // Depending on the environment that provides the default credentials (e.g. Compute Engine, App
- // Engine), the credentials may require us to specify the scopes we need explicitly.
- // Check for this case, and inject the Bigquery scope if required.
- if (credential.createScopedRequired()) {
- credential = credential.createScoped(BigqueryScopes.all());
- }
-
- return new Bigquery.Builder(transport, jsonFactory, credential)
- .setApplicationName("Bigquery Samples")
- .build();
- }
- // [END build_service]
-
- // [START run_query]
- /**
- * Executes the given query synchronously.
- *
- * @param querySql the query to execute.
- * @param bigquery the Bigquery service object.
- * @param projectId the id of the project under which to run the query.
- * @return a list of the results of the query.
- * @throws IOException if there's an error communicating with the API.
- */
- private static List executeQuery(String querySql, Bigquery bigquery, String projectId)
- throws IOException {
- QueryResponse query =
- bigquery.jobs().query(projectId, new QueryRequest().setQuery(querySql)).execute();
-
- // Execute it
- GetQueryResultsResponse queryResult =
- bigquery
- .jobs()
- .getQueryResults(
- query.getJobReference().getProjectId(), query.getJobReference().getJobId())
- .execute();
-
- return queryResult.getRows();
- }
- // [END run_query]
-
- // [START print_results]
- /**
- * Prints the results to standard out.
- *
- * @param rows the rows to print.
- */
- private static void printResults(List rows) {
- System.out.print("\nQuery Results:\n------------\n");
- for (TableRow row : rows) {
- for (TableCell field : row.getF()) {
- System.out.printf("%-50s", field.getV());
- }
- System.out.println();
- }
- }
- // [END print_results]
-
- /**
- * Exercises the methods defined in this class.
- *
- * In particular, it creates an authorized Bigquery service object using Application Default
- * Credentials, then executes a query against the public Shakespeare dataset and prints out the
- * results.
- *
- * @param args the first argument, if it exists, should be the id of the project to run the test
- * under. If no arguments are given, it will prompt for it.
- * @throws IOException if there's an error communicating with the API.
- */
- public static void main(String[] args) throws IOException {
- Scanner sc;
- if (args.length == 0) {
- // Prompt the user to enter the id of the project to run the queries under
- System.out.print("Enter the project ID: ");
- sc = new Scanner(System.in);
- } else {
- sc = new Scanner(args[0]);
- }
- String projectId = sc.nextLine();
-
- // Create a new Bigquery client authorized via Application Default Credentials.
- Bigquery bigquery = createAuthorizedClient();
-
- List rows =
- executeQuery(
- "SELECT TOP(corpus, 10) as title, COUNT(*) as unique_words "
- + "FROM [publicdata:samples.shakespeare]",
- bigquery,
- projectId);
-
- printResults(rows);
- }
-}
-// [END all]
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/ListDatasetsProjects.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/ListDatasetsProjects.java
deleted file mode 100644
index 0334a2f2eda..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/ListDatasetsProjects.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2015 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.client.util.Data;
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.Bigquery.Datasets;
-import com.google.api.services.bigquery.model.DatasetList;
-import com.google.api.services.bigquery.model.GetQueryResultsResponse;
-import com.google.api.services.bigquery.model.ProjectList;
-import com.google.api.services.bigquery.model.QueryRequest;
-import com.google.api.services.bigquery.model.QueryResponse;
-import com.google.api.services.bigquery.model.TableCell;
-import com.google.api.services.bigquery.model.TableRow;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.Thread;
-import java.util.List;
-
-/**
- * Invokes the BigQuery basic APIs for the given project id specified.
- *
- * Samples used in this page:
- *
- * https://cloud.google.com/bigquery/bigquery-api-quickstart
- */
-public class ListDatasetsProjects {
- /**
- * Run the sample.
- */
- public static void main(String[] args) throws IOException, InterruptedException {
- if (args.length != 1) {
- System.err.println("Usage: QuickStart ");
- return;
- }
- String projectId = args[0];
-
- Bigquery bigquery = BigQueryServiceFactory.getService();
- String query =
- "SELECT TOP( title, 10) as title, COUNT(*) as revision_count "
- + "FROM [publicdata:samples.wikipedia] WHERE wp_namespace = 0;";
-
- System.out.println();
- System.out.println("----- Running the asynchronous query and printing it to stdout.");
- runQueryRpcAndPrint(bigquery, projectId, query, System.out);
-
- System.out.println();
- System.out.println("----- Listing all the Datasets in the projectId");
- listDatasets(bigquery, projectId);
-
- System.out.println();
- System.out.println("----- Listing all the Projects");
- listProjects(bigquery);
- }
-
- /**
- * Lists all Datasets in a project specified by the projectId.
- *
- * @param bigquery The BigQuery object.
- * @param projectId The projectId from which lists the existing Datasets.
- * @throws IOException if there's trouble with the network request.
- */
- // [START listDatasets]
- public static void listDatasets(Bigquery bigquery, String projectId) throws IOException {
- Datasets.List datasetRequest = bigquery.datasets().list(projectId);
- DatasetList datasetList = datasetRequest.execute();
-
- if (datasetList.getDatasets() != null) {
- List datasets = datasetList.getDatasets();
- System.out.println("Dataset list:");
-
- for (DatasetList.Datasets dataset : datasets) {
- System.out.format("%s\n", dataset.getDatasetReference().getDatasetId());
- }
- }
- }
- // [END listDatasets]
-
- /**
- * Lists all Projects.
- *
- * @param bigquery The BigQuery object.
- * @throws IOException if there's trouble with the network request.
- */
- // [START listProjects]
- public static void listProjects(Bigquery bigquery) throws IOException {
- Bigquery.Projects.List projectListRequest = bigquery.projects().list();
- ProjectList projectList = projectListRequest.execute();
-
- if (projectList.getProjects() != null) {
- List projects = projectList.getProjects();
- System.out.println("Project list:");
-
- for (ProjectList.Projects project : projects) {
- System.out.format("%s\n", project.getFriendlyName());
- }
- }
- }
- // [END listProjects]
-
- /**
- * Runs a synchronous BigQuery query and displays the result.
- *
- * @param bigquery An authorized BigQuery client
- * @param projectId The current project id
- * @param query A String containing a BigQuery SQL statement
- * @param out A PrintStream for output, normally System.out
- */
- static void runQueryRpcAndPrint(
- Bigquery bigquery, String projectId, String query, PrintStream out)
- throws IOException, InterruptedException {
- QueryRequest queryRequest = new QueryRequest().setQuery(query);
- QueryResponse queryResponse = bigquery.jobs().query(projectId, queryRequest).execute();
- if (queryResponse.getJobComplete()) {
- printRows(queryResponse.getRows(), out);
- if (null == queryResponse.getPageToken()) {
- return;
- }
- }
- // This loop polls until results are present, then loops over result pages.
- String pageToken = null;
- while (true) {
- GetQueryResultsResponse queryResults =
- bigquery
- .jobs()
- .getQueryResults(projectId, queryResponse.getJobReference().getJobId())
- .setPageToken(pageToken)
- .execute();
- if (queryResults.getJobComplete()) {
- printRows(queryResults.getRows(), out);
- pageToken = queryResults.getPageToken();
- if (null == pageToken) {
- return;
- }
- }
- Thread.sleep(500);
- }
- }
-
- /**
- * Print the given rows.
- *
- * @param rows the rows to print.
- * @param out the place to print them.
- */
- private static void printRows(java.util.List rows, PrintStream out) {
- if (rows != null) {
- for (TableRow row : rows) {
- for (TableCell cell : row.getF()) {
- // Data.isNull() is the recommended way to check for the 'null object' in TableCell.
- out.printf("%s, ", Data.isNull(cell.getV()) ? "null" : cell.getV().toString());
- }
- out.println();
- }
- }
- }
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/LoadDataCsvSample.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/LoadDataCsvSample.java
deleted file mode 100644
index b3ecb26c149..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/LoadDataCsvSample.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- Copyright 2015, Google, Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.model.Job;
-import com.google.api.services.bigquery.model.JobConfiguration;
-import com.google.api.services.bigquery.model.JobConfigurationLoad;
-import com.google.api.services.bigquery.model.TableReference;
-import com.google.api.services.bigquery.model.TableSchema;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Collections;
-import java.util.Scanner;
-
-/**
- * Cli tool to load data from a CSV into Bigquery.
- */
-public class LoadDataCsvSample {
-
- /**
- * Protected constructor since this is a collection of static methods.
- */
- protected LoadDataCsvSample() {}
-
- /**
- * Cli tool to load data from a CSV into Bigquery.
- * @param args Command line args, should be empty
- * @throws IOException IOException
- * @throws InterruptedException InterruptedException
- */
- // [START main]
- public static void main(final String[] args) throws IOException, InterruptedException {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Enter your project id: ");
- String projectId = scanner.nextLine();
- System.out.println("Enter your dataset id: ");
- String datasetId = scanner.nextLine();
- System.out.println("Enter your table id: ");
- String tableId = scanner.nextLine();
- System.out.println("Enter the Google Cloud Storage Path to the data " + "you'd like to load: ");
- String cloudStoragePath = scanner.nextLine();
- System.out.println("Enter the filepath to your schema: ");
- String sourceSchemaPath = scanner.nextLine();
-
- System.out.println("Enter how often to check if your job is complete " + "(milliseconds): ");
- long interval = scanner.nextLong();
- scanner.close();
-
- run(
- cloudStoragePath,
- projectId,
- datasetId,
- tableId,
- new FileReader(new File(sourceSchemaPath)),
- interval);
- }
- // [END main]
-
- /**
- * Run the bigquery ClI.
- * @param cloudStoragePath The bucket we are using
- * @param projectId Project id
- * @param datasetId datasetid
- * @param tableId tableid
- * @param schemaSource Source of the schema
- * @param interval interval to wait between polling in milliseconds
- * @throws IOException Thrown if there is an error connecting to Bigquery.
- * @throws InterruptedException Should never be thrown
- */
- // [START run]
- public static void run(
- final String cloudStoragePath,
- final String projectId,
- final String datasetId,
- final String tableId,
- final Reader schemaSource,
- final long interval)
- throws IOException, InterruptedException {
-
- Bigquery bigquery = BigQueryServiceFactory.getService();
-
- Job loadJob =
- loadJob(
- bigquery,
- cloudStoragePath,
- new TableReference()
- .setProjectId(projectId)
- .setDatasetId(datasetId)
- .setTableId(tableId),
- BigQueryUtils.loadSchema(schemaSource));
-
- Bigquery.Jobs.Get getJob =
- bigquery
- .jobs()
- .get(loadJob.getJobReference().getProjectId(), loadJob.getJobReference().getJobId());
-
- BigQueryUtils.pollJob(getJob, interval);
-
- System.out.println("Load is Done!");
- }
- // [END run]
-
- /**
- * A job that extracts data from a table.
- * @param bigquery Bigquery service to use
- * @param cloudStoragePath Cloud storage bucket we are inserting into
- * @param table Table to extract from
- * @param schema The schema of the table we are loading into
- * @return The job to extract data from the table
- * @throws IOException Thrown if error connceting to Bigtable
- */
- // [START load_job]
- public static Job loadJob(
- final Bigquery bigquery,
- final String cloudStoragePath,
- final TableReference table,
- final TableSchema schema)
- throws IOException {
-
- JobConfigurationLoad load =
- new JobConfigurationLoad()
- .setDestinationTable(table)
- .setSchema(schema)
- .setSourceUris(Collections.singletonList(cloudStoragePath));
-
- return bigquery
- .jobs()
- .insert(
- table.getProjectId(), new Job().setConfiguration(new JobConfiguration().setLoad(load)))
- .execute();
- }
- // [END load_job]
-}
diff --git a/bigquery/src/main/java/com/google/cloud/bigquery/samples/StreamingSample.java b/bigquery/src/main/java/com/google/cloud/bigquery/samples/StreamingSample.java
deleted file mode 100644
index ef37f042aab..00000000000
--- a/bigquery/src/main/java/com/google/cloud/bigquery/samples/StreamingSample.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- Copyright 2015, Google, Inc.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-package com.google.cloud.bigquery.samples;
-
-import com.google.api.services.bigquery.Bigquery;
-import com.google.api.services.bigquery.model.TableDataInsertAllRequest;
-import com.google.api.services.bigquery.model.TableDataInsertAllResponse;
-import com.google.gson.Gson;
-import com.google.gson.JsonSyntaxException;
-import com.google.gson.stream.JsonReader;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Scanner;
-
-/**
- * Example of Bigquery Streaming.
- */
-public class StreamingSample {
-
- /**
- * Empty constructor since this is just a collection of static methods.
- */
- protected StreamingSample() {}
-
- /**
- * Command line that demonstrates Bigquery streaming.
- *
- * @param args Command line args, should be empty
- * @throws IOException IOexception
- */
- // [START main]
- public static void main(final String[] args) throws IOException {
- final Scanner scanner = new Scanner(System.in);
- System.out.println("Enter your project id: ");
- String projectId = scanner.nextLine();
- System.out.println("Enter your dataset id: ");
- String datasetId = scanner.nextLine();
- System.out.println("Enter your table id: ");
- String tableId = scanner.nextLine();
- scanner.close();
-
- System.out.println(
- "Enter JSON to stream to BigQuery: \n" + "Press End-of-stream (CTRL-D) to stop");
-
- JsonReader fromCli = new JsonReader(new InputStreamReader(System.in));
-
- Iterator responses = run(projectId, datasetId, tableId, fromCli);
-
- while (responses.hasNext()) {
- System.out.println(responses.next());
- }
-
- fromCli.close();
- }
- // [END main]
-
- /**
- * Run the bigquery ClI.
- *
- * @param projectId Project id
- * @param datasetId datasetid
- * @param tableId tableid
- * @param rows The source of the JSON rows we are streaming in.
- * @return Returns Iterates through the stream responses
- * @throws IOException Thrown if there is an error connecting to Bigquery.
- * @throws InterruptedException Should never be thrown
- */
- // [START run]
- public static Iterator run(
- final String projectId, final String datasetId, final String tableId, final JsonReader rows)
- throws IOException {
-
- final Bigquery bigquery = BigQueryServiceFactory.getService();
- final Gson gson = new Gson();
- rows.beginArray();
-
- return new Iterator() {
-
- /**
- * Check whether there is another row to stream.
- *
- * @return True if there is another row in the stream
- */
- public boolean hasNext() {
- try {
- return rows.hasNext();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
-
- /**
- * Insert the next row, and return the response.
- *
- * @return Next page of data
- */
- public TableDataInsertAllResponse next() {
- try {
- Map rowData =
- gson.