Skip to content

Commit e45e20f

Browse files
author
Ajay Kannan
committed
---
yaml --- r: 6873 b: refs/heads/tswast-patch-1 c: a76e6c4 h: refs/heads/master i: 6871: 323fb86
1 parent 3b191e4 commit e45e20f

96 files changed

Lines changed: 2373 additions & 3272 deletions

File tree

Some content is hidden

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

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 4cf793eb6220524588bd537cf6923ee86b7ea4ed
60+
refs/heads/tswast-patch-1: a76e6c40e3a77dc991d404a80287d5240ce8a0d9
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ If you are using Maven, add this to your pom.xml file
2727
<dependency>
2828
<groupId>com.google.gcloud</groupId>
2929
<artifactId>gcloud-java</artifactId>
30-
<version>0.1.3</version>
30+
<version>0.1.2</version>
3131
</dependency>
3232
```
3333
If you are using Gradle, add this to your dependencies
3434
```Groovy
35-
compile 'com.google.gcloud:gcloud-java:0.1.3'
35+
compile 'com.google.gcloud:gcloud-java:0.1.2'
3636
```
3737
If you are using SBT, add this to your dependencies
3838
```Scala
39-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.3"
39+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.2"
4040
```
4141

4242
Example Applications
@@ -130,7 +130,7 @@ import com.google.gcloud.bigquery.BigQuery;
130130
import com.google.gcloud.bigquery.BigQueryOptions;
131131
import com.google.gcloud.bigquery.Field;
132132
import com.google.gcloud.bigquery.JobStatus;
133-
import com.google.gcloud.bigquery.JobInfo;
133+
import com.google.gcloud.bigquery.LoadJobInfo;
134134
import com.google.gcloud.bigquery.Schema;
135135
import com.google.gcloud.bigquery.TableId;
136136
import com.google.gcloud.bigquery.TableInfo;
@@ -144,8 +144,7 @@ if (info == null) {
144144
bigquery.create(TableInfo.of(tableId, Schema.of(integerField)));
145145
} else {
146146
System.out.println("Loading data into table " + tableId);
147-
LoadJobConfiguration configuration = LoadJobConfiguration.of(tableId, "gs://bucket/path");
148-
JobInfo loadJob = JobInfo.of(configuration);
147+
LoadJobInfo loadJob = LoadJobInfo.of(tableId, "gs://bucket/path");
149148
loadJob = bigquery.create(loadJob);
150149
while (loadJob.status().state() != JobStatus.State.DONE) {
151150
Thread.sleep(1000L);
@@ -210,20 +209,22 @@ Google Cloud Resource Manager (Alpha)
210209
Here is a code snippet showing a simple usage example. Note that you must supply Google SDK credentials for this service, not other forms of authentication listed in the [Authentication section](#authentication).
211210
212211
```java
213-
import com.google.gcloud.resourcemanager.ProjectInfo;
212+
import com.google.gcloud.resourcemanager.Project;
214213
import com.google.gcloud.resourcemanager.ResourceManager;
215214
import com.google.gcloud.resourcemanager.ResourceManagerOptions;
216215
217216
import java.util.Iterator;
218217
219218
ResourceManager resourceManager = ResourceManagerOptions.defaultInstance().service();
220-
ProjectInfo myProject = resourceManager.get("some-project-id"); // Use an existing project's ID
221-
ProjectInfo newProjectInfo = resourceManager.replace(myProject.toBuilder()
222-
.addLabel("launch-status", "in-development").build());
223-
System.out.println("Updated the labels of project " + newProjectInfo.projectId()
224-
+ " to be " + newProjectInfo.labels());
219+
Project myProject = resourceManager.get("some-project-id"); // Use an existing project's ID
220+
Project newProject = myProject.toBuilder()
221+
.addLabel("launch-status", "in-development")
222+
.build()
223+
.replace();
224+
System.out.println("Updated the labels of project " + newProject.projectId()
225+
+ " to be " + newProject.labels());
225226
// List all the projects you have permission to view.
226-
Iterator<ProjectInfo> projectIterator = resourceManager.list().iterateAll();
227+
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
227228
System.out.println("Projects I can view:");
228229
while (projectIterator.hasNext()) {
229230
System.out.println(projectIterator.next().projectId());

branches/tswast-patch-1/RELEASING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ As mentioned before, there is an optional version argument. By default, the scr
2626

2727
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).
2828

