Skip to content

Commit 26479d2

Browse files
committed
---
yaml --- r: 4689 b: refs/heads/logging-alpha c: 712b255 h: refs/heads/master i: 4687: 1ba52a6
1 parent a142d7b commit 26479d2

14 files changed

Lines changed: 196 additions & 184 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ refs/heads/compute-alpha: 969cba2627f1d53d352cc4a5ffe0879dacf65e6c
1212
refs/heads/dns-alpha: 2f90e7e338349287ace33375896907af0f032ca1
1313
refs/heads/dns-alpha-batch: 17442b07867021b85d0452f5f3eda29a3413288f
1414
refs/heads/gcs-nio: 283aeaf15efdcf3621eb6859f05e55ad7764375d
15-
refs/heads/logging-alpha: a248465f1b756918683a3ec8760f2fc748536308
15+
refs/heads/logging-alpha: 712b255f40bfd67128edd4f2b287c7a7193156fa
1616
refs/tags/v0.1.0: a615317f7424ed58621b1f65d5c4d8cbbe8a6ed8
1717
refs/tags/v0.1.1: 7a7f6985fe465e9dd6a075af55493f42b4933be0
1818
refs/tags/v0.1.2: 3eb3fe866ba22487686048f45d927b8c8638ea3f

branches/logging-alpha/RELEASING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Most of the release process is handled by the `after_success.sh` script, trigger
77
1. Run `utilities/update_pom_version.sh` from the repository's base directory.
88
This script takes an optional argument denoting the new version. By default, if the current version is X.Y.Z-SNAPSHOT, the script will update the version in all the pom.xml files to X.Y.Z. If desired, another version can be supplied via command line argument instead.
99

10-
2. Create a PR to update the pom.xml version. If releasing a new client library, this PR should also update javadoc grouping in the base directory's [pom.xml](./pom.xml).
11-
PRs that don't release new modules should look something like [#225](https://github.com/GoogleCloudPlatform/gcloud-java/pull/225). PRs that do release a new module should also add the appropriate packages to the javadoc groups "SPI" and "Test helpers", as shown in [#802](https://github.com/GoogleCloudPlatform/gcloud-java/pull/802) for `gcloud-java-dns`. 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.
10+
2. Create a PR to update the pom.xml version.
11+
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

1313
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.
1414

branches/logging-alpha/codacy-conf.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

Lines changed: 25 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@
1919
import static com.google.common.base.Preconditions.checkArgument;
2020

2121
import com.google.common.base.Function;
22-
import com.google.common.base.Joiner;
2322
import com.google.common.collect.ImmutableList;
2423
import com.google.common.collect.Lists;
25-
import com.google.common.collect.Sets;
24+
import com.google.gcloud.FieldSelector;
2625
import com.google.gcloud.Page;
2726
import com.google.gcloud.Service;
2827
import com.google.gcloud.bigquery.spi.BigQueryRpc;
2928

3029
import java.util.List;
31-
import java.util.Set;
3230

