Skip to content

Commit 2d2532f

Browse files
committed
Merge pull request #868 from mderka/dns-batch-merge
Dns batch merge
2 parents c026e1a + b29df66 commit 2d2532f

File tree

172 files changed

+4083
-3114
lines changed

Some content is hidden

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

172 files changed

+4083
-3114
lines changed

README.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ If you are using Maven, add this to your pom.xml file
3030
<dependency>
3131
<groupId>com.google.gcloud</groupId>
3232
<artifactId>gcloud-java</artifactId>
33-
<version>0.1.5</version>
33+
<version>0.1.7</version>
3434
</dependency>
3535
```
3636
If you are using Gradle, add this to your dependencies
3737
```Groovy
38-
compile 'com.google.gcloud:gcloud-java:0.1.5'
38+
compile 'com.google.gcloud:gcloud-java:0.1.7'
3939
```
4040
If you are using SBT, add this to your dependencies
4141
```Scala
42-
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.5"
42+
libraryDependencies += "com.google.gcloud" % "gcloud-java" % "0.1.7"
4343
```
4444

4545
Example Applications
@@ -84,8 +84,9 @@ Most `gcloud-java` libraries require a project ID. There are multiple ways to s
8484
1. Project ID supplied when building the service options
8585
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
8686
3. App Engine project ID
87-
4. Google Cloud SDK project ID
88-
5. Compute Engine project ID
87+
4. Project ID specified in the JSON credentials file pointed by the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
88+
5. Google Cloud SDK project ID
89+
6. Compute Engine project ID
8990

9091
Authentication
9192
--------------
@@ -249,13 +250,13 @@ ZoneInfo zoneInfo = ZoneInfo.of(zoneName, domainName, description);
249250
Zone zone = dns.create(zoneInfo);
250251
```
251252
252-
The second snippet shows how to create records inside a zone. The complete code can be found on [CreateOrUpdateDnsRecords.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateDnsRecords.java).
253+
The second snippet shows how to create records inside a zone. The complete code can be found on [CreateOrUpdateRecordSets.java](./gcloud-java-examples/src/main/java/com/google/gcloud/examples/dns/snippets/CreateOrUpdateRecordSets.java).
253254
254255
```java
255-
import com.google.gcloud.dns.ChangeRequest;
256+
import com.google.gcloud.dns.ChangeRequestInfo;
256257
import com.google.gcloud.dns.Dns;
257258
import com.google.gcloud.dns.DnsOptions;
258-
import com.google.gcloud.dns.DnsRecord;
259+
import com.google.gcloud.dns.RecordSet;
259260
import com.google.gcloud.dns.Zone;
260261
261262
import java.util.Iterator;
@@ -265,24 +266,24 @@ Dns dns = DnsOptions.defaultInstance().service();
265266
String zoneName = "my-unique-zone";
266267
Zone zone = dns.getZone(zoneName);
267268
String ip = "12.13.14.15";
268-
DnsRecord toCreate = DnsRecord.builder("www.someexampledomain.com.", DnsRecord.Type.A)
269+
RecordSet toCreate = RecordSet.builder("www.someexampledomain.com.", RecordSet.Type.A)
269270
.ttl(24, TimeUnit.HOURS)
270271
.addRecord(ip)
271272
.build();
272-
ChangeRequest.Builder changeBuilder = ChangeRequest.builder().add(toCreate);
273+
ChangeRequestInfo.Builder changeBuilder = ChangeRequestInfo.builder().add(toCreate);
273274
274275
// Verify that the record does not exist yet.
275276
// If it does exist, we will overwrite it with our prepared record.
276-
Iterator<DnsRecord> recordIterator = zone.listDnsRecords().iterateAll();
277-
while (recordIterator.hasNext()) {
278-
DnsRecord current = recordIterator.next();
277+
Iterator<RecordSet> recordSetIterator = zone.listRecordSets().iterateAll();
278+
while (recordSetIterator.hasNext()) {
279+
RecordSet current = recordSetIterator.next();
279280
if (toCreate.name().equals(current.name()) &&
280281
toCreate.type().equals(current.type())) {
281282
changeBuilder.delete(current);
282283
}
283284
}
284285
285-
ChangeRequest changeRequest = changeBuilder.build();
286+
ChangeRequestInfo changeRequest = changeBuilder.build();
286287
zone.applyChangeRequest(changeRequest);
287288
```
288289

RELEASING.md

+2-2
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.
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.
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.
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

codacy-conf.json