29-
7. Be sure to update App Engine documentation and [java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) code as necessary. See directions [here](https://docs.google.com/a/google.com/document/d/1SS3xNn2v0qW7EadGUPBUAPIQAH5VY6WSFmT17ZjjUVE/edit?usp=sharing).
30-
3129
### To push a snapshot version
3230

3331
Pushing a snapshot is completely automated. If "-SNAPSHOT" is included in the version denoted by the base directory's pom.xml, then an updated artifact will be pushed to the snapshot repository when Travis CI successfully completes a non-PR build.

branches/tswast-patch-1/gcloud-java-bigquery/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ If you are using Maven, add this to your pom.xml file
2020
<dependency>
2121
<groupId>com.google.gcloud</groupId>
2222
<artifactId>gcloud-java-bigquery</artifactId>
23-
<version>0.1.3</version>
23+
<version>0.1.2</version>
2424
</dependency>
2525
```
2626
If you are using Gradle, add this to your dependencies
2727
```Groovy
28-
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.3'
28+
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.2'
2929
```
3030
If you are using SBT, add this to your dependencies
3131
```Scala
32-
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.3"
32+
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.2"
3333
```
3434

3535
Example Application

branches/tswast-patch-1/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.1.4-SNAPSHOT</version>
14+
<version>0.1.3-SNAPSHOT</version>
1515
</parent>
1616
<properties>
1717
<site.installationModule>gcloud-java-bigquery</site.installationModule>

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Acl.java

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,22 @@ Access toPb() {
370370
}
371371
}
372372

373-
private Acl(Entity entity, Role role) {
373+
/**
374+
* Build an ACL for an {@code entity} and a {@code role}.
375+
*/
376+
public Acl(Entity entity, Role role) {
374377
this.entity = checkNotNull(entity);
375378
this.role = role;
376379
}
377380

381+
/**
382+
* Build an ACL for a view entity.
383+
*/
384+
public Acl(View view) {
385+
this.entity = checkNotNull(view);
386+
this.role = null;
387+
}
388+
378389
/**
379390
* Returns the entity for this ACL.
380391
*/
@@ -389,23 +400,6 @@ public Role role() {
389400
return role;
390401
}
391402

392-
/**
393-
* Returns an Acl object.
394-
*
395-
* @param entity the entity for this ACL object
396-
* @param role the role to associate to the {@code entity} object
397-
*/
398-
public static Acl of(Entity entity, Role role) {
399-
return new Acl(entity, role);
400-
}
401-
402-
/**
403-
* Returns an Acl object for a view entity.
404-
*/
405-
public static Acl of(View view) {
406-
return new Acl(view, null);
407-
}
408-
409403
@Override
410404
public int hashCode() {
411405
return Objects.hash(entity, role);
@@ -438,7 +432,7 @@ Access toPb() {
438432
}
439433

440434
static Acl fromPb(Access access) {
441-
return Acl.of(Entity.fromPb(access),
435+
return new Acl(Entity.fromPb(access),
442436
access.getRole() != null ? Role.valueOf(access.getRole()) : null);
443437
}
444438
}

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BaseTableInfo.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,14 @@ public String toString() {
386386
return toStringHelper().toString();
387387
}
388388

389-
protected final int baseHashCode() {
389+
@Override
390+
public int hashCode() {
390391
return Objects.hash(tableId);
391392
}
392393

393-
protected final boolean baseEquals(BaseTableInfo tableInfo) {
394-
return Objects.equals(toPb(), tableInfo.toPb());
395-
}
396-
397-
BaseTableInfo setProjectId(String projectId) {
398-
return toBuilder().tableId(tableId().setProjectId(projectId)).build();
394+
@Override
395+
public boolean equals(Object obj) {
396+
return obj instanceof BaseTableInfo && Objects.equals(toPb(), ((BaseTableInfo) obj).toPb());
399397
}
400398

401399
Table toPb() {

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,8 @@ public static JobListOption startPageToken(String pageToken) {
371371
* is not provided all job's fields are returned. {@code JobOption.fields()} can be used to
372372
* specify only the fields of interest. {@link JobInfo#jobId()}, {@link JobStatus#state()},
373373
* {@link JobStatus#error()} as well as type-specific configuration (e.g.
374-
* {@link QueryJobConfiguration#query()} for Query Jobs) are always returned, even if not
375-
* specified. {@link JobField#SELF_LINK} and {@link JobField#ETAG} can not be selected when
376-
* listing jobs.
374+
* {@link QueryJobInfo#query()} for Query Jobs) are always returned, even if not specified.
375+
* {@link JobField#SELF_LINK} and {@link JobField#ETAG} can not be selected when listing jobs.
377376
*/
378377
public static JobListOption fields(JobField... fields) {
379378
String selector = JobField.selector(fields);
@@ -398,8 +397,8 @@ private JobOption(BigQueryRpc.Option option, Object value) {
398397
* Returns an option to specify the job's fields to be returned by the RPC call. If this option
399398
* is not provided all job's fields are returned. {@code JobOption.fields()} can be used to
400399
* specify only the fields of interest. {@link JobInfo#jobId()} as well as type-specific
401-
* configuration (e.g. {@link QueryJobConfiguration#query()} for Query Jobs) are always
402-
* returned, even if not specified.
400+
* configuration (e.g. {@link QueryJobInfo#query()} for Query Jobs) are always returned, even if
401+
* not specified.
403402
*/
404403
public static JobOption fields(JobField... fields) {
405404
return new JobOption(BigQueryRpc.Option.FIELDS, JobField.selector(fields));
@@ -471,7 +470,7 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
471470
*
472471
* @throws BigQueryException upon failure
473472
*/
474-
JobInfo create(JobInfo job, JobOption... options) throws BigQueryException;
473+
<T extends JobInfo> T create(T job, JobOption... options) throws BigQueryException;
475474

476475
/**
477476
* Returns the requested dataset or {@code null} if not found.
@@ -612,14 +611,14 @@ Page<List<FieldValue>> listTableData(TableId tableId, TableDataListOption... opt
612611
*
613612
* @throws BigQueryException upon failure
614613
*/
615-
JobInfo getJob(String jobId, JobOption... options) throws BigQueryException;
614+
<T extends JobInfo> T getJob(String jobId, JobOption... options) throws BigQueryException;
616615

617616
/**
618617
* Returns the requested job or {@code null} if not found.
619618
*
620619
* @throws BigQueryException upon failure
621620
*/
622-
JobInfo getJob(JobId jobId, JobOption... options) throws BigQueryException;
621+
<T extends JobInfo> T getJob(JobId jobId, JobOption... options) throws BigQueryException;
623622

624623
/**
625624
* Lists the jobs.
@@ -666,9 +665,9 @@ Page<List<FieldValue>> listTableData(TableId tableId, TableDataListOption... opt
666665

667666
/**
668667
* Returns a channel to write data to be inserted into a BigQuery table. Data format and other
669-
* options can be configured using the {@link WriteChannelConfiguration} parameter.
668+
* options can be configured using the {@link LoadConfiguration} parameter.
670669
*
671670
* @throws BigQueryException upon failure
672671
*/
673-
TableDataWriteChannel writer(WriteChannelConfiguration writeChannelConfiguration);
672+
TableDataWriteChannel writer(LoadConfiguration loadConfiguration);
674673
}

branches/tswast-patch-1/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQueryException.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.gcloud.bigquery;
1818

19+
import com.google.api.client.googleapis.json.GoogleJsonError;
20+
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
1921
import com.google.common.collect.ImmutableSet;
2022
import com.google.gcloud.BaseServiceException;
2123
import com.google.gcloud.RetryHelper.RetryHelperException;
@@ -53,11 +55,16 @@ public BigQueryException(int code, String message, BigQueryError error) {
5355

5456
public BigQueryException(IOException exception) {
5557
super(exception, true);
56-
BigQueryError error = null;
57-
if (reason() != null) {
58-
error = new BigQueryError(reason(), location(), getMessage(), debugInfo());
58+
BigQueryError bigqueryError = null;
59+
if (exception instanceof GoogleJsonResponseException) {
60+
GoogleJsonError error = ((GoogleJsonResponseException) exception).getDetails();
61+
if (error != null && error.getErrors() != null && !error.getErrors().isEmpty()) {
62+
GoogleJsonError.ErrorInfo errorInfo = error.getErrors().get(0);
63+
bigqueryError = new BigQueryError(errorInfo.getReason(), errorInfo.getLocation(),
64+
errorInfo.getMessage(), (String) error.get("debugInfo"));
65+
}
5966
}
60-
this.error = error;
67+
this.error = bigqueryError;
6168
}
6269

6370
/**

0 commit comments

Comments
 (0)