3331
/**
3432
* An interface for Google Cloud BigQuery.
@@ -43,7 +41,7 @@ public interface BigQuery extends Service<BigQueryOptions> {
4341
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/datasets#resource">Dataset
4442
* Resource</a>
4543
*/
46-
enum DatasetField {
44+
enum DatasetField implements FieldSelector {
4745
ACCESS("access"),
4846
CREATION_TIME("creationTime"),
4947
DATASET_REFERENCE("datasetReference"),
@@ -56,24 +54,19 @@ enum DatasetField {
5654
LOCATION("location"),
5755
SELF_LINK("selfLink");
5856

57+
static final List<FieldSelector> REQUIRED_FIELDS =
58+
ImmutableList.<FieldSelector>of(DATASET_REFERENCE);
59+
5960
private final String selector;
6061

6162
DatasetField(String selector) {
6263
this.selector = selector;
6364
}
6465

66+
@Override
6567
public String selector() {
6668
return selector;
6769
}
68-
69-
static String selector(DatasetField... fields) {
70-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 1);
71-
fieldStrings.add(DATASET_REFERENCE.selector());
72-
for (DatasetField field : fields) {
73-
fieldStrings.add(field.selector());
74-
}
75-
return Joiner.on(',').join(fieldStrings);
76-
}
7770
}
7871

7972
/**
@@ -82,7 +75,7 @@ static String selector(DatasetField... fields) {
8275
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/tables#resource">Table
8376
* Resource</a>
8477
*/
85-
enum TableField {
78+
enum TableField implements FieldSelector {
8679
CREATION_TIME("creationTime"),
8780
DESCRIPTION("description"),
8881
ETAG("etag"),
@@ -101,25 +94,19 @@ enum TableField {
10194
TYPE("type"),
10295
VIEW("view");
10396

97+
static final List<FieldSelector> REQUIRED_FIELDS =
98+
ImmutableList.<FieldSelector>of(TABLE_REFERENCE, TYPE);
99+
104100
private final String selector;
105101

106102
TableField(String selector) {
107103
this.selector = selector;
108104
}
109105

106+
@Override
110107
public String selector() {
111108
return selector;
112109
}
113-
114-
static String selector(TableField... fields) {
115-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 2);
116-
fieldStrings.add(TABLE_REFERENCE.selector());
117-
fieldStrings.add(TYPE.selector());
118-
for (TableField field : fields) {
119-
fieldStrings.add(field.selector());
120-
}
121-
return Joiner.on(',').join(fieldStrings);
122-
}
123110
}
124111

125112
/**
@@ -128,7 +115,7 @@ static String selector(TableField... fields) {
128115
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs#resource">Job Resource
129116
* </a>
130117
*/
131-
enum JobField {
118+
enum JobField implements FieldSelector {
132119
CONFIGURATION("configuration"),
133120
ETAG("etag"),
134121
ID("id"),
@@ -138,25 +125,19 @@ enum JobField {
138125
STATUS("status"),
139126
USER_EMAIL("user_email");
140127

128+
static final List<FieldSelector> REQUIRED_FIELDS =
129+
ImmutableList.<FieldSelector>of(JOB_REFERENCE, CONFIGURATION);
130+
141131
private final String selector;
142132

143133
JobField(String selector) {
144134
this.selector = selector;
145135
}
146136

137+
@Override
147138
public String selector() {
148139
return selector;
149140
}
150-
151-
static String selector(JobField... fields) {
152-
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(fields.length + 2);
153-
fieldStrings.add(JOB_REFERENCE.selector());
154-
fieldStrings.add(CONFIGURATION.selector());
155-
for (JobField field : fields) {
156-
fieldStrings.add(field.selector());
157-
}
158-
return Joiner.on(',').join(fieldStrings);
159-
}
160141
}
161142

162143
/**
@@ -210,7 +191,8 @@ private DatasetOption(BigQueryRpc.Option option, Object value) {
210191
* returned, even if not specified.
211192
*/
212193
public static DatasetOption fields(DatasetField... fields) {
213-
return new DatasetOption(BigQueryRpc.Option.FIELDS, DatasetField.selector(fields));
194+
return new DatasetOption(BigQueryRpc.Option.FIELDS,
195+
selector(DatasetField.REQUIRED_FIELDS, fields));
214196
}
215197
}
216198

@@ -279,7 +261,8 @@ private TableOption(BigQueryRpc.Option option, Object value) {
279261
* of {@link Table#definition()}) are always returned, even if not specified.
280262
*/
281263
public static TableOption fields(TableField... fields) {
282-
return new TableOption(BigQueryRpc.Option.FIELDS, TableField.selector(fields));
264+
return new TableOption(BigQueryRpc.Option.FIELDS,
265+
selector(TableField.REQUIRED_FIELDS, fields));
283266
}
284267
}
285268

@@ -376,9 +359,9 @@ public static JobListOption pageToken(String pageToken) {
376359
* listing jobs.
377360
*/
378361
public static JobListOption fields(JobField... fields) {
379-
String selector = JobField.selector(fields);
380-
StringBuilder builder = new StringBuilder();
381-
builder.append("etag,jobs(").append(selector).append(",state,errorResult),nextPageToken");
362+
StringBuilder builder =
363+
selector(new StringBuilder().append("etag,jobs("), JobField.REQUIRED_FIELDS, fields)
364+
.append(",state,errorResult),nextPageToken");
382365
return new JobListOption(BigQueryRpc.Option.FIELDS, builder.toString());
383366
}
384367
}
@@ -402,7 +385,8 @@ private JobOption(BigQueryRpc.Option option, Object value) {
402385
* returned, even if not specified.
403386
*/
404387
public static JobOption fields(JobField... fields) {
405-
return new JobOption(BigQueryRpc.Option.FIELDS, JobField.selector(fields));
388+
return new JobOption(BigQueryRpc.Option.FIELDS,
389+
Option.selector(JobField.REQUIRED_FIELDS, fields));
406390
}
407391
}
408392

branches/logging-alpha/gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Option.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.common.base.Joiner;
2122
import com.google.common.base.MoreObjects;
23+
import com.google.common.collect.Sets;
24+
import com.google.gcloud.FieldSelector;
2225
import com.google.gcloud.bigquery.spi.BigQueryRpc;
2326

2427
import java.io.Serializable;
28+
import java.util.List;
2529
import java.util.Objects;
30+
import java.util.Set;
2631

2732
/**
2833
* Base class for BigQuery operation option.
@@ -53,8 +58,7 @@ public boolean equals(Object obj) {
5358
return false;
5459
}
5560
Option other = (Option) obj;
56-
return Objects.equals(rpcOption, other.rpcOption)
57-
&& Objects.equals(value, other.value);
61+
return Objects.equals(rpcOption, other.rpcOption) && Objects.equals(value, other.value);
5862
}
5963

6064
@Override
@@ -69,4 +73,20 @@ public String toString() {
6973
.add("value", value)
7074
.toString();
7175
}
76+
77+
static String selector(List<FieldSelector> required, FieldSelector... others) {
78+
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(required.size() + others.length);
79+
for (FieldSelector field : required) {
80+
fieldStrings.add(field.selector());
81+
}
82+
for (FieldSelector field : others) {
83+
fieldStrings.add(field.selector());
84+
}
85+
return Joiner.on(',').join(fieldStrings);
86+
}
87+
88+
static StringBuilder selector(StringBuilder partialSelector, List<FieldSelector> required,
89+
FieldSelector... others) {
90+
return partialSelector.append(selector(required, others));
91+
}
7292
}

branches/logging-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/dns/testing/package-info.java renamed to branches/logging-alpha/gcloud-java-core/src/main/java/com/google/gcloud/FieldSelector.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,17 @@
1414
* limitations under the License.
1515
*/
1616

17+
package com.google.gcloud;
18+
1719
/**
18-
* A testing helper for Google Cloud DNS.
19-
*
20-
* <p>A simple usage example:
21-
* Before the test:
22-
* <pre> {@code
23-
* // Minimum delay before processing change requests (in ms). Setting the delay to 0 makes change
24-
* // request processing synchronous.
25-
* long delay = 0;
26-
* LocalDnsHelper dnsHelper = LocalDnsHelper.create(delay);
27-
* Dns dns = dnsHelper.options().service();
28-
* dnsHelper.start();
29-
* }</pre>
30-
*
31-
* <p>After the test:
32-
* <pre> {@code
33-
* dnsHelper.stop();
34-
* }</pre>
20+
* Interface for Google Cloud resource's fields. Implementations of this interface can be used to
21+
* select only desired fields when getting or listing Google Cloud resources.
3522
*/
36-
package com.google.gcloud.dns.testing;
23+
public interface FieldSelector {
24+
25+
/**
26+
* Returns a string selector. This selector is passed to a Google Cloud service (possibly with
27+
* other field selectors) to specify which resource fields should be returned by an API call.
28+
*/
29+
String selector();
30+
}

branches/logging-alpha/gcloud-java-dns/src/main/java/com/google/gcloud/dns/AbstractOption.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

21+
import com.google.common.base.Joiner;
2122
import com.google.common.base.MoreObjects;
23+
import com.google.common.collect.Sets;
24+
import com.google.gcloud.FieldSelector;
2225
import com.google.gcloud.dns.spi.DnsRpc;
2326

2427
import java.io.Serializable;
28+
import java.util.List;
2529
import java.util.Objects;
30+
import java.util.Set;
2631

2732
/**
2833
* A base class for options.
@@ -67,4 +72,20 @@ public String toString() {
6772
.add("rpcOption", rpcOption)
6873
.toString();
6974
}
75+
76+
static String selector(List<FieldSelector> required, FieldSelector... others) {
77+
Set<String> fieldStrings = Sets.newHashSetWithExpectedSize(required.size() + others.length);
78+
for (FieldSelector field : required) {
79+
fieldStrings.add(field.selector());
80+
}
81+
for (FieldSelector field : others) {
82+
fieldStrings.add(field.selector());
83+
}
84+
return Joiner.on(',').join(fieldStrings);
85+
}
86+
87+
static StringBuilder selector(StringBuilder partialSelector, List<FieldSelector> required,
88+
FieldSelector... others) {
89+
return partialSelector.append(selector(required, others));
90+
}
7091
}

0 commit comments

Comments
 (0)