Skip to content

Commit ec115cb

Browse files
committed
Merge pull request #488 from mziccard/bigquery
Merge master into bigquery
2 parents 433c286 + a08e7bb commit ec115cb

File tree

76 files changed

+2254
-833
lines changed

Some content is hidden

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

76 files changed

+2254
-833
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ before_install:
1010
install: mvn install -DskipTests=true -Dgpg.skip=true
1111
script:
1212
- utilities/verify.sh
13-
branches:
14-
only:
15-
- master
1613
after_success:
1714
- utilities/after_success.sh
1815
env:

README.md

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ If you are using Maven, add this to your pom.xml file
2525
<dependency>
2626
<groupId>com.google.gcloud</groupId>
2727
<artifactId>gcloud-java</artifactId>
28-
<version>0.0.10</version>
28+
<version>0.1.0</version>
2929
</dependency>
3030
```
3131
If you are using Gradle, add this to your dependencies
3232
```Groovy
33-
compile 'com.google.gcloud:gcloud-java:jar:0.0.10'
33+
compile 'com.google.gcloud:gcloud-java:0.1.0'
3434
```
3535
If you are using SBT, add this to your dependencies
3636
```Scala
37-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.0.10"
37+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.0"
3838
```
3939

4040
Example Applications
@@ -45,15 +45,63 @@ Example Applications
4545
- [`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
4646
- 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).
4747