+1-1
Large diffs are not rendered by default.

gcloud-java-bigquery/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ If you are using Maven, add this to your pom.xml file
2222
<dependency>
2323
<groupId>com.google.gcloud</groupId>
2424
<artifactId>gcloud-java-bigquery</artifactId>
25-
<version>0.1.5</version>
25+
<version>0.1.7</version>
2626
</dependency>
2727
```
2828
If you are using Gradle, add this to your dependencies
2929
```Groovy
30-
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.5'
30+
compile 'com.google.gcloud:gcloud-java-bigquery:0.1.7'
3131
```
3232
If you are using SBT, add this to your dependencies
3333
```Scala
34-
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.5"
34+
libraryDependencies += "com.google.gcloud" % "gcloud-java-bigquery" % "0.1.7"
3535
```
3636

3737
Example Application

gcloud-java-bigquery/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<parent>
1111
<groupId>com.google.gcloud</groupId>
1212
<artifactId>gcloud-java-pom</artifactId>
13-
<version>0.1.6-SNAPSHOT</version>
13+
<version>0.1.8-SNAPSHOT</version>
1414
</parent>
1515
<properties>
1616
<site.installationModule>gcloud-java-bigquery</site.installationModule>

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/BigQuery.java

+35-51
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
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;
25+
import com.google.gcloud.FieldSelector.Helper;
2626
import com.google.gcloud.Page;
2727
import com.google.gcloud.Service;
2828
import com.google.gcloud.bigquery.spi.BigQueryRpc;
2929

3030
import java.util.List;
31-
import java.util.Set;
3231

3332
/**
3433
* An interface for Google Cloud BigQuery.
@@ -43,7 +42,7 @@ public interface BigQuery extends Service<BigQueryOptions> {
4342
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/datasets#resource">Dataset
4443
* Resource</a>
4544
*/
46-
enum DatasetField {
45+
enum DatasetField implements FieldSelector {
4746
ACCESS("access"),
4847
CREATION_TIME("creationTime"),
4948
DATASET_REFERENCE("datasetReference"),
@@ -56,24 +55,19 @@ enum DatasetField {
5655
LOCATION("location"),
5756
SELF_LINK("selfLink");
5857

58+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
59+
ImmutableList.of(DATASET_REFERENCE);
60+
5961
private final String selector;
6062

6163
DatasetField(String selector) {
6264
this.selector = selector;
6365
}
6466

67+
@Override
6568
public String selector() {
6669
return selector;
6770
}
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-
}
7771
}
7872

7973
/**
@@ -82,7 +76,7 @@ static String selector(DatasetField... fields) {
8276
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/tables#resource">Table
8377
* Resource</a>
8478
*/
85-
enum TableField {
79+
enum TableField implements FieldSelector {
8680
CREATION_TIME("creationTime"),
8781
DESCRIPTION("description"),
8882
ETAG("etag"),
@@ -101,25 +95,19 @@ enum TableField {
10195
TYPE("type"),
10296
VIEW("view");
10397

98+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
99+
ImmutableList.of(TABLE_REFERENCE, TYPE);
100+
104101
private final String selector;
105102

106103
TableField(String selector) {
107104
this.selector = selector;
108105
}
109106

107+
@Override
110108
public String selector() {
111109
return selector;
112110
}
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-
}
123111
}
124112

125113
/**
@@ -128,7 +116,7 @@ static String selector(TableField... fields) {
128116
* @see <a href="https://cloud.google.com/bigquery/docs/reference/v2/jobs#resource">Job Resource
129117
* </a>
130118
*/
131-
enum JobField {
119+
enum JobField implements FieldSelector {
132120
CONFIGURATION("configuration"),
133121
ETAG("etag"),
134122
ID("id"),
@@ -138,25 +126,19 @@ enum JobField {
138126
STATUS("status"),
139127
USER_EMAIL("user_email");
140128

129+
static final List<? extends FieldSelector> REQUIRED_FIELDS =
130+
ImmutableList.of(JOB_REFERENCE, CONFIGURATION);
131+
141132
private final String selector;
142133

143134
JobField(String selector) {
144135
this.selector = selector;
145136
}
146137

138+
@Override
147139
public String selector() {
148140
return selector;
149141
}
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-
}
160142
}
161143

162144
/**
@@ -210,7 +192,8 @@ private DatasetOption(BigQueryRpc.Option option, Object value) {
210192
* returned, even if not specified.
211193
*/
212194
public static DatasetOption fields(DatasetField... fields) {
213-
return new DatasetOption(BigQueryRpc.Option.FIELDS, DatasetField.selector(fields));
195+
return new DatasetOption(BigQueryRpc.Option.FIELDS,
196+
Helper.selector(DatasetField.REQUIRED_FIELDS, fields));
214197
}
215198
}
216199

@@ -279,7 +262,8 @@ private TableOption(BigQueryRpc.Option option, Object value) {
279262
* of {@link Table#definition()}) are always returned, even if not specified.
280263
*/
281264
public static TableOption fields(TableField... fields) {
282-
return new TableOption(BigQueryRpc.Option.FIELDS, TableField.selector(fields));
265+
return new TableOption(BigQueryRpc.Option.FIELDS,
266+
Helper.selector(TableField.REQUIRED_FIELDS, fields));
283267
}
284268
}
285269

@@ -376,10 +360,8 @@ public static JobListOption pageToken(String pageToken) {
376360
* listing jobs.
377361
*/
378362
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");
382-
return new JobListOption(BigQueryRpc.Option.FIELDS, builder.toString());
363+
return new JobListOption(BigQueryRpc.Option.FIELDS,
364+
Helper.listSelector("jobs", JobField.REQUIRED_FIELDS, fields, "state", "errorResult"));
383365
}
384366
}
385367

@@ -402,7 +384,8 @@ private JobOption(BigQueryRpc.Option option, Object value) {
402384
* returned, even if not specified.
403385
*/
404386
public static JobOption fields(JobField... fields) {
405-
return new JobOption(BigQueryRpc.Option.FIELDS, JobField.selector(fields));
387+
return new JobOption(BigQueryRpc.Option.FIELDS,
388+
Helper.selector(JobField.REQUIRED_FIELDS, fields));
406389
}
407390
}
408391

@@ -488,9 +471,10 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
488471
Dataset getDataset(DatasetId datasetId, DatasetOption... options);
489472

490473
/**
491-
* Lists the project's datasets. This method returns partial information on each dataset
492-
* ({@link Dataset#datasetId()}, {@link Dataset#friendlyName()} and {@link Dataset#id()}). To get
493-
* complete information use either {@link #getDataset(String, DatasetOption...)} or
474+
* Lists the project's datasets. This method returns partial information on each dataset:
475+
* ({@link Dataset#datasetId()}, {@link Dataset#friendlyName()} and
476+
* {@link Dataset#generatedId()}). To get complete information use either
477+
* {@link #getDataset(String, DatasetOption...)} or
494478
* {@link #getDataset(DatasetId, DatasetOption...)}.
495479
*
496480
* @throws BigQueryException upon failure
@@ -558,9 +542,9 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
558542
Table getTable(TableId tableId, TableOption... options);
559543

560544
/**
561-
* Lists the tables in the dataset. This method returns partial information on each table
562-
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#id()} and type, which
563-
* is part of {@link Table#definition()}). To get complete information use either
545+
* Lists the tables in the dataset. This method returns partial information on each table:
546+
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#generatedId()} and type,
547+
* which is part of {@link Table#definition()}). To get complete information use either
564548
* {@link #getTable(TableId, TableOption...)} or
565549
* {@link #getTable(String, String, TableOption...)}.
566550
*
@@ -569,9 +553,9 @@ public static QueryResultsOption maxWaitTime(long maxWaitTime) {
569553
Page<Table> listTables(String datasetId, TableListOption... options);
570554

571555
/**
572-
* Lists the tables in the dataset. This method returns partial information on each table
573-
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#id()} and type, which
574-
* is part of {@link Table#definition()}). To get complete information use either
556+
* Lists the tables in the dataset. This method returns partial information on each table:
557+
* ({@link Table#tableId()}, {@link Table#friendlyName()}, {@link Table#generatedId()} and type,
558+
* which is part of {@link Table#definition()}). To get complete information use either
575559
* {@link #getTable(TableId, TableOption...)} or
576560
* {@link #getTable(String, String, TableOption...)}.
577561
*

gcloud-java-bigquery/src/main/java/com/google/gcloud/bigquery/Dataset.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public Builder friendlyName(String friendlyName) {
103103
}
104104

105105
@Override
106-
Builder id(String id) {
107-
infoBuilder.id(id);
106+
Builder generatedId(String generatedId) {
107+
infoBuilder.generatedId(generatedId);
108108
return this;
109109
}
110110

0 commit comments

Comments
 (0)