48+
Specifying a Project ID
49+
-----------------------
50+
51+
Most `gcloud-java` libraries require a project ID. There are multiple ways to specify this project ID.
52+
53+
1. When using `gcloud-java` libraries from within Compute/App Engine, there's no need to specify a project ID. It is automatically inferred from the production environment.
54+
2. When using `gcloud-java` elsewhere, you can do one of the following:
55+
* Supply the project ID when building the service options. For example, to use Datastore from a project with ID "PROJECT_ID", you can write:
56+
57+
```java
58+
Datastore datastore = DatastoreOptions.builder().projectId("PROJECT_ID").build().service();
59+
```
60+
* Specify the environment variable `GCLOUD_PROJECT` to be your desired project ID.
61+
* Set the project ID using the [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already, and set the project ID from the command line. For example:
62+
63+
```
64+
gcloud config set project PROJECT_ID
65+
```
66+
67+
`gcloud-java` determines the project ID from the following sources in the listed order, stopping once it finds a value:
68+
69+
1. Project ID supplied when building the service options
70+
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
71+
3. App Engine project ID
72+
4. Google Cloud SDK project ID
73+
5. Compute Engine project ID
74+
4875
Authentication
4976
--------------
5077

51-
There are multiple ways to authenticate to use Google Cloud services.
78+
First, ensure that the necessary Google Cloud APIs are enabled for your project. To do this, follow the instructions on the [authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication) shared by all the gcloud language libraries.
79+
80+
Next, choose a method for authenticating API requests from within your project:
5281

5382
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
5483
2. When using `gcloud-java` libraries elsewhere, there are two options:
55-
* [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.
56-
* 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`.
84+
* [Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). After downloading that key, you must do one of the following:
85+
* Define the environment variable GOOGLE_APPLICATION_CREDENTIALS to be the location of the key. For example:
86+
```bash
87+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/key.json
88+
```
89+
* Supply the JSON credentials file when building the service options. For example, this Storage object has the necessary permissions to interact with your Google Cloud Storage data:
90+
```java
91+
Storage storage = StorageOptions.builder()
92+
.authCredentials(AuthCredentials.createForJson(new FileInputStream("/path/to/my/key.json"))
93+
.build()
94+
.service();
95+
```
96+
* If running locally for development/testing, you can use use Google Cloud SDK. Download the SDK if you haven't already, then login using the SDK (`gcloud auth login` in command line). Be sure to set your project ID as described above.
97+
98+
`gcloud-java` looks for credentials in the following order, stopping once it finds credentials:
99+
100+
1. Credentials supplied when building the service options
101+
2. App Engine credentials
102+
3. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
103+
4. Google Cloud SDK credentials
104+
5. Compute Engine credentials
57105
58106
Google Cloud Datastore
59107
----------------------
@@ -75,7 +123,7 @@ import com.google.gcloud.datastore.Entity;
75123
import com.google.gcloud.datastore.Key;
76124
import com.google.gcloud.datastore.KeyFactory;
77125
78-
Datastore datastore = DatastoreOptions.getDefaultInstance().service();
126+
Datastore datastore = DatastoreOptions.defaultInstance().service();
79127
KeyFactory keyFactory = datastore.newKeyFactory().kind(KIND);
80128
Key key = keyFactory.newKey(keyName);
81129
Entity entity = datastore.get(key);
@@ -118,8 +166,7 @@ import com.google.gcloud.storage.StorageOptions;
118166
import java.nio.ByteBuffer;
119167
import java.nio.channels.WritableByteChannel;
120168
121-
StorageOptions options = StorageOptions.builder().projectId("project").build();
122-
Storage storage = options.service();
169+
Storage storage = StorageOptions.defaultInstance().service();
123170
BlobId blobId = BlobId.of("bucket", "blob_name");
124171
Blob blob = Blob.load(storage, blobId);
125172
if (blob == null) {
@@ -135,6 +182,11 @@ if (blob == null) {
135182
}
136183
```
137184
185+
Troubleshooting
186+
---------------
187+
188+
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
189+
138190
Java Versions
139191
-------------
140192
@@ -161,7 +213,7 @@ Contributing
161213
162214
Contributions to this library are always welcome and highly encouraged.
163215
164-
See [CONTRIBUTING] for more information on how to get started.
216+
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
165217
166218
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.
167219
@@ -172,7 +224,7 @@ Apache 2.0 - See [LICENSE] for more information.
172224
173225
174226
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
175-
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md
227+
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
176228
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
177229
[TESTING]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/TESTING.md
178230
[cloud-platform]: https://cloud.google.com/

RELEASING.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ This script takes an optional argument denoting the new version. By default, if
1010
2. Create a PR to update the pom.xml version.
1111
The PR should look something like [#225](https://github.com/GoogleCloudPlatform/gcloud-java/pull/225). After this PR is merged into GoogleCloudPlatform/gcloud-java, Travis CI will push a new website to GoogleCloudPlatform/gh-pages, push a new artifact to the Maven Central Repository, and update versions in the README files.
1212

13-
3. Create a release on Github manually.
14-
Go to the [releases page](https://github.com/GoogleCloudPlatform/gcloud-java/releases) and click "Draft a new release." Use `vX.Y.Z` as the "Tag Version" and `X.Y.Z` as the "Release Title", where `X.Y.Z` is the release version as listed in the `pom.xml` files.
13+
3. Before moving on, verify that the artifacts have successfully been pushed to the Maven Central Repository. Open Travis CI, click the ["Build History" tab](https://travis-ci.org/GoogleCloudPlatform/gcloud-java/builds), and open the second build's logs for Step 2's PR. Be sure that you are not opening the "Pull Request" build logs. When the build finishes, scroll to the end of the log and verify that the artifacts were successfully staged and deployed. You can also search for `gcloud-java` on the [Sonatype website](https://oss.sonatype.org/#nexus-search;quick~gcloud-java) and check the latest version number. If the deployment didn't succeed because of a flaky test, rerun the build.
1514

16-
4. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
15+
4. Publish a release on Github manually.
16+
Go to the [releases page](https://github.com/GoogleCloudPlatform/gcloud-java/releases) and open the appropriate release draft. Make sure the "Tag Version" is `vX.Y.Z` and the "Release Title" is `X.Y.Z`, where `X.Y.Z` is the release version as listed in the `pom.xml` files. The draft should already have all changes that impact users since the previous release. To double check this, you can use the `git log` command and look through the merged master branch pull requests. Here is an example of the log command to get non-merge commits between v0.0.12 and v0.1.0:
17+
18+
```
19+
git --no-pager log v0.0.12..v0.1.0 --pretty=oneline --abbrev-commit --no-merges
20+
```
21+
22+
Ensure that the format is consistent with previous releases (for an example, see the [0.1.0 release](https://github.com/GoogleCloudPlatform/gcloud-java/releases/tag/v0.1.0)). After adding any missing updates and reformatting as necessary, publish the draft. Finally, create a new draft for the next release.
23+
24+
5. Run `utilities/update_pom_version.sh` again (to include "-SNAPSHOT" in the project version).
1725
As mentioned before, there is an optional version argument. By default, the script will update the version from "X.Y.Z" to "X.Y.Z+1-SNAPSHOT". Suppose a different version is desired, for example X+1.0.0-SNAPSHOT. Then the appropriate command to run would be `utilities/update_pom_version.sh X+1.0.0-SNAPSHOT`.
1826

19-
5. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
27+
6. Create and merge in another PR to reflect the updated project version. For an example of what this PR should look like, see [#227](https://github.com/GoogleCloudPlatform/gcloud-java/pull/227).
2028

2129
### To push a snapshot version
2230

gcloud-java-bigquery/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.google.gcloud</groupId>
1313
<artifactId>gcloud-java-pom</artifactId>
14-
<version>0.0.11-SNAPSHOT</version>
14+
<version>0.1.1-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>gcloud-java-bigquery</site.installationModule>

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/BigQueryImplTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ public void setUp() {
260260
EasyMock.replay(rpcFactoryMock);
261261
options = BigQueryOptions.builder()
262262
.projectId(PROJECT)
263-
.authCredentials(AuthCredentials.noCredentials())
264263
.serviceRpcFactory(rpcFactoryMock)
265264
.build();
266265
}
@@ -1011,7 +1010,7 @@ public void testRetryableException() {
10111010
.andThrow(new BigQueryException(500, "InternalError", true))
10121011
.andReturn(DATASET_INFO_WITH_PROJECT.toPb());
10131012
EasyMock.replay(bigqueryRpcMock);
1014-
bigquery = options.toBuilder().retryParams(RetryParams.getDefaultInstance()).build().service();
1013+
bigquery = options.toBuilder().retryParams(RetryParams.defaultInstance()).build().service();
10151014
DatasetInfo dataset = bigquery.getDataset(DATASET);
10161015
assertEquals(DATASET_INFO_WITH_PROJECT, dataset);
10171016
}
@@ -1022,7 +1021,7 @@ public void testNonRetryableException() {
10221021
EasyMock.expect(bigqueryRpcMock.getDataset(DATASET, EMPTY_RPC_OPTIONS))
10231022
.andThrow(new BigQueryException(501, exceptionMessage, false));
10241023
EasyMock.replay(bigqueryRpcMock);
1025-
bigquery = options.toBuilder().retryParams(RetryParams.getDefaultInstance()).build().service();
1024+
bigquery = options.toBuilder().retryParams(RetryParams.defaultInstance()).build().service();
10261025
thrown.expect(BigQueryException.class);
10271026
thrown.expectMessage(exceptionMessage);
10281027
bigquery.getDataset(DatasetId.of(DATASET));
@@ -1034,7 +1033,7 @@ public void testRuntimeException() {
10341033
EasyMock.expect(bigqueryRpcMock.getDataset(DATASET, EMPTY_RPC_OPTIONS))
10351034
.andThrow(new RuntimeException(exceptionMessage));
10361035
EasyMock.replay(bigqueryRpcMock);
1037-
bigquery = options.toBuilder().retryParams(RetryParams.getDefaultInstance()).build().service();
1036+
bigquery = options.toBuilder().retryParams(RetryParams.defaultInstance()).build().service();
10381037
thrown.expect(BigQueryException.class);
10391038
thrown.expectMessage(exceptionMessage);
10401039
bigquery.getDataset(DATASET);

gcloud-java-bigquery/src/test/java/com/google/gcloud/bigquery/SerializationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ public void testServiceOptions() throws Exception {
218218

219219
options = options.toBuilder()
220220
.projectId("p2")
221-
.retryParams(RetryParams.getDefaultInstance())
222-
.authCredentials(AuthCredentials.noCredentials())
221+
.retryParams(RetryParams.defaultInstance())
222+
.authCredentials(null)
223223
.build();
224224
serializedCopy = serializeAndDeserialize(options);
225225
assertEquals(options, serializedCopy);

gcloud-java-core/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,23 @@ If you are using Maven, add this to your pom.xml file
1717
<dependency>
1818
<groupId>com.google.gcloud</groupId>
1919
<artifactId>gcloud-java-core</artifactId>
20-
<version>0.0.10</version>
20+
<version>0.1.0</version>
2121
</dependency>
2222
```
2323
If you are using Gradle, add this to your dependencies
2424
```Groovy
25-
compile 'com.google.gcloud:gcloud-java-core:jar:0.0.10'
25+
compile 'com.google.gcloud:gcloud-java-core:jar:0.1.0'
2626
```
2727
If you are using SBT, add this to your dependencies
2828
```Scala
29-
libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.0.10"
29+
libraryDependencies += "com.google.gcloud" % "gcloud-java-core" % "0.1.0"
3030
```
3131

32+
Troubleshooting
33+
---------------
34+
35+
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
36+
3237
Java Versions
3338
-------------
3439

@@ -39,7 +44,9 @@ Contributing
3944

4045
Contributions to this library are always welcome and highly encouraged.
4146

42-
See [CONTRIBUTING] for more information on how to get started.
47+
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
48+
49+
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.
4350

4451
Versioning
4552
----------
@@ -57,5 +64,6 @@ Apache 2.0 - See [LICENSE] for more information.
5764

5865

5966
[CONTRIBUTING]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CONTRIBUTING.md
67+
[code-of-conduct]:https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/CODE_OF_CONDUCT.md#contributor-code-of-conduct
6068
[LICENSE]: https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/LICENSE
6169
[cloud-platform]: https://cloud.google.com/

gcloud-java-core/pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.google.gcloud</groupId>
1313
<artifactId>gcloud-java-pom</artifactId>
14-
<version>0.0.11-SNAPSHOT</version>
14+
<version>0.1.1-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>gcloud-java-core</site.installationModule>
@@ -20,12 +20,18 @@
2020
<dependency>
2121
<groupId>com.google.auth</groupId>
2222
<artifactId>google-auth-library-credentials</artifactId>
23-
<version>0.1.0</version>
23+
<version>0.3.1</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>com.google.auth</groupId>
2727
<artifactId>google-auth-library-oauth2-http</artifactId>
28-
<version>0.1.0</version>
28+
<version>0.3.1</version>
29+
<exclusions>
30+
<exclusion>
31+
<groupId>com.google.guava</groupId>
32+
<artifactId>guava-jdk5</artifactId>
33+
</exclusion>
34+
</exclusions>
2935
</dependency>
3036
<dependency>
3137
<groupId>com.google.http-client</groupId>

0 commit comments

Comments
 (0)